Ansible: Different ways to run a playbook

Posted on Posted in Ansible

Running a playbook over ssh with username and password

 

I find that normally when setting up a virtual machine that I haven’t added ssh pubic keys yet that this method works well.

-k ask for password for ssh connection

-u remote user to use for the ssh connection

ansible-playbook  -k -u username1 playbook.yaml

 

Running a playbook on a single server.

So you have your /etc/ansible/hosts file filled out with your environment, lets say your ansible host file consists of a heading called[servers].

the the top of your playbooks will say hosts: servers.

the /etc/ansible/hosts this will look like:-
[servers]
192.168.0.10
192.168.0.11

We are testing and want to run a playbook on a single node, here is the command, along with the other options from the top of the article.

-l = limit to hosts or nodes what you put in /etc/ansible/hosts

ansible-playbook -k -u username1 -l 192.168.0.102

Leave a Reply

Your email address will not be published. Required fields are marked *