From c61fdc64edb412999d6cfe13dcedf5e717584002 Mon Sep 17 00:00:00 2001 From: Lorin Hochstein Date: Sun, 15 Feb 2015 17:07:08 -0500 Subject: [PATCH] Use a template for rendering index.html --- ch02/playbooks/templates/index.html.j2 | 12 ++++++++++++ ch02/playbooks/web-notls.yml | 2 +- ch02/playbooks/web-tls.yml | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 ch02/playbooks/templates/index.html.j2 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 -- 2.44.0