Skip to content

ansible playbook arguments

Mohit edited this page Aug 9, 2017 · 1 revision

Running Plays from a playbook

ansible-playbook <your-playbook-filename>.yml -i ./hosts

The above command will run the playbook on all the hosts mentioned in the hosts file.

  • To see all the hosts that will be modified, pass the flag list-hosts
  • To perform dry run, you can also pass --check flag.

Running the playbook as a user

ansible-playbook playbook.yml -i ./hosts --remote-user=mohitsharma44

This will run the playbook as mohitsharma44 user.

If the user needs to run plays with elevated privileges, you can pass --sudo and --sudo-user=... and --ask-sudo-pass