Escape invalid JSON characters during deployment.

By first quoting the JSON query, it is possible to easily pass
it to the json_query plugin. This allows elements with special
characters, such as a hyphen -, to be resolvable.

Conflicts:
    tripleo_common/templates/deployments.yaml

Change-Id: I56f3e5f96dc25f16aed585ca6678de53721071b7
Closes-Bug: #1853321
Signed-off-by: Luke Short <ekultails@gmail.com>
(cherry picked from commit f81e0bf426)
This commit is contained in:
Luke Short 2019-11-12 14:17:52 -05:00
parent 2534143091
commit 5610fae465
1 changed files with 7 additions and 2 deletions

View File

@ -1,10 +1,15 @@
- name: Quote the JSON queries to escape invalid characters
set_fact:
item_id: '"{{ item }}".id'
item_only: '"{{ item }}"'
- name: Lookup deployment UUID - name: Lookup deployment UUID
set_fact: set_fact:
deployment_uuid: "{{ lookup('file', role_name ~ '/' ~ ansible_hostname | lower ~ '/' ~ item) | from_yaml | json_query(item ~ '.id')}}" deployment_uuid: "{{ lookup('file', role_name ~ '/' ~ ansible_hostname | lower ~ '/' ~ item) | from_yaml | json_query(item_id)}}"
- name: "Render deployment file for {{ item }}" - name: "Render deployment file for {{ item }}"
copy: copy:
content: "[ {{ lookup('file', role_name ~ '/' ~ ansible_hostname | lower ~ '/' ~ item) | from_yaml | json_query(item) }} ]" content: "[ {{ lookup('file', role_name ~ '/' ~ ansible_hostname | lower ~ '/' ~ item) | from_yaml | json_query(item_only) }} ]"
dest: "/var/lib/heat-config/tripleo-config-download/{{ item }}" dest: "/var/lib/heat-config/tripleo-config-download/{{ item }}"
become: true become: true