Skip to content

Updating-string #2507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions roles/aws/aws_admin_tools/tasks/create_methods.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,18 @@
--region {{ _aws_region }}
when: item.url_params is not defined or item.url_params | length == 0

- name: Generate template parts for each param
set_fact:
template_parts: "{{ item.url_params | map('regex_replace', '^(.*)$', '\\\"\\1\\\": \\\"$input.params(''\\1'')\\\"') | list }}"
- name: Generate URL parameters string
ansible.builtin.set_fact:
url_params_string: >-
{% for _url in item.url_params %}
{{ '' if loop.first else ',' }}
\"{{ _url }}\": \"$input.params('{{ _url }}')\"
{% endfor %}
when: item.url_params is defined and item.url_params | length > 0

- name: Create final template string
set_fact:
template_string: "{ \"application/json\": \"{ {{ template_parts | join(',') }} }\" }"
template_string: "{ \"application/json\": \"{ {{ url_params_string }} }\" }"
when: item.url_params is defined and item.url_params | length > 0

- name: Write template to file
Expand Down