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 5,454 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
4,159 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
3,491 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, 2020 in Ansible by MD
• 95,460 points
14,413 views
0 votes
1 answer

How to pull a docker image using Ansible playbook?

Did you try using this? https://docs.ansible.com/ansible/latest/colle ...READ MORE

answered Nov 5, 2020 in Ansible by undermink
10,875 views
+15 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,041 views
+2 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 22, 2019 in Ansible by Vedant
5,905 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 11, 2019 in Ansible by Drake
1,465 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP