Execute a command using ansible playbook

0 votes

I'm trying to execute this command using ansible playbook but I'm not sure where to start writing the playbook.

Command:

curl -X POST -d@mesos-consul.json -H "Content-Type: application/json" http://marathon.service.consul:8080/v2/apps

I need a playbook to execute this. Thank you 

Jan 17 in Ansible by Reshma

edited Jan 18 by Vardhan 164 views

1 answer to this question.

0 votes

Hey @Reshma, You can use the URI Module for this purpose. This module interacts with http and https servers supports many authentication mechanism.  

Try something like this:

tasks:
- name: post to consul
  uri:
    url: http://marathon.service.consul:8080/v2/apps/
    method: POST
    body: "{{ lookup('file','mesos-consul.json') }}"
    body_format: json
    headers:
      Content-Type: "application/json"
answered Jan 17 by Sameer

Related Questions In Ansible

0 votes
1 answer
0 votes
1 answer

Running a playbook using Ansible on Jenkins

Hey, @Asha seems like you've added a ...READ MORE

answered Apr 4 in Ansible by Akhil
314 views
0 votes
1 answer

How can I create a new user using ansible ploybook?

You're switching from the root user. Root ...READ MORE

answered Mar 29, 2018 in Ansible by DareDev
• 6,810 points
111 views
0 votes
1 answer

How do I execute a shell script and then use the result in ansible

This can work out for you: - name: ...READ MORE

answered Apr 11, 2018 in Ansible by shubham
• 6,890 points
745 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
145 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer