SARATH CHANDRAN
SARATH CHANDRAN

Reputation: 315

how to run multiple command in a single line in ansible

I need to a run two ansible command in a single line. While am running the command its taking only the second command .

ansible -i list  cdlk -a "touch /tmp/a" -a "touch /tmp/b" --private-key=/tmp/id_rsa

I have create a file called list and after running this command only /tmp/b file is getting created .How I can run multiple commands in single line?

Upvotes: 0

Views: 4997

Answers (1)

Abdulla Thanseeh
Abdulla Thanseeh

Reputation: 10526

By default ansible CLI uses command module, which does not feed its arguments trough shell.change your parameter according to requirement.An example is shared below

You want to use shell module instead:

ansible host -m shell -a 'echo hello && echo world'

Upvotes: 2

Related Questions