From 387b03ddbf4f81123bca44863ad8bead63b3eb51 Mon Sep 17 00:00:00 2001 From: Emilien Mantel Date: Tue, 31 Aug 2021 10:51:29 +0200 Subject: [PATCH] Fix lint errors --- .ansible-lint | 8 +++++++ README.md | 2 +- meta/main.yml | 46 +++++++++++++++++++------------------- tasks/fpm.yml | 8 ++++++- tasks/main.yml | 31 ++++++++++++++------------ tasks/opcache.yml | 30 +++++++++++++++---------- tasks/xdebug.yml | 56 +++++++++++++++++++++++------------------------ 7 files changed, 102 insertions(+), 79 deletions(-) create mode 100644 .ansible-lint diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..fe29fed --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,8 @@ +--- + +# TODO: enable later +# enable_list: +# - fqcn-builtins + +skip_list: + - role-name diff --git a/README.md b/README.md index 0b51194..148481b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Ansible PHP (+FPM) role for Debian / Ubuntu / FreeBSD ===================================================== -[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-HanXHX.php-blue.svg)](https://galaxy.ansible.com/HanXHX/php) [![Build Status](https://travis-ci.org/HanXHX/ansible-php.svg?branch=master)](https://travis-ci.org/HanXHX/ansible-php) +[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-HanXHX.php-blue.svg)](https://galaxy.ansible.com/HanXHX/php) [![Build Status](https://app.travis-ci.com/HanXHX/ansible-php.svg?branch=master)](https://app.travis-ci.com/HanXHX/ansible-php) Install PHP on Debian / Ubuntu / FreeBSD. Manage PHP-FPM, APCu, Opcache and Xdebug. diff --git a/meta/main.yml b/meta/main.yml index 5c3de13..28c3a3b 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -6,28 +6,28 @@ galaxy_info: license: GPLv2 min_ansible_version: 2.11 platforms: - - name: Debian - versions: - - stretch - - buster - - bullseye - - name: Ubuntu - versions: - - xenial - - bionic - - name: FreeBSD - versions: - - 11.0 - - 11.1 - - 12.0 + - name: Debian + versions: + - stretch + - buster + - bullseye + - name: Ubuntu + versions: + - xenial + - bionic + - name: FreeBSD + versions: + - 11.0 + - 11.1 + - 12.0 galaxy_tags: - - development - - web - - php - - php-fpm - - php7 - - debian - - ubuntu - - freebsd + - development + - web + - php + - fpm + - php7 + - php8 + - debian + - ubuntu + - freebsd dependencies: [] - diff --git a/tasks/fpm.yml b/tasks/fpm.yml index 7727594..9da4ce4 100644 --- a/tasks/fpm.yml +++ b/tasks/fpm.yml @@ -17,7 +17,10 @@ dest: '{{ php_fpm_ini }}' regexp: '^;?{{ item.key }}' line: '{{ item.key }} = {{ item.value }}' - create: yes + create: true + owner: root + group: root + mode: 0644 loop: "{{ php_ini | combine(php_ini_fpm) | dict2items }}" notify: restart php-fpm @@ -25,6 +28,9 @@ template: src: etc/__php__/fpm/pool.d/pool.conf.j2 dest: '{{ php_fpm_pool_dir }}/{{ item.name }}.conf' + owner: root + group: root + mode: 0644 loop: "{{ ansible_local.hanxhx_php.fpm_pool }}" notify: restart php-fpm diff --git a/tasks/main.yml b/tasks/main.yml index 21d981c..f29895c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -39,12 +39,15 @@ file: path: /etc/ansible/facts.d state: directory - recurse: yes + recurse: true - name: COPY | Manage facts copy: content: "{ \"fpm_pool\": {{ php_fpm_full_pool | to_nice_json }} }" dest: /etc/ansible/facts.d/hanxhx_php.fact + owner: root + group: root + mode: 0644 register: f - name: SETUP | Gathers new facts @@ -57,7 +60,7 @@ apt: pkg: "{{ pkgs }}" state: present - update_cache: yes + update_cache: true cache_valid_time: 3600 vars: pkgs: "{{ php_packages + php_extra_packages | flatten }}" @@ -94,18 +97,18 @@ - block: - - name: COMMAND | Check if PHP-FPM is started (Docker) - command: 'service {{ php_fpm_service }} status' - args: - warn: false - register: dps - changed_when: false - failed_when: false + - name: COMMAND | Check if PHP-FPM is started (Docker) + command: 'service {{ php_fpm_service }} status' + args: + warn: false + register: dps + changed_when: false + failed_when: false - - name: COMMAND | Ensure PHP-FPM is started (Docker) - command: 'service {{ php_fpm_service }} start' - args: - warn: false - when: dps.stdout.find('is not running') != -1 + - name: COMMAND | Ensure PHP-FPM is started (Docker) + command: 'service {{ php_fpm_service }} start' + args: + warn: false + when: dps.stdout.find('is not running') != -1 when: php_install_fpm and ansible_virtualization_type == 'docker' diff --git a/tasks/opcache.yml b/tasks/opcache.yml index 074d12e..b6feac1 100644 --- a/tasks/opcache.yml +++ b/tasks/opcache.yml @@ -2,25 +2,25 @@ - block: - - name: APT | Install APCu - apt: - pkg: "php-apcu" + - name: APT | Install APCu + apt: + pkg: "php-apcu" - - name: APT | Install Opcache - apt: - pkg: "{{ php_package_prefix }}opcache" + - name: APT | Install Opcache + apt: + pkg: "{{ php_package_prefix }}opcache" when: ansible_os_family == 'Debian' - block: - - name: PKGNG | Install APCu - pkgng: - name: "php{{ php_version | replace('.', '') }}-pecl-APCu" + - name: PKGNG | Install APCu + pkgng: + name: "php{{ php_version | replace('.', '') }}-pecl-APCu" - - name: PKGNG | Install Opcache - pkgng: - name: "{{ php_package_prefix }}opcache" + - name: PKGNG | Install Opcache + pkgng: + name: "{{ php_package_prefix }}opcache" when: ansible_os_family == 'FreeBSD' @@ -28,10 +28,16 @@ template: src: "etc/__php__/mods-available/opcache.ini.j2" dest: "{{ php_mods_dir }}/opcache.ini" + owner: root + group: root + mode: 0644 notify: restart php-fpm - name: TEMPLATE | Configure APCu template: src: "etc/__php__/mods-available/apcu.ini.j2" dest: "{{ php_mods_dir }}/apcu.ini" + owner: root + group: root + mode: 0644 notify: restart php-fpm diff --git a/tasks/xdebug.yml b/tasks/xdebug.yml index 2b13a2d..aaafd7b 100644 --- a/tasks/xdebug.yml +++ b/tasks/xdebug.yml @@ -2,41 +2,41 @@ - block: - - name: APT | Install xdebug - apt: - pkg: "{{ php_xdebug_package }}" - state: present - update_cache: yes - cache_valid_time: 3600 - when: ansible_os_family == 'Debian' + - name: APT | Install xdebug + apt: + pkg: "{{ php_xdebug_package }}" + state: present + update_cache: true + cache_valid_time: 3600 + when: ansible_os_family == 'Debian' - - name: PKGNG | Install xdebug - pkgng: - name: "{{ php_xdebug_package }}" - when: ansible_os_family == 'FreeBSD' and php_xdebug_package is defined + - name: PKGNG | Install xdebug + pkgng: + name: "{{ php_xdebug_package }}" + when: ansible_os_family == 'FreeBSD' and php_xdebug_package is defined - - name: TEMPLATE | Deploy module configurations - template: - src: "etc/__php__/mods-available/xdebug.ini.j2" - dest: "{{ php_mods_dir }}/xdebug.ini" - owner: root - mode: 0644 - notify: restart php-fpm + - name: TEMPLATE | Deploy module configurations + template: + src: "etc/__php__/mods-available/xdebug.ini.j2" + dest: "{{ php_mods_dir }}/xdebug.ini" + owner: root + mode: 0644 + notify: restart php-fpm when: php_install_xdebug - block: - - name: APT | Uninstall xdebug - apt: - pkg: "{{ php_xdebug_package }}" - state: absent - when: ansible_os_family == 'Debian' + - name: APT | Uninstall xdebug + apt: + pkg: "{{ php_xdebug_package }}" + state: absent + when: ansible_os_family == 'Debian' - - name: PKGNG | Uninstall xdebug - pkgng: - name: "{{ php_xdebug_package }}" - state: absent - when: ansible_os_family == 'FreeBSD' + - name: PKGNG | Uninstall xdebug + pkgng: + name: "{{ php_xdebug_package }}" + state: absent + when: ansible_os_family == 'FreeBSD' when: not php_install_xdebug