Skip to content

Commit

Permalink
don't use json_query for data filtering
Browse files Browse the repository at this point in the history
The json_query filter isn't officially supported and should be avoided.
  • Loading branch information
evgeni authored and adamruzicka committed Jan 20, 2021
1 parent c56e30a commit d69a82c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ An installer playbook for setting up Satellite with a Receptor node connected to
Requirements
------------

This role requires Receptor and python2-jmespath be installed on the system.
This role requires Receptor be installed on the system.

Role Variables
--------------
Expand Down
8 changes: 2 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
file:
path: "{{ receptor_data_dir }}"
state: directory
- name: Install role dependencies
yum:
name: python2-jmespath
state: installed
- name: Determine which command to use for locking packages
include_tasks: determine_maintain_command.yml
loop:
Expand Down Expand Up @@ -85,7 +81,7 @@
register: account_dirs_full_path
- name: Extract account dirs
set_fact:
account_dirs: "{{ account_dirs_full_path | json_query('files[*].path') | map('basename') | list }}"
account_dirs: "{{ account_dirs_full_path.files | map(attribute='path') | map('basename') | list }}"
- name: Identify Satellite ID from Satellite
uri:
url: "{{ satellite_url }}/api/settings?search=name%20%3D%20instance_id"
Expand All @@ -97,7 +93,7 @@
register: satellite_uuid_json
- name: Extract Satellite ID from result
set_fact:
satellite_uuid: "{{ satellite_uuid_json | json_query('json.results[0].value') }}"
satellite_uuid: "{{ satellite_uuid_json.json.results[0].value }}"
- name: Set up Source with c.rh.c for each account
include_tasks: register_with_sources.yml
loop: "{{ account_dirs }}"
Expand Down
6 changes: 3 additions & 3 deletions tasks/register_with_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
register: source_types_response
- name: Extract Satellite source type from response
set_fact:
source_type_id: "{{ source_types_response.json | json_query('data[0].id') }}"
source_type_id: "{{ source_types_response.json.data[0].id }}"
- name: See if source already exists
uri:
url: "https://{{ c_rh_c_host }}/api/sources/v2.0/sources?source_ref={{ satellite_uuid }}"
Expand Down Expand Up @@ -46,7 +46,7 @@
when: existing_source_response.json.meta.count == 0
- name: Set source ID fact (pre-existing)
set_fact:
source_id: "{{ existing_source_response.json | json_query('data[0].id') }}"
source_id: "{{ existing_source_response.json.data[0].id }}"
when: existing_source_response.json.meta.count != 0
- debug:
msg: "Source ID {{ source_id }}"
Expand Down Expand Up @@ -80,7 +80,7 @@
register: application_types_response
- name: Set application type ID fact
set_fact:
application_type_id: "{{ application_types_response.json | json_query('data[0].id') }}"
application_type_id: "{{ application_types_response.json.data[0].id }}"
- name: See if application already exists
uri:
url: "https://{{ c_rh_c_host }}/api/sources/v2.0/applications?source_id={{ source_id }}&application_type_id={{ application_type_id }}"
Expand Down

0 comments on commit d69a82c

Please sign in to comment.