geerlingguy / ansible-role-php

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

Php-fpm service not found when running ansible playbook --check #407

Closed vonhraban closed 1 year ago

vonhraban commented 1 year ago

When running ansible-playbood --check --diff in Ubuntu, the following step is executed by Ansible

TASK [geerlingguy.php : Ensure php-fpm is started and enabled at boot (if configured).] ***

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

My understanding is that it can never succeed since this a dry run, and the service has never been installed. I can see that this step is omitted when running in Debian

https://github.com/geerlingguy/ansible-role-php/blob/7a1597c1ce6da36770f6a7615b031f2c4112da1d/tasks/configure-fpm.yml#L53

Perhaps there should be the same clause for Ubuntu, i.e.

when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'

?

This is the definition of what I am trying to execute

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

Some debug output

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

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

Thank you

vonhraban commented 1 year ago

Closing in favour of https://github.com/geerlingguy/ansible-role-php/pull/408