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, 2019 in Ansible by Reshma

edited Jan 18, 2019 by Vardhan 850 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, 2019 by Sameer

Related Questions In Ansible

0 votes
1 answer

How do I wget a file from web server using shell in the ansible playbook

Hey Ayaan, you could probably use this ...READ MORE

answered Jan 24, 2019 in Ansible by Anushri
980 views
0 votes
1 answer

Running a playbook using Ansible on Jenkins

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

answered Apr 4, 2019 in Ansible by Akhil
1,219 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,850 points
189 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,910 points
2,375 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,400 points
425 views
0 votes
1 answer
0 votes
1 answer

Execute ansible playbook on a docker container

Hey @Ram, you could use a dockerfile ...READ MORE

answered Jan 21, 2019 in Ansible by Vedant
1,844 views
0 votes
1 answer

obtain information about a file in windows using ansible playbook

Hey @Travis, you can use the win_stat ...READ MORE

answered Jun 10, 2019 in Ansible by Drake
277 views