robertdebock / ansible-collection-roles

A collection of roles found on robertdebock.nl.
Apache License 2.0
36 stars 15 forks source link

Flush handler conflict while using multiple roles #6

Closed flotho closed 1 year ago

flotho commented 1 year ago

Hi,

I'm running mutiple of your roles in a playbook :

.../..
  roles:
    - role: robertdebock.roles.locale
      vars:
        locale_timezone: "{{ ntp_timezone }}"
    - role: robertdebock.roles.openssh
    - role: robertdebock.roles.git
    - role: robertdebock.roles.logrotate
    - role: robertdebock.roles.investigate

My host is a rocky linux 9 uptodate. The first time I run this sequence, the flush handler in openssh is triggering an event causing an issue on the locale :

TASK [robertdebock.roles.openssh : Flush handlers] *********************************************************************************************
task path: /home/florent.thomas/DEV/Projets_Infra/all-ansible-tools/ansible_collections/robertdebock/roles/roles/openssh/tasks/main.yml:55
[WARNING]: flush_handlers task does not support when conditional

RUNNING HANDLER [robertdebock.roles.locale : Localectl set-locale] *****************************************************************************
task path: /home/florent.thomas/DEV/Projets_Infra/all-ansible-tools/ansible_collections/robertdebock/roles/roles/locale/handlers/main.yml:4
fatal: [sso.mind-and-go.net]: FAILED! => {"changed": true, "cmd": ["localectl", "set-locale", "LANG=fr_FR.utf8"], "delta": "0:00:00.037381", "end": "2022-12-22 21:54:25.241665", "msg": "non-zero return code", "rc": 1, "start": "2022-12-22 21:54:25.204284", "stderr": "Failed to issue method call: Locale fr_FR.utf8 not installed, refusing.", "stderr_lines": ["Failed to issue method call: Locale fr_FR.utf8 not installed, refusing."], "stdout": "", "stdout_lines": []}

RUNNING HANDLER [robertdebock.roles.openssh : Restart openssh] *********************************************************************************
task path: /home/florent.thomas/DEV/Projets_Infra/all-ansible-tools/ansible_collections/robertdebock/roles/roles/openssh/handlers/main.yml:4
META: ran handlers

Even if we have an issue there, y=the locale has correctly been set.

Moreover, running a second time the same sequence succeeded.

AFAICS, this part of the code https://github.com/robertdebock/ansible-collection-roles/blob/master/roles/openssh/tasks/main.yml#L56 is triggering this other part : https://github.com/robertdebock/ansible-collection-roles/blob/master/roles/locale/handlers/main.yml#L4

I don't know what to do

flotho commented 1 year ago

hum... obviously, not everything is correctly set :

[root@localhost ~]# locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=fr_FR.utf8
LC_CTYPE="fr_FR.utf8"
LC_NUMERIC="fr_FR.utf8"
LC_TIME="fr_FR.utf8"
LC_COLLATE="fr_FR.utf8"
LC_MONETARY="fr_FR.utf8"
LC_MESSAGES="fr_FR.utf8"
LC_PAPER="fr_FR.utf8"
LC_NAME="fr_FR.utf8"
LC_ADDRESS="fr_FR.utf8"
LC_TELEPHONE="fr_FR.utf8"
LC_MEASUREMENT="fr_FR.utf8"
LC_IDENTIFICATION="fr_FR.utf8"
LC_ALL=
flotho commented 1 year ago

looks like something recent https://bugzilla.redhat.com/show_bug.cgi?id=2000878

robertdebock commented 1 year ago

About the flushing of handlers;

If there is any ansible.builtin.meta: flush_handlers, it will flush all collected handlers. This means you can indeed see handlers of role x while the role that's running is y.

I'm not sure if that answers your question, let me know if you need something else.