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
Name of a role may prevent it from being executed in 2.2.0 #20448
Comments
Hmm, I'm not able to reproduce this against 2.2.0 (the relatively-pathed role runs fine from a playbook invoked inside it) - can you get it down to a super-tiny self-contained repro and upload somewhere? |
note that this is not the ideal way of referencing roles, you normally put them in the roles path referenced in config or in roles/ relative to play. That said, this should still work, but again, not optimal. |
@bcoca: this specific case is invoking a role-specific "test" playbook inside the role |
i would just symlink the roles/ directory or move the tests to the top level |
@nitzmahone Hi, I just load a tiny repo here on GitHub. The 2 roles I tried agin, and the result remains the same. $ ansible-playbook roles/fail2ban/tests/main.yml
SUDO password:
PLAY [Test suit] ***************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 For $ ansible-playbook roles/failban/tests/main.yml
SUDO password:
PLAY [Test suit] ***************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [../../failban : Install package `fail2ban`] ******************************
ok: [localhost]
TASK [../../failban : Ensure fail2ban path exists] *****************************
ok: [localhost]
TASK [../../failban : Copy jail.local] *****************************************
ok: [localhost]
TASK [../../failban : Restart service fail2ban] ********************************
changed: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=5 changed=1 unreachable=0 failed=0 What's more, if I reference both of them in a top level play, everything seems fine: $ ansible-playbook test.yml
SUDO password:
PLAY [Test suit] ***************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [fail2ban : Install package `fail2ban`] ***********************************
ok: [localhost]
TASK [fail2ban : Ensure fail2ban path exists] **********************************
ok: [localhost]
TASK [fail2ban : Copy jail.local] **********************************************
ok: [localhost]
TASK [fail2ban : Restart service fail2ban] *************************************
changed: [localhost]
TASK [failban : Install package `fail2ban`] ************************************
ok: [localhost]
TASK [failban : Ensure fail2ban path exists] ***********************************
ok: [localhost]
TASK [failban : Copy jail.local] ***********************************************
ok: [localhost]
TASK [failban : Restart service fail2ban] **************************************
changed: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=9 changed=2 unreachable=0 failed=0 |
I tried to reproduce this on a Ubuntu 14.04 host running Ansible 2.2.1.0, and a CentOS 6.8 host running Ansible 2.1.2.0, and both hosts were able to run both roles without any problems.
|
I think I figured out how to reproduce this. I install Ansible 2.2.0 on a clean Centos 6.8 machine, then clone the repo I uploaded. # For fail2ban
$ ansible-playbook roles/fail2ban/tests/main.yml --list-task
playbook: roles/fail2ban/tests/main.yml
play #1 (localhost): Test suit TAGS: []
tasks:
../../fail2ban : Install package `fail2ban` TAGS: []
../../fail2ban : Ensure fail2ban path exists TAGS: []
../../fail2ban : Copy jail.local TAGS: []
../../fail2ban : Restart service fail2ban TAGS: []
# For failban
$ ansible-playbook roles/failban/tests/main.yml --list-task
playbook: roles/failban/tests/main.yml
play #1 (localhost): Test suit TAGS: []
tasks:
../../failban : Install package `fail2ban` TAGS: []
../../failban : Ensure fail2ban path exists TAGS: []
../../failban : Copy jail.local TAGS: []
../../failban : Restart service fail2ban TAGS: [] Then run role fail2ban: ansible-playbook roles/fail2ban/tests/main.yml
SUDO password:
PLAY [Test suit] ***************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [../../fail2ban : Install package `fail2ban`] *****************************
changed: [localhost]
TASK [../../fail2ban : Ensure fail2ban path exists] ****************************
ok: [localhost]
TASK [../../fail2ban : Copy jail.local] ****************************************
fatal: [localhost]: FAILED! => {"changed": false, "checksum": "a244a87751cf1b1b144927e117ea598250feac21", "failed": true,
"msg": "Aborting, target uses selinux but python bindings (libselinux-python) aren't installed!"}
to retry, use: --limit @/home/nutstore/ansible-issue20448/roles/fail2ban/tests/main.retry
PLAY RECAP *********************************************************************
localhost : ok=3 changed=1 unreachable=0 failed=1 And things start getting weird: $ ansible-playbook roles/fail2ban/tests/main.yml --list-tasks
playbook: roles/fail2ban/tests/main.yml
play #1 (localhost): Test suit TAGS: []
tasks:
$ ansible-playbook roles/fail2ban/tests/main.yml --check
SUDO password:
PLAY [Test suit] ***************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
$ ansible-playbook roles/fail2ban/tests/main.yml
SUDO password:
PLAY [Test suit] ***************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 I tried installing $ ansible-playbook roles/failban/tests/main.yml --list-tasks
playbook: roles/failban/tests/main.yml
play #1 (localhost): Test suit TAGS: []
tasks:
../../failban : Install package `fail2ban` TAGS: []
../../failban : Ensure fail2ban path exists TAGS: []
../../failban : Copy jail.local TAGS: []
../../failban : Restart service fail2ban TAGS: [] |
Moreover, if libselinux-python is installed in advance, everything goes fine. |
closing as per above |
ISSUE TYPE
COMPONENT NAME
roles
in a playANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
CentOS release 6.8 (Final)
SUMMARY
Name of a role can prevent it from running in 2.2.0
STEPS TO REPRODUCE
Structure of Ansible dir like this
Content of
roles/fail2ban/tasks/main.yml
Content of
roles/fail2ban/tests/main.yml
is quite straight forwardEXPECTED RESULTS
Tasks listed in
tasks/main.yml
should be executed.ACTUAL RESULTS
After I run
ansible-playbook roles/fail2ban/tests/main.yml
, nothing happens:And
--list-tasks
gives me thisHowever, if I mv
fail2ban\
tofailban\
and change- role: ../../fail2ban
into- role: ../../failban
, everything seems fineThe text was updated successfully, but these errors were encountered: