Workshop Exercise - Wrap up

Read this in other languages:
uk English, japan日本語, brazil Portugues do Brasil, france Française, Español Español.

Table of Contents


This is the final challenge where we try to put most of what you have learned together.


Let’s set the stage

Your operations team and your application development team likes what they see in Ansible Tower. To really use it in their environment they put together these requirements:

The Git Repository

All code is already in place - this is a Tower lab after all. Check out the Workshop Project git repository at There you will find the playbook webcontent.yml, which calls the role role_webcontent.

Compared to the previous Apache installation role there is a major difference: there are now two versions of an index.html template, and a task deploying the template file which has a variable as part of the source file name:


<h1>This is a development webserver, have fun!</h1>
{{ dev_content }}


<h1>This is a production webserver, take care!</h1>
{{ prod_content }}


- name: Deploy index.html from template
    src: "{{ stage }}_index.html.j2"
    dest: /var/www/html/index.html
  notify: apache-restart

Prepare Inventory

There is of course more then one way to accomplish this, but here is what you should do:


Make sure to keep the three dashes that mark the YAML start and the ansible_host line in place!

Create the Template

Check the results

This time we use the power of Ansible to check the results: execute curl to get the web content from each node, orchestrated by an ad-hoc command on the command line of your Tower control host:


We are using the ansible_host variable in the URL to access every node in the inventory group.

[student<X>@ansible-1 ~]$ ansible web -m command -a "curl -s http://{{ ansible_host }}"
 [WARNING]: Consider using the get_url or uri module rather than running 'curl'.  If you need to use command because get_url or uri is insufficient you can add 'warn: false' to this command task or set 'command_warnings=False' in ansible.cfg to get rid of this message.

node2 | CHANGED | rc=0 >>
<h1>This is a production webserver, take care!</h1>
prod wweb

node1 | CHANGED | rc=0 >>
<h1>This is a development webserver, have fun!</h1>
dev wweb

node3 | CHANGED | rc=0 >>
<h1>This is a development webserver, have fun!</h1>
dev wweb

Note the warning in the first line about not to use curl via the command module since there are better modules right within Ansible. We will come back to that in the next part.

Add Survey

Check the results again from your Tower control host. Since we got a warning last time using curl via the command module, this time we will use the dedicated uri module. As arguments it needs the actual URL and a flag to output the body in the results.

[student<X>@ansible-1 ~]$ ansible web -m uri -a "url=http://{{ ansible_host }}/ return_content=yes"
node3 | SUCCESS => {
    "accept_ranges": "bytes",
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    "changed": false,
    "connection": "close",
    "content": "<body>\n<h1>This is a development webserver, have fun!</h1>\nwerners dev content\n</body>\n",
    "content_length": "87",
    "content_type": "text/html; charset=UTF-8",
    "cookies": {},
    "cookies_string": "",
    "date": "Tue, 29 Oct 2019 11:14:24 GMT",
    "elapsed": 0,
    "etag": "\"57-5960ab74fc401\"",
    "last_modified": "Tue, 29 Oct 2019 11:14:12 GMT",
    "msg": "OK (87 bytes)",
    "redirected": false,
    "server": "Apache/2.4.6 (Red Hat Enterprise Linux)",
    "status": 200,
    "url": ""



Solution Not Below

You have done all the required configuration steps in the lab already. If unsure, just refer back to the respective chapters.

The End

Congratulations, you finished your labs! We hope you enjoyed your first encounter with Ansible Tower as much as we enjoyed creating the labs.

Previous Exercise

Click here to return to the Ansible for Red Hat Enterprise Linux Workshop