From d69a82c5e8be204fcef7491aede3fae9199e65df Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Fri, 8 Jan 2021 11:53:41 +0100 Subject: [PATCH] don't use json_query for data filtering The json_query filter isn't officially supported and should be avoided. --- README.md | 2 +- tasks/main.yml | 8 ++------ tasks/register_with_sources.yml | 6 +++--- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7676ada..319d383 100644 --- a/README.md +++ b/README.md @@ -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 -------------- diff --git a/tasks/main.yml b/tasks/main.yml index 3634ffd..dc0afee 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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: @@ -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" @@ -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 }}" diff --git a/tasks/register_with_sources.yml b/tasks/register_with_sources.yml index 1ad4b4a..5f69946 100644 --- a/tasks/register_with_sources.yml +++ b/tasks/register_with_sources.yml @@ -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 }}" @@ -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 }}" @@ -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 }}"