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 1,533 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
1,405 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,791 views
0 votes
1 answer

How to overwrite the content of a file in remote systems using Ansible playbook?

Hi@akhtar, You can find one argument in the ...READ MORE

answered Aug 2 in Ansible by MD
• 43,520 points
30 views
0 votes
0 answers

How to pull a docker image using Ansible playbook?

Hi Guys, I am new in Ansible. I ...READ MORE

Aug 4 in Ansible by akhtar
• 18,760 points
40 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,420 points
610 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
2,965 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
316 views