Run Ansible adhoc commands in sequence

0 votes

I'm trying to run ansible adhoc commands on an ec2 instance on aws sequentially but I think its getting executed parallelly.

Something like this:

ansible aws -a "hostname"
ec2 | SUCCESS | rc=0 >>
ip-172-31-36-255

ec3 | SUCCESS | rc=0 >>
ip-172-31-45-174

ansible aws -a "hostname"
ec3 | SUCCESS | rc=0 >>
ip-172-31-45-174

ec2 | SUCCESS | rc=0 >>
ip-172-31-36-255
Jan 14, 2019 in Ansible by Thomas
1,582 views

1 answer to this question.

0 votes

Hey @Thomas, by default ansible runs these commands parellely. If you want it to be executed sequencially then you need to explicitly mention it using --fork.

On adhoc command:

ansible aws -a "hostname" --forks=1

Inside the playbook:

- hosts: aws
  become: yes
  gather_facts: yes
  serial: 1
  tasks:
    - your tasks
answered Jan 14, 2019 by Barbara

Related Questions In Ansible

0 votes
1 answer

Is it possible to run commands on ansible host?

If you just trying to run a ...READ MORE

answered Jan 10, 2019 in Ansible by Vijay
1,424 views
0 votes
1 answer
0 votes
1 answer

Can we run parallel jobs in Ansible

Running parallel tasks in Ansible is not ...READ MORE

answered Aug 5, 2019 in Ansible by Kalgi
• 52,350 points
5,098 views
0 votes
1 answer

How to run Ansible-Playbook in the localhost?

Hi@akhtar, To run any playbook in the local ...READ MORE

answered Aug 11, 2020 in Ansible by MD
• 95,460 points
2,810 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,036 views
+2 votes
1 answer
0 votes
1 answer

Is it possible to run an Ansible Playbook in python script?

Hey @Cerci, Of course its possible. You ...READ MORE

answered Jan 17, 2019 in Ansible by Nicolas
15,668 views
0 votes
1 answer

How to ignore failed commands in Ansible?

Usually, if even one command fails to ...READ MORE

answered Feb 7, 2019 in Ansible by Patt
15,682 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