Ansible handler goes in timeout

52 Views Asked by At

I have a playbook with two blocks: the first one run tasks as root to prepare the system, immediately after there's a second block that runs as a specific user. At the end of the playbook, I have my handlers. In case I open a new port in firewalld, the playbook completes but return an error when the handler fires (it goes in timeout). This is my play book with the relevant parts:

---
- hosts: homeserver
  tasks:
    - name: PREFLIGHT - Configure system and install needed packages
      block:

      ...

      - name: Populate service facts
        ansible.builtin.service_facts:
        register: service_facts
      
      - name: Open Ports in firewalld
        ansible.posix.firewalld:
          port: "{{ item }}"
          permanent: true
          state: enabled
        loop:
          # First service
          - xxx/tcp
          # Second service
          - yyy/tcp
        when:
          - services['firewalld.service'] is defined
          - services['firewalld.service']['state'] == 'running'
        notify:
          - Reload firewalld
      ...
      
      become: true
      become_user: root

This is the second block:

- name: Configure containers
      block:
...
become: true
become_user: podman

And this is the handler:

handlers:
    - name: Reload firewalld
      ansible.builtin.service:
        name: firewalld
        state: reloaded

What am I doing wrong and how can I avoid the time out from the handler?

0

There are 0 best solutions below