Adding vars to the play
Variables can be defines in many locations, and we can get them from the facts gathering stage as well.
lets add some content to the nginx servers, create a file called index.html.tpl
with the content:
{% embed include file="src/examples/aintro/index.html.tpl)
and run the playbook again:
yonit@ansible_server:~/ansible$ ansible-playbook nginx_install.yml
PLAY [virtualhosts] ********************************************************************************
TASK [Gathering Facts] *****************************************************************************
ok: [ubuntu-1]
ok: [ubuntu-2]
TASK [install nginx] *******************************************************************************
ok: [ubuntu-1]
ok: [ubuntu-2]
TASK [Setup nginx conf] ****************************************************************************
ok: [ubuntu-1]
ok: [ubuntu-2]
TASK [add index.html file] *************************************************************************
changed: [ubuntu-2]
changed: [ubuntu-1]
PLAY RECAP *****************************************************************************************
ubuntu-1 : ok=4 changed=1 unreachable=0 failed=0
ubuntu-2 : ok=4 changed=1 unreachable=0 failed=0
now lets see it:
yonit@ansible_server:~/ansible$ curl http://ubuntu-2/
{% embed include file="src/examples/aintro/output2.html)