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 in Ansible by Thomas
41 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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 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 9 in Ansible by Vijay
27 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,500 points
226 views
0 votes
1 answer

When conditional not working in Ansible

Your identation is wrong and when is ...READ MORE

answered Apr 27, 2018 in Ansible by ajs3033
• 7,040 points
473 views
+13 votes
2 answers
0 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 in Ansible by Nicolas
594 views
0 votes
1 answer

How to ignore failed commands in Ansible?

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

answered Feb 7 in Ansible by Patt
407 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.