ansible role exercise git-link: https://github.com/ansible/ansible-examples
Directory Layout
# tree /etc/ansible/
.
├── ansible.cfg
├── group_vars # here we assign variables to particular groups
│ └── tomcat-servers # this filename must the same with the group in the 'hosts'
├── hosts
├── roles
│ ├── selinux
│ └── tomcat
│ ├── files
│ │ └── tomcat-initscript.sh # <-- script files for use with the script resource
│ ├── handlers
│ │ └── main.yml # <-- handlers file
│ ├── tasks
│ │ └── main.yml # <-- tasks file can include smaller files if warranted
│ └── templates # <-- files for use with the template resource
│ ├── iptables-save
│ ├── server.xml
│ └── tomcat-users.xml
├── site.retry
└── site.yml # master playbook
# cat hosts
[tomcat-servers]
10.0.0.85
10.0.0.78
# cat site.yml
---
# This playbook deploys a simple standalone Tomcat 7 server.
- hosts: tomcat-servers
remote_user: root
roles:
- selinux
- tomcat
# cat group_vars/tomcat-servers
# Here are variables related to the Tomcat installation
http_port: 8080
https_port: 8443
# This will configure a default manager-gui user:
admin_username: admin
admin_password: admin