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

handlers not inheriting role parameters (become) #17490

Closed
basictheprogram opened this issue Sep 9, 2016 · 1 comment
Closed

handlers not inheriting role parameters (become) #17490

basictheprogram opened this issue Sep 9, 2016 · 1 comment
Assignees
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug.

Comments

@basictheprogram
Copy link

ISSUE TYPE
  • Bug Report
COMPONENT NAME
ANSIBLE VERSION
$ ansible --version
ansible 2.2.0 (devel 19e00cf160) last updated 2016/09/09 11:04:47 (GMT -500)
  lib/ansible/modules/core: (detached HEAD bf5b3de83e) last updated 2016/09/09 11:04:47 (GMT -500)
  lib/ansible/modules/extras: (detached HEAD f83aa9fff3) last updated 2016/09/09 11:04:47 (GMT -500)
  config file =
  configured module search path = Default w/o overrides
CONFIGURATION
OS / ENVIRONMENT
SUMMARY

All my handlers that need to run as root are failing.

STEPS TO REPRODUCE
- hosts: all
  roles:
    - { role: grub2, become: yes }

grub2 handlers/main.yml

- name: update grub2
  command: "{{ update_grub2_command }}"
  register: r
  failed_when: r.rc != 0
  changed_when: False
  tags: grub2

RUNNING HANDLER [grub2 : update grub2] *****************************************
fatal: [testing_xenial64]: FAILED! => {"changed": false, "cmd": ["/usr/sbin/update-grub2"], "delta": "0:00:00.011241", "end": "2016-09-09 12:06:25.551493", "failed": true, "failed_when_result": true, "rc": 1, "start": "2016-09-09 12:06:25.540252", "stderr": "grub-mkconfig: You must run this as root", "stdout": "", "stdout_lines": [], "warnings": []}

Changing the handler to

- name: update grub2
  command: "{{ update_grub2_command }}"
  register: r
  failed_when: r.rc != 0
  changed_when: False
  become: yes
  tags: grub2

Fixes the problem.
EXPECTED RESULTS
ACTUAL RESULTS

Additional details in Ansible Development Google Group
https://groups.google.com/forum/#!topic/ansible-devel/utV9nR-1P84

@bcoca bcoca changed the title Did something changed in how handlers are called? handlers not inheriting role parameters (become) Sep 9, 2016
@bcoca bcoca added bug_report affects_2.2 This issue/PR affects Ansible v2.2 labels Sep 9, 2016
@bcoca bcoca assigned jimi-c and bcoca Sep 9, 2016
jsteinich added a commit to jsteinich/ansible-datadog that referenced this issue Nov 8, 2016
@jimi-c
Copy link
Member

jimi-c commented Nov 11, 2016

Hi @basictheprogram, this appears to have been resolved by other inheritance-related fixes I've been working on recently. I can no longer replicate this in stable-2.2 or devel:

[jamesc@jimi 17490]$ cat test.yml 
- hosts: localhost
  gather_facts: no
  roles:
  - { name: test, become: yes }
[jamesc@jimi 17490]$ cat roles/test/tasks/main.yml 
---
# tasks file for roles/test
- debug:
  changed_when: true
  notify: the handler
[jamesc@jimi 17490]$ cat roles/test/handlers/main.yml 
---
# handlers file for roles/test
- name: the handler
  command: whoami
[jamesc@jimi 17490]$ ansible-playbook --version
ansible-playbook 2.2.0.0 (stable-2.2 debfb798dd) last updated 2016/11/11 08:10:00 (GMT -500)
  lib/ansible/modules/core: (detached HEAD 164225aa43) last updated 2016/11/11 10:31:30 (GMT -500)
  lib/ansible/modules/extras: (detached HEAD 18bb736cc2) last updated 2016/11/11 10:31:30 (GMT -500)
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/usr/share/ansible']
[jamesc@jimi 17490]$ ansible-playbook -vv test.yml 
Using /etc/ansible/ansible.cfg as config file
PLAYBOOK: test.yml *************************************************************
1 plays in test.yml
PLAY [localhost] ***************************************************************
TASK [test : debug] ************************************************************
task path: /home/jamesc/testing/17490/roles/test/tasks/main.yml:3
NOTIFIED HANDLER the handler
ok: [localhost] => {
    "msg": "Hello world!"
}
RUNNING HANDLER [test : the handler] *******************************************
changed: [localhost] => {"changed": true, "cmd": ["whoami"], "delta": "0:00:00.002354", "end": "2016-11-11 10:31:46.044595", "rc": 0, "start": "2016-11-11 10:31:46.042241", "stderr": "", "stdout": "root", "stdout_lines": ["root"], "warnings": []}
PLAY RECAP *********************************************************************
localhost                  : ok=2    changed=2    unreachable=0    failed=0   

As such, we will go ahead and close this now. This will also be included in the 2.2.1.0 release.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved.

Thank you!

@jimi-c jimi-c closed this as completed Nov 11, 2016
yusekiya added a commit to yusekiya/ansible_role_docker that referenced this issue Jan 20, 2017
This was workaround of ansible/ansible#17490 resolved in ver. 2.2.1.
yusekiya added a commit to yusekiya/ansible_role_nvidia_driver that referenced this issue Jan 20, 2017
This was workaround of ansible/ansible#17490 resolved in ver. 2.2.1.
yusekiya added a commit to yusekiya/ansible_role_ubuntu_common that referenced this issue Jan 20, 2017
This was workaround of ansible/ansible#17490 resolved in ver. 2.2.1.
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
no-reply pushed a commit to surfliner/surfliner-mirror that referenced this issue Apr 10, 2019
Pulled cscfi.shibboleth-sp v1.0.6, fixed hanlder for
ansible/ansible#17490

Replaced loop: with with_items: for 2.2.0.0 compatibility

Explicitly add cmprescott.xml requirement.

Rebased to master branch as of Mon Apr  1 19:40:10 UTC 2019
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants