Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect behaviour after flush_handlers #82384

Closed
1 task done
m-krs opened this issue Dec 8, 2023 · 4 comments
Closed
1 task done

Incorrect behaviour after flush_handlers #82384

m-krs opened this issue Dec 8, 2023 · 4 comments
Labels
affects_2.14 affects_2.16 bug This issue/PR relates to a bug. module This issue/PR relates to a module.

Comments

@m-krs
Copy link

m-krs commented Dec 8, 2023

Summary

ansible-core 2.14 has introduced a bug with handlers that impacts the next executed task.

Issue Type

Bug Report

Component Name

meta

Ansible Version

ansible [core 2.16.1]
  config file = None
  configured module search path = ['/Users/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/user/.pyenv/versions/3.10.2/envs/ansible-9.1.0/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/user/.pyenv/versions/ansible-9.1.0/bin/ansible
  python version = 3.10.2 (main, Jun  6 2022, 10:23:56) [Clang 13.1.6 (clang-1316.0.21.2.5)] (/Users/user/.pyenv/versions/3.10.2/envs/ansible-9.1.0/bin/python3.10)
  jinja version = 3.1.2
  libyaml = True

Configuration

CONFIG_FILE() = None

OS / Environment

Darwin Kernel Version 22.6.0

Steps to Reproduce

ansible-playbook -i host1,host2,host3 main.yml

- name: Test
  hosts: all
  connection: local
  gather_facts: false
  handlers:
    - name: run_handler
      ansible.builtin.debug:
        msg: run_handler
  tasks:
    - name: Trigger handler
      ansible.builtin.debug:
        msg: test
      changed_when: true
      when: inventory_hostname == 'host1'
      notify:
        - run_handler

    - name: Flush_handlers
      ansible.builtin.meta: flush_handlers

    - name: Wrong order
      ansible.builtin.debug:
        msg: What's wrong with the order? And look at the task name.

    - name: Next task is ok
      ansible.builtin.debug:
        msg: Next task is ok.

Expected Results

❯   ansible-playbook -i host1,host2,host3 main.yml -vvvv
ansible-playbook [core 2.13.13]
  config file = None
  configured module search path = ['/Users/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/user/.pyenv/versions/3.10.2/envs/ansible-6.7.0/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/user/.pyenv/versions/ansible-6.7.0/bin/ansible-playbook
  python version = 3.10.2 (main, Jun  6 2022, 10:23:56) [Clang 13.1.6 (clang-1316.0.21.2.5)]
  jinja version = 3.1.2
  libyaml = True
No config file found; using defaults
setting up inventory plugins
Parsed host1,host2,host3 inventory source with host_list plugin
Loading callback plugin default of type stdout, v2.0 from /Users/user/.pyenv/versions/3.10.2/envs/ansible-6.7.0/lib/python3.10/site-packages/ansible/plugins/callback/default.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: main.yml *****************************************************************************
Positional arguments: main.yml
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('host1,host2,host3',)
forks: 5
1 plays in main.yml

PLAY [Test] ***************************************************************************************
META: ran handlers

TASK [Trigger handler] *****************************************************************************
task path: /Users/user/test/ahandlers/main.yml:10
NOTIFIED HANDLER run_handler for host1
changed: [host1] => {
    "msg": "test"
}
skipping: [host2] => {}
skipping: [host3] => {}

TASK [Flush_handlers] ******************************************************************************
task path: /Users/user/test/ahandlers/main.yml:18

RUNNING HANDLER [run_handler] ******************************************************************
task path: /Users/user/test/ahandlers/main.yml:6
ok: [host1] => {
    "msg": "run_handler"
}
META: ran handlers

TASK [Wrong order] *********************************************************************************
task path: /Users/user/test/ahandlers/main.yml:21
ok: [host1] => {
    "msg": "What's wrong with the order? And look at the task name."
}
ok: [host2] => {
    "msg": "What's wrong with the order? And look at the task name."
}
ok: [host3] => {
    "msg": "What's wrong with the order? And look at the task name."
}

TASK [Next task is ok] ********************************************************************************
task path: /Users/user/test/ahandlers/main.yml:25
ok: [host1] => {
    "msg": "Next task is ok."
}
ok: [host2] => {
    "msg": "Next task is ok."
}
ok: [host3] => {
    "msg": "Next task is ok."
}
META: ran handlers
META: ran handlers

PLAY RECAP *******************************************************************************************
host1                      : ok=4    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
host2                      : ok=2    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0   
host3                      : ok=2    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0  

Actual Results

ansible-playbook [core 2.16.1]
  config file = None
  configured module search path = ['/Users/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/user/.pyenv/versions/3.10.2/envs/ansible-9.1.0/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/user/.pyenv/versions/ansible-9.1.0/bin/ansible-playbook
  python version = 3.10.2 (main, Jun  6 2022, 10:23:56) [Clang 13.1.6 (clang-1316.0.21.2.5)] (/Users/user/.pyenv/versions/3.10.2/envs/ansible-9.1.0/bin/python3.10)
  jinja version = 3.1.2
  libyaml = True
No config file found; using defaults
setting up inventory plugins
Loading collection ansible.builtin from 
Parsed host1,host2,host3 inventory source with host_list plugin
Loading callback plugin default of type stdout, v2.0 from /Users/user/.pyenv/versions/3.10.2/envs/ansible-9.1.0/lib/python3.10/site-packages/ansible/plugins/callback/default.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: main.yml ************************************************************************************************
Positional arguments: main.yml
verbosity: 4
connection: ssh
become_method: sudo
tags: ('all',)
inventory: ('host1,host2,host3',)
forks: 5
1 plays in main.yml

PLAY [Test] *********************************************************************************************************

TASK [Trigger handler] ***********************************************************************************************
task path: /Users/user/test/ahandlers/main.yml:10
Notification for handler run_handler has been saved.
changed: [host1] => {
    "msg": "test"
}
skipping: [host2] => {
    "false_condition": "inventory_hostname == 'host1'"
}
skipping: [host3] => {
    "false_condition": "inventory_hostname == 'host1'"
}

TASK [Flush_handlers] ***********************************************************************************************
task path: /Users/user/test/ahandlers/main.yml:18
NOTIFIED HANDLER run_handler for host1
META: triggered running handlers for host1

TASK [Flush_handlers] ***********************************************************************************************
task path: /Users/user/test/ahandlers/main.yml:18
META: triggered running handlers for host2

TASK [Flush_handlers] ***********************************************************************************************
task path: /Users/user/test/ahandlers/main.yml:18
META: triggered running handlers for host3

RUNNING HANDLER [run_handler] ***********************************************************************************
task path: /Users/user/test/ahandlers/main.yml:6
ok: [host1] => {
    "msg": "run_handler"
}

TASK [run_handler] **************************************************************************************************
task path: /Users/user/test/ahandlers/main.yml:21
ok: [host2] => {
    "msg": "What's wrong with the order? And look at the task name."
}
ok: [host3] => {
    "msg": "What's wrong with the order? And look at the task name."
}

TASK [Wrong order] *************************************************************************************************
task path: /Users/user/test/ahandlers/main.yml:21
ok: [host1] => {
    "msg": "What's wrong with the order? And look at the task name."
}

TASK [Next task is ok] ***********************************************************************************************
task path: /Users/user/test/ahandlers/main.yml:25
ok: [host1] => {
    "msg": "Next task is ok."
}
ok: [host2] => {
    "msg": "Next task is ok."
}
ok: [host3] => {
    "msg": "Next task is ok."
}

PLAY RECAP *********************************************************************************************************
host1                      : ok=4    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
host2                      : ok=2    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0   
host3                      : ok=2    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0 

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. affects_2.14 module This issue/PR relates to a module. labels Dec 8, 2023
@ansibot
Copy link
Contributor

ansibot commented Dec 8, 2023

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the component bot command.

@ansibot
Copy link
Contributor

ansibot commented Dec 8, 2023

@m-krs ansible-core 2.14 is not supported and no longer receives bug fixes. Please test against one of the supported versions of ansible-core, preferably the most recent one, to see whether the bug has been fixed.

click here for bot help

@m-krs
Copy link
Author

m-krs commented Dec 8, 2023

Updated test with core 2.16.1

@mkrizek
Copy link
Contributor

mkrizek commented Dec 8, 2023

Duplicate of #82307

@mkrizek mkrizek marked this as a duplicate of #82307 Dec 8, 2023
@mkrizek mkrizek closed this as completed Dec 12, 2023
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Dec 12, 2023
@ansible ansible locked and limited conversation to collaborators Dec 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.14 affects_2.16 bug This issue/PR relates to a bug. module This issue/PR relates to a module.
Projects
None yet
Development

No branches or pull requests

3 participants