From 8a5430336b37309987a1003c42c263fa7bf51663 Mon Sep 17 00:00:00 2001 From: Ivan Grynenko Date: Thu, 9 Jun 2016 20:49:36 +1000 Subject: [PATCH] Moved PHP-FPM into it's own role --- lamp_centos7/hosts | 2 -- lamp_centos7/roles/php-fpm/handlers/main.yml | 3 ++ lamp_centos7/roles/php-fpm/tasks/main.yml | 35 +++++++++++++++++++ .../roles/php-fpm/templates/wordpress.conf | 15 ++++++++ .../roles/web/tasks/install_httpd.yml | 22 ++---------- lamp_centos7/site.yml | 9 ++++- 6 files changed, 63 insertions(+), 23 deletions(-) create mode 100644 lamp_centos7/roles/php-fpm/handlers/main.yml create mode 100644 lamp_centos7/roles/php-fpm/tasks/main.yml create mode 100644 lamp_centos7/roles/php-fpm/templates/wordpress.conf diff --git a/lamp_centos7/hosts b/lamp_centos7/hosts index 3cb4f9e..e51ef48 100644 --- a/lamp_centos7/hosts +++ b/lamp_centos7/hosts @@ -3,5 +3,3 @@ [dbservers] 122.129.219.67:221 - - diff --git a/lamp_centos7/roles/php-fpm/handlers/main.yml b/lamp_centos7/roles/php-fpm/handlers/main.yml new file mode 100644 index 0000000..6a975ad --- /dev/null +++ b/lamp_centos7/roles/php-fpm/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: restart php-fpm + service: name=php-fpm state=restarted diff --git a/lamp_centos7/roles/php-fpm/tasks/main.yml b/lamp_centos7/roles/php-fpm/tasks/main.yml new file mode 100644 index 0000000..5a17cc6 --- /dev/null +++ b/lamp_centos7/roles/php-fpm/tasks/main.yml @@ -0,0 +1,35 @@ +--- +- name: Install php-fpm and deps + yum: name={{ item }} state=present + with_items: + - php + - php-fpm + - php-enchant + - php-IDNA_Convert + - php-mbstring + - php-mysql + - php-PHPMailer + - php-process + - php-simplepie + - php-xml + - php-gd + - php-mbstring + - php-opcache + - php-pdo-dblib + - php-pecl-apcu + - php-pecl-memcached + - php-pecl-uploadprogress + - php-pecl-uuid + - php-pspell + - php-soap + - php-twig + - php-twig-ctwig + - php-xmlrpc + +- name: Disable default pool + command: mv /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.disabled creates=/etc/php-fpm.d/www.disabled + notify: restart php-fpm + +- name: Copy php-fpm configuration + template: src=wordpress.conf dest=/etc/php-fpm.d/ + notify: restart php-fpm diff --git a/lamp_centos7/roles/php-fpm/templates/wordpress.conf b/lamp_centos7/roles/php-fpm/templates/wordpress.conf new file mode 100644 index 0000000..10434c5 --- /dev/null +++ b/lamp_centos7/roles/php-fpm/templates/wordpress.conf @@ -0,0 +1,15 @@ +[wordpress] +listen = /var/run/php-fpm/wordpress.sock +listen.owner = nginx +listen.group = nginx +listen.mode = 0660 +user = wordpress +group = wordpress +pm = dynamic +pm.max_children = 10 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +pm.max_requests = 500 +chdir = /srv/wordpress/ +php_admin_value[open_basedir] = /srv/wordpress/:/tmp diff --git a/lamp_centos7/roles/web/tasks/install_httpd.yml b/lamp_centos7/roles/web/tasks/install_httpd.yml index 40a540f..ae3e313 100644 --- a/lamp_centos7/roles/web/tasks/install_httpd.yml +++ b/lamp_centos7/roles/web/tasks/install_httpd.yml @@ -1,28 +1,10 @@ --- # These tasks install http and the php modules. -- name: Install http and php etc - yum: name={{ item }} state=present +- name: Install http and libraries + yum: name={{ item }} state=latest with_items: - httpd - - php - - php-mysql - - php-fpm - - php-gd - - php-mbstring - - php-mcrypt - - php-opcache - - php-pdo-dblib - - php-pecl-apcu - - php-pecl-memcached - - php-pecl-uploadprogress - - php-pecl-uuid - - php-pspell - - php-soap - - php-twig - - php-twig-ctwig - - php-xml - - php-xmlrpc - git - libsemanage-python - libselinux-python diff --git a/lamp_centos7/site.yml b/lamp_centos7/site.yml index f395725..38373f2 100644 --- a/lamp_centos7/site.yml +++ b/lamp_centos7/site.yml @@ -1,5 +1,5 @@ --- -# This playbook deploys the whole application stack in this site. +# This playbook deploys the whole application stack in this site. - name: apply common configuration to all nodes hosts: all @@ -15,6 +15,13 @@ roles: - web +- name: deploy PHP-FPM + hosts: webservers + remote_user: root + + roles: + - php-fpm + - name: deploy MySQL and configure the databases hosts: dbservers remote_user: root