Skip to content

Commit

Permalink
NGX-753: Update (#23)
Browse files Browse the repository at this point in the history
* NGX-753: Update
  • Loading branch information
combssm authored Aug 6, 2023
1 parent 2d0ecbf commit cc36628
Show file tree
Hide file tree
Showing 16 changed files with 172 additions and 131 deletions.
58 changes: 48 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,62 @@ on:
workflow_dispatch:
branches: [master]

env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'

jobs:
test:
molecule:
name: Molecule Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image:
- "centos:7"
- "centos:8"
- "debian:10"
- "debian:11"
- "ubuntu:18.04"
- "ubuntu:20.04"
include:
- image: geerlingguy/docker-debian10-ansible:latest
command: /lib/systemd/systemd
- image: geerlingguy/docker-debian11-ansible:latest
command: /lib/systemd/systemd
- image: geerlingguy/docker-ubuntu2004-ansible:latest
- image: geerlingguy/docker-ubuntu2204-ansible:latest
- image: ghcr.io/artis3n/docker-almalinux8-ansible:latest
- image: geerlingguy/docker-rockylinux8-ansible:latest
- image: geerlingguy/docker-rockylinux9-ansible:latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.x"
- run: pip install -r requirements.txt
- run: molecule test

- name: Install test dependencies
run: pip3 install ansible molecule molecule-docker

- name: Run Molecule Test
run: molecule test
env:
MOLECULE_IMAGE: ${{ matrix.image }}
MOLECULE_COMMAND: ${{ matrix.command }}

molecule-legacy:
name: Molecule Test Legacy OS
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- image: geerlingguy/docker-centos7-ansible:latest
command: /usr/lib/systemd/systemd
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Install test dependencies
run: pip3 install ansible molecule molecule-docker

- name: Run Molecule Test
run: molecule test
env:
MOLECULE_IMAGE: ${{ matrix.image }}
MOLECULE_COMMAND: ${{ matrix.command }}
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/ansible/ansible-lint.git
rev: v6.17.2
hooks:
- id: ansible-lint
name: Ansible-lint
description: This hook runs ansible-lint.
entry: python3 -m ansiblelint -v --force-color
language: python
# do not pass files to ansible-lint, see:
# https://github.com/ansible/ansible-lint/issues/611
pass_filenames: false
always_run: true
additional_dependencies:
# https://github.com/pre-commit/pre-commit/issues/1526
# If you want to use specific version of ansible-core or ansible, feel
# free to override `additional_dependencies` in your own hook config
# file.
- ansible-core>=2.13.11
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/inmotionhosting/ansible-role-php_fpm.png?branch=master)](https://travis-ci.org/inmotionhosting/ansible-role-php_fpm) [![GPL-3.0 License](https://img.shields.io/github/license/inmotionhosting/ansible-role-php_fpm.svg?color=blue)](https://github.com/inmotionhosting/ansible-role-php_fpm/blob/master/LICENSE) [![GitHub stars](https://img.shields.io/github/stars/inmotionhosting/ansible-role-php_fpm.svg)](https://github.com/inmotionhosting/ansible-role-php_fpm/stargazers)
![Ansible Molecule Pipeline](https://github.com/inmotionhosting/ansible-role-php_fpm/actions/workflows/main.yml/badge.svg) [![GPL-3.0 License](https://img.shields.io/github/license/inmotionhosting/ansible-role-php_fpm.svg?color=blue)](https://github.com/inmotionhosting/ansible-role-php_fpm/blob/master/LICENSE) [![GitHub stars](https://img.shields.io/github/stars/inmotionhosting/ansible-role-php_fpm.svg)](https://github.com/inmotionhosting/ansible-role-php_fpm/stargazers)

# Ansible Role: PHP-FPM

Expand All @@ -10,9 +10,11 @@ server-focused Linux distributions and aims to follow their deprecation
policies. Additionally we will focus on supporting the latest two stable
releases of each, which at the time of writing are as follows:

* CentOS 7, 8
* Debian 10, 11
* Ubuntu 18.04, 20.04
* CentOS 7.x or later
* Debian 10 or later
* Ubuntu 20.04 LTS or later
* AlmaLinux 8.x or later
* RockyLinux 8.x or later

## Dependencies
None.
Expand All @@ -26,7 +28,6 @@ Available variables are listed below with their default values (you can also see
| php_fpm_config_pool_path | Default: `/etc/php-fpm.d`
| php_fpm_daemon | Default: `php-fpm`
| php_request_slowlog_timeout | Default: `0`
| php_fpm_site_errorlog | Default: `/home/{{ system_user }}/logs/{{ site_domain | replace (".", "_") }}.php.error.log`
| php_fpm_slowlog | Default: `/var/log/php-fpm/{{ system_user }}-slow.log`
| php_fpm_socket_path | Default: `/var/run/php-fpm/{{ system_user }}.sock`
| php_packages | The list of PHP packages to install.
Expand Down
1 change: 0 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ php_config_ini_path: /etc/php.ini
php_fpm_config_path: /etc/php-fpm.conf
php_fpm_config_pool_path: /etc/php-fpm.d
php_fpm_daemon: php-fpm
php_fpm_site_errorlog: /home/{{ system_user }}/logs/{{ site_domain | replace(".", "_") }}.php.error.log
php_fpm_slowlog: /var/log/php-fpm/{{ system_user }}-slow.log
php_fpm_socket_path: /var/run/php-fpm/{{ system_user }}.sock
php_systemd_restart: false
Expand Down
6 changes: 3 additions & 3 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: restart php-fpm
systemd:
daemon_reload: yes
- name: Restart php-fpm
ansible.builtin.systemd:
daemon_reload: true
name: "{{ php_fpm_daemon }}"
state: restarted
11 changes: 6 additions & 5 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ galaxy_info:
description: Modular Ansible Role for deploying and configuring PHP-FPM
company: InMotion Hosting
license: GPLv3
min_ansible_version: 2.8
min_ansible_version: "2.9"

platforms:
- name: EL
versions:
- 7
- 8
- "7"
- "8"
- "9"
- name: Debian
versions:
- stretch
- buster
- bullseye
- name: Ubuntu
versions:
- bionic
- focal
- jammy

galaxy_tags:
- web
Expand Down
36 changes: 0 additions & 36 deletions molecule/default/Dockerfile.j2

This file was deleted.

8 changes: 8 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
---
- name: Converge
hosts: all

pre_tasks:
- name: Update apt cache (on Debian).
ansible.builtin.apt:
update_cache: true
cache_valid_time: 3600
when: ansible_os_family == 'Debian'

vars:
system_user: example
roles:
Expand Down
22 changes: 11 additions & 11 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ driver:
name: docker

platforms:
- name: "molecule-ansible-role-php_fpm"
image: "${MOLECULE_IMAGE:-centos:8}"
command: ""
privileged: true
- name: "molecule-ansible-role-mysql"
image: ${MOLECULE_IMAGE:-geerlingguy/docker-ubuntu2204-ansible:latest}
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
pre_build_image: true

provisioner:
name: ansible
name: "ansible"
config_options:
defaults:
callback_enabled: timer
internal_poll_interval: "0.01"
callbacks_enabled: "profile_tasks, timer"
internal_poll_interval: 0.01
nocows: 1
stdout_callback: "yaml"
var_compression_level: 9
diff:
always: true
log: true

verifier:
name: ansible
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# requirements.txt

ansible==4.5.0
molecule==3.4.0
molecule-docker==1.0.2
ansible-lint
pre-commit
23 changes: 11 additions & 12 deletions tasks/facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
- name: Set installed PHP version
vars:
package: php-fpm
set_fact:
ansible.builtin.set_fact:
php_version_installed: "{{ ansible_facts.packages[package][0].version.split('.')[0:2] | join('.') }}"
php_version_installed_flat: "{{ ansible_facts.packages[package][0].version.split('.')[0:2] | join('.') | replace('.', '') }}"
when:
- package in ansible_facts.packages.keys()

- name: Include Debian vars
include_vars: "debian.yml"
ansible.builtin.include_vars: "debian.yml"
when: ansible_os_family|lower == "debian"

- name: Set lists of required variables
set_fact:
ansible.builtin.set_fact:
php_required_strings:
- php_version
- php_version_flat
Expand All @@ -35,7 +35,6 @@
- php_conf_soap_wsdl_cache_dir
- php_fpm_config_pool_path
- php_fpm_socket_path
- php_fpm_site_errorlog
- php_fpm_slowlog
php_required_ints:
- php_ini_rlimit_files
Expand All @@ -51,7 +50,7 @@
- php_ini_zlib_output_compression_level

- name: Check required PHP variables (strings)
fail:
ansible.builtin.fail:
msg: |
Invalid value for variable for '{{ item }}': {{ lookup('vars', item) }}
Expand All @@ -63,7 +62,7 @@
with_items: "{{ php_required_strings }}"

- name: Check required PHP variables (integers)
fail:
ansible.builtin.fail:
msg: |
Invalid value for variable for '{{ item }}': {{ lookup('vars', item) }}
Expand All @@ -75,7 +74,7 @@
with_items: "{{ php_required_ints }}"

- name: Check required PHP variables (php_packages)
fail:
ansible.builtin.fail:
msg: |
Invalid value for variable for 'php_packages': {{ php_packages }}
Expand All @@ -86,21 +85,21 @@
or php_packages == 0
- name: Set and sanitize dependent RedHat vars
set_fact:
ansible.builtin.set_fact:
apache_config_path: /etc/httpd/conf.d
when:
- ansible_os_family|lower == "redhat"
- apache_config_path is undefined

- name: Set and sanitize dependent Debian vars
set_fact:
ansible.builtin.set_fact:
apache_config_path: /etc/apache2/conf-enabled
when:
- ansible_os_family|lower == "debian"
- apache_config_path is undefined

- name: Check variable 'systemd_restart_setting'
fail:
ansible.builtin.fail:
msg: |
Invalid value for variable 'systemd_restart_setting': '{{ systemd_restart_setting }}'
Expand All @@ -120,13 +119,13 @@
and systemd_restart)
- name: Set PHP switcher
set_fact:
ansible.builtin.set_fact:
php_version_switch: true
when:
- php_version_installed is defined
- php_version != php_version_installed

- name: Remove php-sodium when PHP 5.6
set_fact:
ansible.builtin.set_fact:
php_packages: "{{ php_packages | reject('search', 'php-sodium') | list }}"
when: php_version == '5.6'
Loading

0 comments on commit cc36628

Please sign in to comment.