At the top level of our Ansible repository (two directories up from the helloworld role), we are going to create a new file called helloworld.yml. In this file, we are going to add the following:
--- - hosts: "{{ target | default('localhost') }}" become: yes roles: - helloworld
This basically tells Ansible to execute the helloworld role onto the hosts listed in the target variable, or localhost if the target isn't defined. The become option will tell Ansible to execute the role with elevated privileges (in our case, sudo). At this point, your Ansible repository should look like the example at https://github.com/yogeshraheja/Effective-DevOps-with-AWS/tree/master/Chapter03/ansible. We are now ready to test our playbook. ...