commit
08ad4c77fb
@ -1,23 +0,0 @@ |
||||
Building a simple Apache Server and deploying index.html using Ansible Playbooks. |
||||
------------------------------------------- |
||||
|
||||
These playbooks require Ansible 1.2. |
||||
|
||||
These playbooks are meant to be a reference and starter's guide to building |
||||
Ansible Playbooks. These playbooks were tested on CentOS 6.x so we recommend |
||||
that you use CentOS or RHEL to test these modules. |
||||
|
||||
The Apache server can be on a single node or multiple nodes. The inventory file |
||||
'hosts' defines the nodes in which the stacks should be configured. |
||||
|
||||
[webservers] |
||||
localhost |
||||
|
||||
Here the webserver would be configured on the local host. This can be deployed |
||||
using the following command: |
||||
|
||||
ansible-playbook -i hosts site.yml |
||||
|
||||
Once done, you can check the results by browsing to http://localhost/index.php. |
||||
You should see a simple test page and a list of databases retrieved from the |
||||
database server. |
@ -1,3 +0,0 @@ |
||||
--- |
||||
# Variables listed here are applicable to all host groups |
||||
|
@ -1,3 +0,0 @@ |
||||
--- |
||||
# The variables file used by the playbooks in the webservers group. |
||||
# These don't have to be explicitly imported by vars_files: they are autopopulated. |
@ -1,2 +0,0 @@ |
||||
[webservers] |
||||
web1 |
@ -1,9 +0,0 @@ |
||||
--- |
||||
# These tasks are responsible for copying the latest dev/production code from |
||||
# the version control system. |
||||
|
||||
- name: Copy the code from repository |
||||
git: repo={{ repository }} dest=/var/www/html/ |
||||
|
||||
- name: Creates the index.html file |
||||
template: src=index.html.j2 dest=/var/www/html/index.html |
@ -1,13 +0,0 @@ |
||||
--- |
||||
# These tasks install apache. |
||||
|
||||
- name: install packages |
||||
yum: name=httpd state=present |
||||
when: ansible_os_family == "RedHat" |
||||
|
||||
- name: install packages |
||||
apt: name=apache2 state=present |
||||
when: ansible_os_family == "Debian" |
||||
|
||||
- name: http service state |
||||
service: name=httpd state=started enabled=yes |
@ -1,3 +0,0 @@ |
||||
--- |
||||
- include: install_apache.yml |
||||
- include: copy_code.yml |
@ -1,10 +0,0 @@ |
||||
<html> |
||||
<head> |
||||
<title>Ansible Application</title> |
||||
</head> |
||||
<body> |
||||
</br> |
||||
<a href=http://{{ ansible_eth0.ipv4.address }}/index.html>Homepage</a> |
||||
</br> |
||||
</body> |
||||
</html> |
@ -1,3 +0,0 @@ |
||||
--- |
||||
# Handler to handle common notifications. Handlers are called by other plays. |
||||
# See http://ansible.cc/docs/playbooks.html for more information about handlers. |
@ -1,2 +0,0 @@ |
||||
--- |
||||
# This playbook contains common plays that will be run on all nodes. |
@ -1,16 +0,0 @@ |
||||
--- |
||||
# This playbook deploys, update and config apache. |
||||
|
||||
- name: common config |
||||
hosts: all |
||||
user: root |
||||
|
||||
roles: |
||||
- common |
||||
|
||||
- name: apache |
||||
hosts: webservers |
||||
user: root |
||||
|
||||
roles: |
||||
- apache |
Reference in new issue