Copying an HTML file

The final task is to copy an index.html file to our web root, so we have something to serve with our newly installed Apache server. The task to do this uses the template module:

- name: copy the test HTML page to the document root  template:    src: "index.html.j2"    dest: "{{ document_root }}/index.html"    mode: "0644"    owner: "{{ users.0.name }}"    group: "{{ apache_group }}"  when: html_deploy == true

As you can see, we are loading a template called index.html.j2, which contains the following content:

<!--{{ ansible_managed }}--><!doctype html><title>{{ html_heading }}</title><style>  body { text-align: center; padding: 150px; }  h1 { font-size: 50px; }  body { font: 20px Helvetica, sans-serif; color: #333; } article { display: block; ...

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.