From c7dca761e66519db1ef57e54e2e8c7c7913ee4c6 Mon Sep 17 00:00:00 2001 From: bennojoy Date: Tue, 12 Mar 2013 22:03:13 +0530 Subject: [PATCH] latest --- lamp_haproxy/roles/add_webservers.yml | 10 ----- lamp_haproxy/roles/db.yml | 11 ------ lamp_haproxy/roles/dbtier/handlers/main.yml | 6 --- .../roles/dbtier/tasks/install_mysql.yml | 32 --------------- lamp_haproxy/roles/dbtier/templates/my.cnf.j2 | 11 ------ lamp_haproxy/roles/haproxy.yml | 10 ----- .../roles/haproxy/tasks/install_haproxy.yml | 19 --------- lamp_haproxy/roles/remove_webservers.yml | 9 ----- lamp_haproxy/roles/rolling_update.yml | 8 ---- lamp_haproxy/roles/web.yml | 11 ------ lamp_haproxy/roles/webtier/handlers/main.yml | 5 --- .../roles/webtier/tasks/add_to_lb.yml | 15 ------- .../roles/webtier/tasks/copy_code.yml | 10 ----- .../roles/webtier/tasks/install_httpd.yml | 26 ------------- .../roles/webtier/tasks/remove_from_lb.yml | 23 ----------- .../roles/webtier/tasks/rolling_update.yml | 22 ----------- lamp_haproxy/roles/webtier/tasks/utils.yml | 39 ------------------- .../roles/webtier/templates/index.php.j2 | 16 -------- lamp_simple/README.md | 13 +------ lamp_simple/hosts | 6 ++- lamp_simple/roles/common/tasks/main.yml | 2 +- lamp_simple/roles/db.yml | 11 ------ lamp_simple/roles/dbtier/handlers/main.yml | 6 --- .../roles/dbtier/tasks/install_mysql.yml | 32 --------------- lamp_simple/roles/dbtier/templates/my.cnf.j2 | 11 ------ lamp_simple/roles/web.yml | 11 ------ lamp_simple/roles/webtier/handlers/main.yml | 5 --- lamp_simple/roles/webtier/tasks/copy_code.yml | 10 ----- .../roles/webtier/tasks/install_httpd.yml | 26 ------------- .../roles/webtier/templates/index.php.j2 | 24 ------------ lamp_simple/site.yml | 4 +- 31 files changed, 8 insertions(+), 436 deletions(-) delete mode 100644 lamp_haproxy/roles/add_webservers.yml delete mode 100644 lamp_haproxy/roles/db.yml delete mode 100644 lamp_haproxy/roles/dbtier/handlers/main.yml delete mode 100644 lamp_haproxy/roles/dbtier/tasks/install_mysql.yml delete mode 100644 lamp_haproxy/roles/dbtier/templates/my.cnf.j2 delete mode 100644 lamp_haproxy/roles/haproxy.yml delete mode 100644 lamp_haproxy/roles/haproxy/tasks/install_haproxy.yml delete mode 100644 lamp_haproxy/roles/remove_webservers.yml delete mode 100644 lamp_haproxy/roles/rolling_update.yml delete mode 100644 lamp_haproxy/roles/web.yml delete mode 100644 lamp_haproxy/roles/webtier/handlers/main.yml delete mode 100644 lamp_haproxy/roles/webtier/tasks/add_to_lb.yml delete mode 100644 lamp_haproxy/roles/webtier/tasks/copy_code.yml delete mode 100644 lamp_haproxy/roles/webtier/tasks/install_httpd.yml delete mode 100644 lamp_haproxy/roles/webtier/tasks/remove_from_lb.yml delete mode 100644 lamp_haproxy/roles/webtier/tasks/rolling_update.yml delete mode 100644 lamp_haproxy/roles/webtier/tasks/utils.yml delete mode 100644 lamp_haproxy/roles/webtier/templates/index.php.j2 delete mode 100644 lamp_simple/roles/db.yml delete mode 100644 lamp_simple/roles/dbtier/handlers/main.yml delete mode 100644 lamp_simple/roles/dbtier/tasks/install_mysql.yml delete mode 100644 lamp_simple/roles/dbtier/templates/my.cnf.j2 delete mode 100644 lamp_simple/roles/web.yml delete mode 100644 lamp_simple/roles/webtier/handlers/main.yml delete mode 100644 lamp_simple/roles/webtier/tasks/copy_code.yml delete mode 100644 lamp_simple/roles/webtier/tasks/install_httpd.yml delete mode 100644 lamp_simple/roles/webtier/templates/index.php.j2 diff --git a/lamp_haproxy/roles/add_webservers.yml b/lamp_haproxy/roles/add_webservers.yml deleted file mode 100644 index 536f0eb..0000000 --- a/lamp_haproxy/roles/add_webservers.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -# This Playbook adds a webserver into the the web cluster - -- hosts: webservers - user: root - serial: 1 - tasks: - - include: ../roles/webtier/tasks/install_httpd.yml - - include: ../roles/webtier/tasks/copy_code.yml - - include: ../roles/webtier/tasks/add_to_lb.yml diff --git a/lamp_haproxy/roles/db.yml b/lamp_haproxy/roles/db.yml deleted file mode 100644 index 904e7ed..0000000 --- a/lamp_haproxy/roles/db.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -# This playbook deploys mysql and configures database on the db node/nodes - -- hosts: dbservers - user: root - tasks: - - include: common/tasks/main.yml - - include: dbtier/tasks/install_mysql.yml - handlers: - - include: dbtier/handlers/main.yml - - include: common/handlers/main.yml diff --git a/lamp_haproxy/roles/dbtier/handlers/main.yml b/lamp_haproxy/roles/dbtier/handlers/main.yml deleted file mode 100644 index 0014f14..0000000 --- a/lamp_haproxy/roles/dbtier/handlers/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# Handler to handle DB tier notifications - -- name: restart mysql - service: name=mysqld state=restarted - diff --git a/lamp_haproxy/roles/dbtier/tasks/install_mysql.yml b/lamp_haproxy/roles/dbtier/tasks/install_mysql.yml deleted file mode 100644 index 2332e91..0000000 --- a/lamp_haproxy/roles/dbtier/tasks/install_mysql.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -# This playbook will install mysql and create db user and give permissions. - -- name: Install Mysql package - action: yum pkg=$item state=installed - with_items: - - mysql-server - - MySQL-python - - libselinux-python - - libsemanage-python - -- name: Configure SELinux to start mysql on any port - seboolean: name=mysql_connect_any state=true persistent=yes - -- name: Create Mysql configuration file - action: template src=dbtier/templates/my.cnf.j2 dest=/etc/my.cnf - notify: - - restart mysql - -- name: Start Mysql Service - service: name=mysqld state=started enabled=true - -- name: insert iptables rule - lineinfile: dest=/etc/sysconfig/iptables state=present regexp="$mysql_port" insertafter="^:OUTPUT " line="-A INPUT -p tcp --dport $mysql_port -j ACCEPT" - notify: restart iptables - - -- name: Create Application Database - mysql_db: name=$dbname state=present - -- name: Create Application DB User - mysql_user: name=$dbuser password=$upassword priv=*.*:ALL host='%' state=present diff --git a/lamp_haproxy/roles/dbtier/templates/my.cnf.j2 b/lamp_haproxy/roles/dbtier/templates/my.cnf.j2 deleted file mode 100644 index 3944d06..0000000 --- a/lamp_haproxy/roles/dbtier/templates/my.cnf.j2 +++ /dev/null @@ -1,11 +0,0 @@ -[mysqld] -datadir=/var/lib/mysql -socket=/var/lib/mysql/mysql.sock -user=mysql -# Disabling symbolic-links is recommended to prevent assorted security risks -symbolic-links=0 -port={{ mysql_port }} - -[mysqld_safe] -log-error=/var/log/mysqld.log -pid-file=/var/run/mysqld/mysqld.pid diff --git a/lamp_haproxy/roles/haproxy.yml b/lamp_haproxy/roles/haproxy.yml deleted file mode 100644 index 2f986d5..0000000 --- a/lamp_haproxy/roles/haproxy.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -#PlayBook for haproxy operations - -- hosts: lbservers - user: root - tasks: - - include: haproxy/tasks/install_haproxy.yml - handlers: - - include: haproxy/handlers/main.yml - - include: common/handlers/main.yml diff --git a/lamp_haproxy/roles/haproxy/tasks/install_haproxy.yml b/lamp_haproxy/roles/haproxy/tasks/install_haproxy.yml deleted file mode 100644 index 352fa92..0000000 --- a/lamp_haproxy/roles/haproxy/tasks/install_haproxy.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -# This PlayBook Installs the HAProxy and configures it. - -- name: Download and install haproxy - command: creates=/opt/haproxy.rpm curl -o /opt/haproxy.rpm ftp://ftp.univie.ac.at/systems/linux/fedora/epel/6/i386/haproxy-1.4.18-1.el6.i686.rpm - -- name: Install the haproxy rpm. - command: creates=/etc/haproxy/haproxy.cfg yum -y localinstall /opt/haproxy.rpm - -- name: Install the socat package for dynamic addition/removal of hosts - yum: name=socat state=installed - -- name: Open firewall port for haproxy. - lineinfile: dest=/etc/sysconfig/iptables state=present regexp="$listenport" insertafter="^:OUTPUT " line="-A INPUT -p tcp --dport $listenport -j ACCEPT" - notify: restart iptables - -- name: Configure the haproxy cnf file with hosts - template: src=haproxy/templates/haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg - notify: restart haproxy diff --git a/lamp_haproxy/roles/remove_webservers.yml b/lamp_haproxy/roles/remove_webservers.yml deleted file mode 100644 index db097b5..0000000 --- a/lamp_haproxy/roles/remove_webservers.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -# This Playbook removes a webserver from the pool serialy. - - -- hosts: webservers - user: root - serial: 1 - tasks: - - include: ../roles/webtier/tasks/remove_from_lb.yml diff --git a/lamp_haproxy/roles/rolling_update.yml b/lamp_haproxy/roles/rolling_update.yml deleted file mode 100644 index 89d50d3..0000000 --- a/lamp_haproxy/roles/rolling_update.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -# This Playbook does a rolling update of the code for all webservers serially (one at a time). Change the value of serial: to adjust the number of server to be updated. - -- hosts: webservers - user: root - serial: 1 - tasks: - - include: ../roles/webtier/tasks/rolling_update.yml diff --git a/lamp_haproxy/roles/web.yml b/lamp_haproxy/roles/web.yml deleted file mode 100644 index 3798685..0000000 --- a/lamp_haproxy/roles/web.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -# This Playbook deploys the WebServers with httpd and the code. - -- hosts: webservers - user: root - tasks: - - include: common/tasks/main.yml - - include: webtier/tasks/install_httpd.yml - - include: webtier/tasks/copy_code.yml - handlers: - - include: webtier/handlers/main.yml diff --git a/lamp_haproxy/roles/webtier/handlers/main.yml b/lamp_haproxy/roles/webtier/handlers/main.yml deleted file mode 100644 index f613a8f..0000000 --- a/lamp_haproxy/roles/webtier/handlers/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -# Handler for the webtier - -- name: restart iptables - service: name=iptables state=restarted diff --git a/lamp_haproxy/roles/webtier/tasks/add_to_lb.yml b/lamp_haproxy/roles/webtier/tasks/add_to_lb.yml deleted file mode 100644 index a3b7e3d..0000000 --- a/lamp_haproxy/roles/webtier/tasks/add_to_lb.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -# This Playbook does utility stuff's like adding a webserver into the pool, etc.. - -- name: Add server to LB - lineinfile: dest=/etc/haproxy/haproxy.cfg state=present regexp="${ansible_hostname}" line="server ${ansible_hostname} ${ansible_eth0.ipv4.address}:${httpd_port}" - delegate_to: $item - with_items: ${groups.lbservers} - register: last_run - -- name: Reload the haproxy - service: name=haproxy state=reloaded - delegate_to: $item - with_items: ${groups.lbservers} - only_if: ${last_run.changed} - diff --git a/lamp_haproxy/roles/webtier/tasks/copy_code.yml b/lamp_haproxy/roles/webtier/tasks/copy_code.yml deleted file mode 100644 index 8975fdc..0000000 --- a/lamp_haproxy/roles/webtier/tasks/copy_code.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -# This Playbook is 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: Create's the index.php file - template: src=webtier/templates/index.php.j2 dest=/var/www/html/index.php - diff --git a/lamp_haproxy/roles/webtier/tasks/install_httpd.yml b/lamp_haproxy/roles/webtier/tasks/install_httpd.yml deleted file mode 100644 index 19ea206..0000000 --- a/lamp_haproxy/roles/webtier/tasks/install_httpd.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# This playbook installs http and the php modules. - -- name: Install http and php etc - action: yum name=$item state=installed - with_items: - - httpd - - php - - php-mysql - - libsemanage-python - - libselinux-python - - -- name: insert iptables rule for httpd - lineinfile: dest=/etc/sysconfig/iptables state=present regexp="$httpd_port" insertafter="^:OUTPUT " line="-A INPUT -p tcp --dport $httpd_port -j ACCEPT" - register: last_run - -- name: Apply iptable rule - service: name=iptables state=restarted - only_if: ${last_run.changed} - -- name: http service state - service: name=httpd state=started enabled=yes - -- name: Configure SELinux to allow httpd to connect to remote database - seboolean: name=httpd_can_network_connect_db state=true persistent=yes diff --git a/lamp_haproxy/roles/webtier/tasks/remove_from_lb.yml b/lamp_haproxy/roles/webtier/tasks/remove_from_lb.yml deleted file mode 100644 index 985d0d4..0000000 --- a/lamp_haproxy/roles/webtier/tasks/remove_from_lb.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -# This Playbook does utility stuff's like adding a webserver into the pool, etc.. - -- name: Remove the code from server - command: rm -rf /var/www/html/* - -- name: Remove server from LB - lineinfile: dest=/etc/haproxy/haproxy.cfg state=absent regexp="${ansible_hostname}" - delegate_to: $item - with_items: ${groups.lbservers} - register: last_run - -- name: disable the server in haproxy - shell: echo "disable server myapplb/${ansible_hostname}" | socat stdio /var/lib/haproxy/stats - delegate_to: $item - with_items: ${groups.lbservers} - -- name: Remove the httpd package - yum: name=httpd state=absent - - - - diff --git a/lamp_haproxy/roles/webtier/tasks/rolling_update.yml b/lamp_haproxy/roles/webtier/tasks/rolling_update.yml deleted file mode 100644 index 981f047..0000000 --- a/lamp_haproxy/roles/webtier/tasks/rolling_update.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -# This Playbook implements a rolling update on the infrastructure, change the value of the serial keyword to specify the number of servers the update should happen. - -- name: Remove the code from server - command: rm -rf /var/www/html/* - -- name: disable the server in haproxy - shell: echo "disable server myapplb/${ansible_hostname}" | socat stdio /var/lib/haproxy/stats - delegate_to: $item - with_items: ${groups.lbservers} - -- name: Copy the code from repository - git: repo=${repository} dest=/var/www/html/ - -- name: Create's the index.php file - template: src=webtier/templates/index.php.j2 dest=/var/www/html/index.php - -- name: Enable the server in haproxy - shell: echo "enable server myapplb/${ansible_hostname}" | socat stdio /var/lib/haproxy/stats - delegate_to: $item - with_items: ${groups.lbservers} - diff --git a/lamp_haproxy/roles/webtier/tasks/utils.yml b/lamp_haproxy/roles/webtier/tasks/utils.yml deleted file mode 100644 index 5ba4e7a..0000000 --- a/lamp_haproxy/roles/webtier/tasks/utils.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- -# This Playbook does utility stuff's like adding a webserver into the pool, etc.. - -- name: Add server to LB - lineinfile: dest=/etc/haproxy/haproxy.cfg state=present regexp="${ansible_hostname}" line="server ${ansible_hostname} ${ansible_eth0.ipv4.address}:${httpd_port}" - delegate_to: ${lbserver} - register: last_run - tags: add - -- name: Reload the haproxy - service: name=haproxy state=reloaded - delegate_to: ${lbserver} - only_if: ${last_run.changed} - tags: add - -- name: Remove the code from server - command: rm -rf /var/www/html/* - tags: remove - -- name: Remove server from LB - lineinfile: dest=/etc/haproxy/haproxy.cfg state=absent regexp="${ansible_hostname}" - delegate_to: $item - with_items: ${groups.lbservers}} - register: last_run - tags: remove - -- name: disable the server in haproxy - shell: echo "disable server myapplb/${ansible_hostname}" | socat stdio /var/lib/haproxy/stats - delegate_to: $item - with_items: ${groups.lbservers}} - tags: remove - -- name: Remove the httpd package - yum: name=httpd state=absent - tags: remove - - - - diff --git a/lamp_haproxy/roles/webtier/templates/index.php.j2 b/lamp_haproxy/roles/webtier/templates/index.php.j2 deleted file mode 100644 index a8c4dca..0000000 --- a/lamp_haproxy/roles/webtier/templates/index.php.j2 +++ /dev/null @@ -1,16 +0,0 @@ - - - Ansible Application - - -
- Homepage -
-"; -?> - - - diff --git a/lamp_simple/README.md b/lamp_simple/README.md index 52f90ce..877f161 100644 --- a/lamp_simple/README.md +++ b/lamp_simple/README.md @@ -42,17 +42,6 @@ Now we setup our Lamp Stack, The stack can be on a single node or multiple nodes Here the webserver would be configured on the localhost and the dbserver on bensible. The stack can be deployed using the following command. - ansible-playbook -i hosts site.yml + ansible-playbook -i hosts site.yml Once Done, you can check by browsing to http:///index.php - -If you want to add a new webserver to the stack it would be as simple as changing the hosts file to add the new webserver name and rerun the above command. - - [webservers] - localhost - webserver1 - - [dbservers] - bensible - - ansible-playbook -i hosts site.yml diff --git a/lamp_simple/hosts b/lamp_simple/hosts index 3b63018..add61ed 100644 --- a/lamp_simple/hosts +++ b/lamp_simple/hosts @@ -1,5 +1,7 @@ [webservers] -web2 +web3 [dbservers] -web3 +web2 + + diff --git a/lamp_simple/roles/common/tasks/main.yml b/lamp_simple/roles/common/tasks/main.yml index a0d7875..3e1cfec 100644 --- a/lamp_simple/roles/common/tasks/main.yml +++ b/lamp_simple/roles/common/tasks/main.yml @@ -6,7 +6,7 @@ tags: ntp - name: Configure ntp file - template: src=common/templates/ntp.conf.j2 dest=/etc/ntp.conf + template: src=../roles/common/templates/ntp.conf.j2 dest=/etc/ntp.conf tags: ntp notify: restart ntp diff --git a/lamp_simple/roles/db.yml b/lamp_simple/roles/db.yml deleted file mode 100644 index 904e7ed..0000000 --- a/lamp_simple/roles/db.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -# This playbook deploys mysql and configures database on the db node/nodes - -- hosts: dbservers - user: root - tasks: - - include: common/tasks/main.yml - - include: dbtier/tasks/install_mysql.yml - handlers: - - include: dbtier/handlers/main.yml - - include: common/handlers/main.yml diff --git a/lamp_simple/roles/dbtier/handlers/main.yml b/lamp_simple/roles/dbtier/handlers/main.yml deleted file mode 100644 index 0014f14..0000000 --- a/lamp_simple/roles/dbtier/handlers/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# Handler to handle DB tier notifications - -- name: restart mysql - service: name=mysqld state=restarted - diff --git a/lamp_simple/roles/dbtier/tasks/install_mysql.yml b/lamp_simple/roles/dbtier/tasks/install_mysql.yml deleted file mode 100644 index 2332e91..0000000 --- a/lamp_simple/roles/dbtier/tasks/install_mysql.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -# This playbook will install mysql and create db user and give permissions. - -- name: Install Mysql package - action: yum pkg=$item state=installed - with_items: - - mysql-server - - MySQL-python - - libselinux-python - - libsemanage-python - -- name: Configure SELinux to start mysql on any port - seboolean: name=mysql_connect_any state=true persistent=yes - -- name: Create Mysql configuration file - action: template src=dbtier/templates/my.cnf.j2 dest=/etc/my.cnf - notify: - - restart mysql - -- name: Start Mysql Service - service: name=mysqld state=started enabled=true - -- name: insert iptables rule - lineinfile: dest=/etc/sysconfig/iptables state=present regexp="$mysql_port" insertafter="^:OUTPUT " line="-A INPUT -p tcp --dport $mysql_port -j ACCEPT" - notify: restart iptables - - -- name: Create Application Database - mysql_db: name=$dbname state=present - -- name: Create Application DB User - mysql_user: name=$dbuser password=$upassword priv=*.*:ALL host='%' state=present diff --git a/lamp_simple/roles/dbtier/templates/my.cnf.j2 b/lamp_simple/roles/dbtier/templates/my.cnf.j2 deleted file mode 100644 index 3944d06..0000000 --- a/lamp_simple/roles/dbtier/templates/my.cnf.j2 +++ /dev/null @@ -1,11 +0,0 @@ -[mysqld] -datadir=/var/lib/mysql -socket=/var/lib/mysql/mysql.sock -user=mysql -# Disabling symbolic-links is recommended to prevent assorted security risks -symbolic-links=0 -port={{ mysql_port }} - -[mysqld_safe] -log-error=/var/log/mysqld.log -pid-file=/var/run/mysqld/mysqld.pid diff --git a/lamp_simple/roles/web.yml b/lamp_simple/roles/web.yml deleted file mode 100644 index 3798685..0000000 --- a/lamp_simple/roles/web.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -# This Playbook deploys the WebServers with httpd and the code. - -- hosts: webservers - user: root - tasks: - - include: common/tasks/main.yml - - include: webtier/tasks/install_httpd.yml - - include: webtier/tasks/copy_code.yml - handlers: - - include: webtier/handlers/main.yml diff --git a/lamp_simple/roles/webtier/handlers/main.yml b/lamp_simple/roles/webtier/handlers/main.yml deleted file mode 100644 index f613a8f..0000000 --- a/lamp_simple/roles/webtier/handlers/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -# Handler for the webtier - -- name: restart iptables - service: name=iptables state=restarted diff --git a/lamp_simple/roles/webtier/tasks/copy_code.yml b/lamp_simple/roles/webtier/tasks/copy_code.yml deleted file mode 100644 index 8975fdc..0000000 --- a/lamp_simple/roles/webtier/tasks/copy_code.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -# This Playbook is 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: Create's the index.php file - template: src=webtier/templates/index.php.j2 dest=/var/www/html/index.php - diff --git a/lamp_simple/roles/webtier/tasks/install_httpd.yml b/lamp_simple/roles/webtier/tasks/install_httpd.yml deleted file mode 100644 index 19ea206..0000000 --- a/lamp_simple/roles/webtier/tasks/install_httpd.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# This playbook installs http and the php modules. - -- name: Install http and php etc - action: yum name=$item state=installed - with_items: - - httpd - - php - - php-mysql - - libsemanage-python - - libselinux-python - - -- name: insert iptables rule for httpd - lineinfile: dest=/etc/sysconfig/iptables state=present regexp="$httpd_port" insertafter="^:OUTPUT " line="-A INPUT -p tcp --dport $httpd_port -j ACCEPT" - register: last_run - -- name: Apply iptable rule - service: name=iptables state=restarted - only_if: ${last_run.changed} - -- name: http service state - service: name=httpd state=started enabled=yes - -- name: Configure SELinux to allow httpd to connect to remote database - seboolean: name=httpd_can_network_connect_db state=true persistent=yes diff --git a/lamp_simple/roles/webtier/templates/index.php.j2 b/lamp_simple/roles/webtier/templates/index.php.j2 deleted file mode 100644 index 76c3420..0000000 --- a/lamp_simple/roles/webtier/templates/index.php.j2 +++ /dev/null @@ -1,24 +0,0 @@ - - - Ansible Application - - -
- Homepage -
-"; -echo "List of Databases:
"; - {% for host in groups['dbservers'] %} - $link = mysql_connect('{{ hostvars[host].ansible_eth0.ipv4.address }}', '{{ hostvars[host].dbuser }}', '{{ hostvars[host].upassword }}') or die(mysql_error()); - {% endfor %} - $res = mysql_query("SHOW DATABASES"); - while ($row = mysql_fetch_assoc($res)) { - echo $row['Database'] . "\n"; - } -?> - - - diff --git a/lamp_simple/site.yml b/lamp_simple/site.yml index af6af93..57ac736 100644 --- a/lamp_simple/site.yml +++ b/lamp_simple/site.yml @@ -1,5 +1,5 @@ --- #This Playbook deploys the whole application stack in this site. -- include: roles/db.yml -- include: roles/web.yml +- include: playbooks/db.yml +- include: playbooks/web.yml