Ansible Playbook Execution¶
After all requirements have been met, the playbook can be executed.
Depending on how Ansible was installed, a Python virtual environment may need to
be activated so that the ansible-playbook
command is available:
source venv/bin/activate
Once the ansible-playbook
command is available, execute the playbook from the
installation package root with the following:
ansible-playbook -i hosts.ini playbook.yaml
If you are connecting to the host targets as a different user than yourself,
specify the -u
flag:
ansible-playbook -i hosts.ini playbook.yaml -u ec2-user
If the playbook needs to be run as the installation user without privilege
escalation, pass --extra-vars "use_become=False"
to the command. This will
skip any tasks that would require elevated privileges. To more permanently
set this behavior, set the use_become
variable to False
in the hosts.ini
file.
Note
The use_become
variable is set to True
by default. If running with
use_become=True
, the installation user must have sudo permissions. If
running with use_become=False
, tasks that require elevated privileges
must have been executed prior to running the playbook.
ansible-playbook -i hosts.ini playbook.yaml -u vrisk --extra-vars "use_become=False"