geerlingguy / ansible-role-php

Ansible Role - PHP
https://galaxy.ansible.com/geerlingguy/php/
MIT License
496 stars 442 forks source link

Do not run php-fpm service when ansible is in check mode #408

Closed vonhraban closed 1 year ago

vonhraban commented 1 year ago

At the moment running the role when in check mode always fails since the role is trying to start/restart php-fpm service. This will never succeed in check mode since no real changes are made to the target environment.

This change ensures that both restart php-fpm and Ensure php-fpm is started and enabled at boot (if configured). do not run in check mode.

Below is steps I took to reproduce the issue on Ubuntu 20.04

Output:


fatal: [***]: FAILED! => {"changed": false, "msg": "Could not find the requested service php8.1-fpm: host"}

Definition:

php_default_version: "8.1"

    become: true
    daemon_reload: yes
    vars:
      php_fpm_daemon: "php8.1-fpm"
      php_default_version_debian: "{{ php_default_version }}"
      php_enable_php_fpm: true
      ...
      php_webserver_daemon: "nginx"
      php_fpm_listen: "/var/run/php/php-fpm.sock"
      php_packages:
        - php
        - ...
        - etc

Environment:

- name: Print Distribution Info
  debug:
    msg: "{{ ansible_distribution }} || {{ ansible_distribution_version }} || ({{ ansible_architecture }})"
  become: true

ok: [***] => {
    "msg": "Ubuntu || 20.04 || (x86_64)"
}