# ansible playbook with curl

**URL:** <https://forum.ansible.com/t/ansible-playbook-with-curl/24196>\
**Category:** Ansible Project\
**Created:** [April 12, 2017, 12:18am UTC](https://forum.ansible.com/t/ansible-playbook-with-curl/24196 "2017-04-12T00:18:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shankar\_Bala](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@Shankar\_Bala](https://forum.ansible.com/u/Shankar_Bala)\
**Post date:** [April 12, 2017, 12:18am UTC](https://forum.ansible.com/t/ansible-playbook-with-curl/24196/1 "2017-04-12T00:18:22Z")

</div>

Hi All

I am trying to run ansible playbook to create powerdns record .pdns.yml

- name: add dns record  
vars:  
pilot\_dns: “{{ input\_dns }}”  
pilot\_dom: “{{ input\_domain }}”  
arecord: “{{ input\_hostname }}”  
iprecord: “{{ input\_ip }}”  
command: curl -X PATCH --data ‘{“rrsets”: [{“name”: "’" {{ arecord }} “.'”, “type”: “A”, “ttl”: 86400, “changetype”: “REPLACE”, “records”: [ {“content”: “'” {{ iprecord }} “'”, “disabled”: false }] } ] }’ -H “‘X-API-Key: changeme’” ‘http://“{{ pilot\_pdns }}”:8081/api/v1/servers/localhost/zones/“{{ pilot\_dom }}”.’ | jq .  
tags: add\_pdns

I get syntax error when i run as “ansible-playbook pdns.yml --check”

ERROR! Syntax Error while loading YAML.

The offending line appears to be:

iprecord: “{{ input\_ip }}”  
command: curl -X PATCH --data ‘{“rrsets”: [{“name”: "’" {{ arecord }} “.'”, “type”: “A”, “ttl”: 86400, “changetype”: “REPLACE”, “records”: [ {“content”: “'” {{ iprecord }} “'”, “disabled”: false }] } ] }’ -H “‘X-API-Key: changeme’” ‘http://“{{ pilot\_pdns }}”:8081/api/v1/servers/localhost/zones/“{{ pilot\_dom }}”.’ | jq .  
^ here

any help here ?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [April 12, 2017, 9:34pm UTC](https://forum.ansible.com/t/ansible-playbook-with-curl/24196/2 "2017-04-12T21:34:27Z")

</div>

Why not just use the `uri` module?

The following should be equivalent:

- uri:  
method: PATCH  
url: “http://{{ pilot\_pdns }}:8081/api/v1/servers/localhost/zones/{{ pilot\_dom }}”  
body:  
rrsets:
- name: “{{ arecord }}”  
type: A  
ttl: 86400  
changetype: REPLACE  
records:
- content: “{{ iprecord }}”  
disabled: false  
body\_format: json  
headers:  
‘X-API-Key’: changeme  
return\_content: yes  
register: whatever  
tags:
- add\_pdns  
vars:  
pilot\_dns: “{{ input\_dns }}”  
pilot\_dom: “{{ input\_domain }}”  
arecord: “{{ input\_hostname }}”  
iprecord: “{{ input\_ip }}”

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [April 12, 2017, 9:37pm UTC](https://forum.ansible.com/t/ansible-playbook-with-curl/24196/3 "2017-04-12T21:37:25Z")

</div>

Or even more tailored for this job:  
[https://github.com/Nosmoht/ansible-module-powerdns#records](https://github.com/Nosmoht/ansible-module-powerdns#records)
