commit ddb3a9c8565ff1c46d336bad367563d99e555b28 Author: Thomas Constans Date: Mon Oct 18 18:03:37 2021 +0200 initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..38a2e52 --- /dev/null +++ b/README.md @@ -0,0 +1,58 @@ +Role Name +========= + + +Install php-fpm (for apache) + +and some php packages along the way + +Requirements +------------ + +None + +Role Variables +-------------- + +php_version: default 73 +php_fpm_pool_user: default apache +php_fpm_pool_group: default apache +php_fpm_listen_url: default 127.0.0.1:90{{ php_version }} +php_pm: static +php_pm_max_children: 1000 +php_pm_max_requests: 10000 +php_pm_status_url: /phpstatus +php_packages: [ 'php{{ php_version }}-php-common' ] + +Dependencies +------------ + +Better have apache + + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + vars: + httpd_server_name: foobar.fr + php_version: 73 + php_packages: + - php73-php-imap + - php73-php-pear + roles: + - apache + - php-fpm + +License +------- + +BSD + +Author Information +------------------ + +Thomas C + diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..0825527 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,11 @@ +--- +# defaults file for php-fpm +php_version: 73 +php_fpm_pool_user: apache +php_fpm_pool_group: apache +php_fpm_listen_url: 127.0.0.1:90{{ php_version }} +php_pm: static +php_pm_max_children: 1000 +php_pm_max_requests: 10000 +php_pm_status_url: /phpstatus +php_packages: [ 'php{{ php_version }}-php-common' ] diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..96b2ba1 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,6 @@ +--- +# handlers file for php-fpm +- name: restart php-fpm + service: + name: php-fpm + state: restarted \ No newline at end of file diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..227ad9c --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,53 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.9 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. + \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..6183d79 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,4 @@ +--- +# tasks file for php-fpm +- include_tasks: php-fpm.yml + tags: php \ No newline at end of file diff --git a/tasks/php-fpm.yml b/tasks/php-fpm.yml new file mode 100644 index 0000000..b05be3d --- /dev/null +++ b/tasks/php-fpm.yml @@ -0,0 +1,45 @@ +--- +# tasks file for php-fpm +- name: install repository definitions + yum: + name: + - epel-release + - http://rpms.remirepo.net/enterprise/remi-release-{{ ansible_distribution_major_version }}.rpm + - yum-utils + state: present + +- name: activate given repo + ini_file: + path: /etc/yum.repos.d/remi-php{{ php_version }}.repo + section: "remi-php{{ php_version }}" + option: enabled + value: 1 + +- name: install php-fpm + yum: + name: + - php{{php_version}}-php-fpm + state: installed + +- name: install php packages + yum: + name: "{{ php_packages }}" + state: present + +- name: configure php-fpm pool 2 + template: + src: www.conf + dest: /etc/opt/remi/php{{ php_version }}/php-fpm.d/www_{{ php_version }}.conf + notify: restart php-fpm + +- name: create log symlink + file: + src: /var/opt/remi/php{{ php_version }}/log/php-fpm + dest: /var/log/php-fpm + state: link + +- name: start and enable service + service: + name: php{{php_version}}-php-fpm + enabled: yes + state: started \ No newline at end of file diff --git a/templates/php-fpm.conf.tt b/templates/php-fpm.conf.tt new file mode 100644 index 0000000..85dfb6e --- /dev/null +++ b/templates/php-fpm.conf.tt @@ -0,0 +1,3 @@ + + SetHandler proxy:fcgi://{{ php_fpm_listen_url }} + diff --git a/templates/www.conf b/templates/www.conf new file mode 100644 index 0000000..e30aa18 --- /dev/null +++ b/templates/www.conf @@ -0,0 +1,20 @@ +[www{{php_version}}] +user = {{ php_fpm_pool_user }} +group = {{ php_fpm_pool_group }} +listen = {{ php_fpm_listen_url }} +listen.backlog = 511 +pm = {{ php_pm }} +pm.max_children = {{ php_pm_max_children }} +pm.start_servers = 5 +pm.min_spare_servers = 5 +pm.max_spare_servers = 35 +pm.max_requests = {{ php_pm_max_requests }} +pm.status_path = {{ php_pm_status_url }} +ping.path = /ping +access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" +access.log = /var/opt/remi/php{{ php_version }}/log/php-fpm/$pool.access.log +slowlog = /var/opt/remi/php{{ php_version }}/log/php-fpm/$pool.slow.log +request_slowlog_timeout = 5s +php_value[session.save_handler] = files +php_value[session.save_path] = /var/opt/remi/php{{ php_version }}/lib/php/se +php_value[soap.wsdl_cache_dir] = /var/opt/remi/php{{ php_version }}/lib/php/ws diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..2c031d5 --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - php-fpm \ No newline at end of file diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..a30a57c --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for php-fpm \ No newline at end of file