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

notify is silently ignored on import_tasks #64935

Closed
aschult5 opened this issue Nov 16, 2019 · 10 comments · Fixed by #73572
Closed

notify is silently ignored on import_tasks #64935

aschult5 opened this issue Nov 16, 2019 · 10 comments · Fixed by #73572
Labels
affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team. utilities Utilities category

Comments

@aschult5
Copy link
Contributor

aschult5 commented Nov 16, 2019

SUMMARY

notify is silently ignored on import_tasks.
This leads to unexpected behavior.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

import_tasks

ANSIBLE VERSION
ansible-playbook 2.10.0.dev0
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/aschultz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/aschultz/dev/vendor/ansible/lib/ansible
  executable location = /home/aschultz/dev/vendor/ansible/bin/ansible-playbook
  python version = 3.7.3 (default, Apr 09 2019, 05:18:21) [GCC]
STEPS TO REPRODUCE

ansible-playbook test.yml -c local -l localhost

test.yml:

- hosts: localhost
  tasks:
    - import_tasks: tasks.yml
      notify:
        - myhandler

  handlers:
    - name: myhandler
      debug:
        msg: "handler"

tasks.yml:

- name: a touch
  file:
    path: /tmp/touchme
    state: touch
EXPECTED RESULTS

An error is printed similar to the one for include_tasks, i.e.

ERROR! 'notify' is not a valid attribute for a TaskInclude

ACTUAL RESULTS

The notify attribute is ignored.

PLAY [localhost] *********************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [a touch] ************************************************************************************************************************************************************************************************************************
changed: [localhost]

PLAY RECAP ***************************************************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
@ansibot
Copy link
Contributor

ansibot commented Nov 16, 2019

Files identified in the description:

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

click here for bot help

@ansibot ansibot added affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. utilities Utilities category labels Nov 16, 2019
Akasurde added a commit to Akasurde/ansible that referenced this issue Nov 20, 2019
notify is not valid import_tasks attribute. Raise an error
when user specifies it.

Fixes: ansible#64935

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Akasurde added a commit to Akasurde/ansible that referenced this issue Nov 21, 2019
notify is not valid import_tasks attribute. Raise an error
when user specifies it.

Fixes: ansible#64935

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Akasurde added a commit to Akasurde/ansible that referenced this issue Nov 21, 2019
notify is not valid import_tasks attribute. Raise an error
when user specifies it.

Fixes: ansible#64935

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@cesarjorgemartinez
Copy link

cesarjorgemartinez commented Nov 26, 2019

Hi,

In my environments this issue appears using Ansible version 2.8.2, 2.8.7, 2.9.1.

In Ansible 2.6.5 is working correctly, the handler is executed correctly:

RUNNING HANDLER [iot.mongodb : restart mongodb service] *******************************************************************************
Running systemd
...

Using the other versions:

RUNNING HANDLER [iot.mongodb : restart mongodb service] *******************************************************************************
task path: ...roles/iot.mongodb/handlers/main.yml:2
skipping: [mongo-02] => {
    "changed": false, 
    "skip_reason": "Conditional result was False"
}

I try to use: import_tasks, include_tasks, etc, without no luck.

I've been trying to find a workaround but I haven't got it.

When will this bug be fixed? It's very important. I cannot use ansible branch master in production.

Regards,
Cesar Jorge

@ansibot ansibot added the has_pr This issue has an associated PR. label Nov 26, 2019
@s-hertel
Copy link
Contributor

@cesarjorgemartinez It seems like you may be having a different issue. There isn't different behavior on 2.6.5 using the reproducer in this ticket. Adding this feature would be a significant change to how imports/includes fundamentally work and would probably need to go through the proposal process if it was something we wanted to add.

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Nov 26, 2019
Akasurde added a commit to Akasurde/ansible that referenced this issue Nov 26, 2019
notify is not valid import_tasks attribute. Raise an error
when user specifies it.

Fixes: ansible#64935

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@cesarjorgemartinez
Copy link

cesarjorgemartinez commented Nov 26, 2019

Then, I create a new issue? Exist multiple issues related with handler execution, and this is the closest one I've found

@s-hertel
Copy link
Contributor

s-hertel commented Nov 30, 2019

@cesarjorgemartinez Yes, create a new issue with a simple reproducer for the behavior you're seeing. From the brief excerpt it looks like you're having a problem with the conditional on your handler rather than a problem with notify being ignored.

@sm4rk0
Copy link
Contributor

sm4rk0 commented Jan 10, 2020

I don't see a conditional in above handler...
And would expect the notify to trigger a handler if any of the imported tasks changed.

@sivel
Copy link
Member

sivel commented Jan 10, 2020

I don't see a conditional in above handler...
And would expect the notify to trigger a handler if any of the imported tasks changed.

imports do not work like tasks, and they do not have an association between the import_tasks task and the tasks within the imported file really. import_tasks is a pre-processing trigger, that is handled during playbook parsing time. When the parser encounters it, the tasks within are retrieved, and inserted where the import_tasks task was located. There is a proposal to "taskify" includes at ansible/proposals#136 but I don't see that being implemented any time soon.

@ansibot
Copy link
Contributor

ansibot commented May 16, 2020

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.

click here for bot help

@ChristianCiach
Copy link

ChristianCiach commented Jun 2, 2020

The one thing that always bugs me the most when using Ansible is the fact that Ansible fails to report errors when doing something that is not supported. Over the years, Ansible could have saved us a lot of headaches if it would just fail early (or report something at all) if the playbook contains unsupported constructs.

@jimi-c
Copy link
Member

jimi-c commented Jun 2, 2020

There was some effort recently to make options on some statements like this report warnings or errors instead of being silently ignored. I would not be opposed to adding this as well to avoid confusion in the future.

Akasurde added a commit to Akasurde/ansible that referenced this issue Jul 6, 2020
Raise an error or a warning when user specifies parameters
which are not supported by import_tasks.

Fixes: ansible#64935

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Akasurde added a commit to Akasurde/ansible that referenced this issue Jul 6, 2020
Raise an error or a warning when user specifies parameters
which are not supported by import_tasks.

Fixes: ansible#64935

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Akasurde added a commit to Akasurde/ansible that referenced this issue Jul 6, 2020
Raise an error or a warning when user specifies parameters
which are not supported by import_tasks.

Fixes: ansible#64935

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Akasurde added a commit to Akasurde/ansible that referenced this issue Jul 6, 2020
Raise an error or a warning when user specifies parameters
which are not supported by import_tasks.

Fixes: ansible#64935

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@ansible ansible locked and limited conversation to collaborators Mar 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team. utilities Utilities category
Projects
None yet
8 participants