From: Lorin Hochstein Date: Sun, 15 Feb 2015 22:07:08 +0000 (-0500) Subject: Use a template for rendering index.html X-Git-Url: https://git.halfball.org/?a=commitdiff_plain;h=c61fdc64edb412999d6cfe13dcedf5e717584002;p=ansiblebook.git Use a template for rendering index.html --- diff --git a/ch02/playbooks/templates/index.html.j2 b/ch02/playbooks/templates/index.html.j2 new file mode 100644 index 0000000..a276e9d --- /dev/null +++ b/ch02/playbooks/templates/index.html.j2 @@ -0,0 +1,12 @@ + + + Welcome to ansible + + +

nginx, configured by Ansible

+

If you can see this, Ansible successfully installed nginx.

+ +

{{ ansible_managed }}

+ + + diff --git a/ch02/playbooks/web-notls.yml b/ch02/playbooks/web-notls.yml index 31ffc17..ea66c8f 100644 --- a/ch02/playbooks/web-notls.yml +++ b/ch02/playbooks/web-notls.yml @@ -13,6 +13,6 @@ src=/etc/nginx/sites-available/default state=link - name: copy index.html - copy: src=files/index.html dest=/usr/share/nginx/html/index.html mode=0644 + template: src=templates/index.html.j2 dest=/usr/share/nginx/html/index.html mode=0644 - name: restart nginx service: name=nginx state=restarted diff --git a/ch02/playbooks/web-tls.yml b/ch02/playbooks/web-tls.yml index c69a5c8..fdb7cba 100644 --- a/ch02/playbooks/web-tls.yml +++ b/ch02/playbooks/web-tls.yml @@ -25,7 +25,7 @@ file: dest=/etc/nginx/sites-enabled/default src={{ conf_file }} state=link notify: restart nginx - name: copy index.html - copy: src=files/index.html dest=/usr/share/nginx/html/index.html mode=0644 + template: src=templates/index.html.j2 dest=/usr/share/nginx/html/index.html mode=0644 handlers: - name: restart nginx service: name=nginx state=restarted