ansible-role-apache/lamp_simple/README.md

46 lines
1.9 KiB
Markdown
Raw Normal View History

2013-03-12 08:35:13 +01:00
Building a simple LAMP stack and deploying Application using Ansible Playbooks.
-------------------------------------------
2013-03-20 05:40:39 +01:00
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.
2013-03-12 08:35:13 +01:00
### Installing Ansible
2013-03-20 05:40:39 +01:00
Running this playbook requires setting up Ansible first. Luckily this is a very simple process on CentOS 6.x:
2013-03-12 08:35:13 +01:00
yum install http://epel.mirrors.arminco.com/6/x86_64/epel-release-6-8.noarch.rpm
yum install python PyYAML python-paramiko python-jinja2
git clone git://github.com/ansible/ansible.git
cd ansible
source hacking/env-setup
2013-03-20 05:40:39 +01:00
Generate/synchronize your SSH keys (optional you can pass -k parameter to prompt for password)
2013-03-12 08:35:13 +01:00
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
2013-03-20 05:40:39 +01:00
Create a sample inventory file. The inventory file contains a grouped list of hostnames that are managed by Ansible. The command below will just add "localhost" to the host list.
2013-03-12 08:35:13 +01:00
echo "localhost" > ansible_hosts
2013-03-20 05:40:39 +01:00
Test if we are setup properly:
2013-03-12 08:35:13 +01:00
ansible -i ansible_hosts localhost -m ping
localhost | success >> {
"changed": false,
"ping": "pong"
}
2013-03-20 05:40:39 +01:00
Now we set up our LAMP stack. The stack can be on a single node or multiple nodes. The inventory file 'hosts' defines the nodes in which the stacks should be configured.
2013-03-12 08:35:13 +01:00
[webservers]
localhost
[dbservers]
bensible
2013-03-20 05:40:39 +01:00
Here the webserver would be configured on the local host and the dbserver on a server called "bensible". The stack can be deployed using the following command:
2013-03-12 08:35:13 +01:00
2013-03-12 17:33:13 +01:00
ansible-playbook -i hosts site.yml
2013-03-12 08:35:13 +01:00
2013-03-20 05:40:39 +01:00
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.