Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

More vars

To get the index files to display the name of the server i need to use a variable in the template

lets rename the index.html file: mv index.html.tpl index.html.j2

and edit the playbook, change these line:

src=index.html.tpl
to
src=index.html.j2

and lets slightly change index.html.j2:

{% embed include file="src/examples/aintro/index.html.j2)

run the playbook:

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

and now:

yonit@ansible_server:~/ansible$ curl http://ubuntu-2/

{% embed include file="src/examples/aintro/output5.html)