We are now going to run your brand spankin' new playbook on your two web nodes. To do this,
you are going to use the
Step 1: From your playbook directory (
), run your playbook.
ansible-playbook -i ./hosts -k install_apache.yml
However, before you go ahead and run that command, lets take a few moments to understand the options.
-i This option allows you to specify the inventory file you wish to use.
-k This option prompts you for the password of the user running the playbook.
-v Although not used here, this increases verbosity. Try running your playbook a second time using
to increase the verbosity
--syntax-check If you run into any issues with your playbook running properly; you know, from that copy/pasting that you didn’t do because we said "don’t do that"; you could use this option to help find those issues like so…
ansible-playbook -i ./hosts -k install_apache.yml --syntax-check
OK, go ahead and run your playbook as specified in Step 1
In standard output, you should see something that looks very similar to the following:
Notice that the play and each task is named so that you can see what is being done and to which node it is being done to.
You also may notice a task in there that you didn’t write; <cough>
<cough>. This is because the
runs by default. To turn if off, you can specify gather_facts: false in your play definition like this:
--- - hosts: web name: Install the apache web service become: yes gather_facts: false
Step 2: Remove Apache
OK, for the next several minutes or as much time as we can afford, we want to to experiment a little. We would like you to reverse what you’ve done, i.e. stop and uninstall apache on your web nodes. So, go ahead and edit your playbook and then when your finished, rerun it as specified in Step 1. For this exercise we aren’t going to show you line by line, but we will give you a few hints.
Feel free to browse the help pages to see a list of all options.