I’m trying to dynamically create the JSON response needed for my REST request, I can hard code the JSON var and it works but when I add a variable it fails.
- name: add ssh key to stash via api
uri:
url: "{{stash_api_url}}"
user: "{{stash_username}}"
password: "{{stash_password}}"
force_basic_auth: yes
method: POST
body: '''{"text":"{{stash_ansible_ssh_key_contents.stdout}}"}'''
body_format: json
status_code: 201,409
HEADER_Content-Type: "application/json"
register: ssh_key_added_to_stash
when: stash_ansible_ssh_key_contents.stdout != -1
tried:
- body: '{"text":"{{stash_ansible_ssh_key_contents.stdout}}"}'
- body: ''{"text":"{{stash_ansible_ssh_key_contents.stdout}}"}''
- body: '''{"text":"{{stash_ansible_ssh_key_contents.stdout}}"}'''
if I reverse the single and double quotes there is still an issue