vars:
- paydata: {"status":"complete","message":"successfully
completed","actions":["close ticket"]}
- local_action: command curl -X PUT -i -H "Content-Type:application/json" https://ansibledev.corp.xxxx.com:8443/api/job/{{ ticket }} -k --data "{{ paydata }}" completed","actions":["close ticket"]}' --header
But here is the error I am getting. Seems "paydata" is not passed as expected.
fatal: [10.225.240.39 -> localhost]: FAILED! => {"changed": true, "cmd": ["curl", "-X", "PUT", "-i", "-H", "Content-Type:application/json", "https://gns-ansible-dev.corp.xxx.com:8443/api/job/CRQmattcheng22", "-k", "-d", "{ustatus:", "ucomplete,", "umessage:", "usuccessfully completed,", "uactions:", "[uclose ticket]}",
Any resolution?
Thank you in advance.
Bikram
Hi All,
I defined a json variable in vars section and want to pass it as body in curl command as below:
Have you considered using the uri module instead?
vars:
- paydata: {"status":"complete","message":"successfully
completed","actions":["close ticket"]}
- local_action: command curl -X PUT -i -H "Content-Type:application/json" https://ansibledev.corp.xxxx.com:8443/api/job/{{ ticket }} -k --data "{{ paydata }}" completed","actions":["close ticket"]}' --header
But here is the error I am getting. Seems "paydata" is not passed as expected.
fatal: [10.225.240.39 -> localhost]: FAILED! => {"changed": true, "cmd": ["curl", "-X", "PUT", "-i", "-H", "Content-Type:application/json", "https://gns-ansible-dev.corp.xxx.com:8443/api/job/CRQmattcheng22", "-k", "-d", "{ustatus:", "ucomplete,", "umessage:", "usuccessfully completed,", "uactions:", "[uclose ticket]}",
Any resolution?
Please post your playbook. It looks like the data needs proper
escaping to be used in the command line.
-
Sudheer S
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a096b6cb-4b69-6420-2050-057b98addb1b%40olstad.com.
For more options, visit https://groups.google.com/d/optout.
- name: authenticate with restible via oauth2.0
uri:
body:
grant_type: client_credentials
body_format: form-urlencoded
force_basic_auth: yes
method: POST
user: "{{ client_id }}"
password: "{{ client_secret}}"
status_code: 201
url: https://gns-ansible-dev.corp.xxx.com:8443/auth/token
validate_certs: no
register: token_auth_response
- set_fact: access_token="{{ 'Authorization:'+'Bearer' + ' ' + token_auth_response.json.access_token }}"
- local_action: command curl -X PUT -i -H "Content-Type:application/json" https://gns-ansible-dev.corp.xxx.com:8443/api/job/{{ ticket }} -k --data '{"status":"complete","message":"unsuccessfully completed","actions":["close ticket"]}' --header "{{ access_token }}"
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/be015628-d567-2ef2-0150-661008594503%40techchorus.net.
headers:
Authorization: "Bearer {{ token_auth_response.json.access_token }}"
Content-Type: "application/json"
Thanks for your help.
Bikram