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

include_role error with with_items (2.3.0 devel) #21285 #23104

Closed
wants to merge 1 commit into from

Conversation

snowsky
Copy link
Contributor

@snowsky snowsky commented Mar 30, 2017

SUMMARY

Fixes #21285

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
ANSIBLE VERSION
It seems this applies to the versions after 2.0.
ADDITIONAL INFORMATION
The role name didn't expand correctly if it is in a loop. This fix will see if there is loop var in role name, if there is it will replace the variable with correct loop var value.

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bugfix_pull_request c:executor/task_executor c:playbook/role_include needs_triage Needs a first human triage before being processed. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Mar 30, 2017
@snowsky snowsky closed this Mar 30, 2017
@snowsky snowsky reopened this Mar 30, 2017
@snowsky
Copy link
Contributor Author

snowsky commented Mar 30, 2017

The error is not related to this PR. I'll retest it.

@snowsky snowsky closed this Mar 30, 2017
@snowsky snowsky reopened this Mar 30, 2017
@snowsky
Copy link
Contributor Author

snowsky commented Mar 30, 2017

The error message is not related to the PR:

2017-03-30 13:00:20 Run command: docker run --detach ansible/ansible:httptester
2017-03-30 13:00:37 Run command: docker run --detach --volume /sys/fs/cgroup:/sys/fs/cgroup:ro --privileged=false --link e796353d922031119fa708809afb1c078a0444bf7d1111361f8b1df2ed8a130f:ansible.http.tests --link e796353d922031119fa708809afb1c078a0444bf7d1111361f8b1df2ed8a130f:sni1.ansible.http.tests --link e796353d922031119fa708809afb1c078a0444bf7d1111361f8b1df2ed8a130f:sni2.ansible.http.tests --link e796353d922031119fa708809afb1c078a0444bf7d1111361f8b1df2ed8a130f:fail.ansible.http.tests --env HTTPTESTER=1 ansible/ansible:ubuntu1604py3
2017-03-30 13:00:37 Run command: docker exec -i 6de974a3cf1bf4728d83b3d13408753e180bf2c3924c490e986107c5009bab4e dd of=/root/docker.sh bs=65536
2017-03-30 13:00:37 Run command: docker exec 6de974a3cf1bf4728d83b3d13408753e180bf2c3924c490e986107c5009bab4e /bin/bash /root/docker.sh
2017-03-30 13:00:37 /root/docker.sh: line 14: cannot create temp file for here-document: No such file or directory
2017-03-30 13:00:37 Run command: docker rm -f e796353d922031119fa708809afb1c078a0444bf7d1111361f8b1df2ed8a130f
2017-03-30 13:00:52 Run command: docker rm -f 6de974a3cf1bf4728d83b3d13408753e180bf2c3924c490e986107c5009bab4e
2017-03-30 13:00:57 ERROR: Command "docker exec 6de974a3cf1bf4728d83b3d13408753e180bf2c3924c490e986107c5009bab4e /bin/bash /root/docker.sh" returned exit status 1.

@snowsky snowsky closed this Mar 30, 2017
@snowsky snowsky reopened this Mar 30, 2017
@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Mar 30, 2017
@Qalthos Qalthos removed the needs_triage Needs a first human triage before being processed. label Mar 30, 2017
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Apr 11, 2017
@jbilbro
Copy link

jbilbro commented May 8, 2017

I have tried installing these two files on my Ansible 2.3 install on my Ansible Tower 3.1.3 server. When trying to execute a job template, it fails immediately when trying to update from SCM. If I revert these two files everything works fine (other than you know, include_roles failing to take a variable).

TASK [Set the git repository version] ****************************************** An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'module' object has no attribute 'NAMESPACE_FACTS' fatal: [localhost]: FAILED! => {"failed": true, "msg": "Unexpected failure during module execution.", "stdout": ""}

@ansibot ansibot added the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Jun 29, 2017
@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jul 19, 2017
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jul 27, 2017
@calfonso calfonso requested a review from bcoca August 17, 2017 18:42
@calfonso calfonso requested a review from jimi-c August 30, 2017 18:11
@halberom
Copy link
Contributor

halberom commented Sep 8, 2017

The include_role module example docs should probably be updated to include an example of this. Also, how does this impact the (currently working) alternative logic of with_ on a role?, as shown by the example

- name: Use role in loop
  include_role:
    name: myrole
  with_items:
    - '{{ roleinput1 }}'
    - '{{ roleinput2 }}'
  loop_control:
    loop_var: roleinputvar

for example, if I do this

- hosts: localhost
  connection: local
  gather_facts: False
  tasks:
    - include_role:
        name: "{{ item.name }}"
      with_items: 
        - { name: test2, message: 'foo' }
      loop_control:
        loop_var: rolevar

it (your pull request) doesn't work. 'item' is undefined

and finally, i thought dynamic role names weren't allowed for security reasons - too easy to modify what might be run based on some overriding var.

@mgvazquez
Copy link

I tested this PR locally in my env with the ansible-2.4.2.0 and work perfectly.
Please, review it and merge it as soon as possible. This is e great feature to implement.
PD: Sorry about my lack of expression in English language

@mkrizek
Copy link
Contributor

mkrizek commented Jan 8, 2018

#21285 was fixed in #33386 therefore I am going to close this one, thanks for your contribution @snowsky!

@mkrizek mkrizek closed this Jan 8, 2018
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bugfix_pull_request labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. c:executor/task_executor c:playbook/role_include executor/task_executor include_role playbook/role_include stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

include_role error with with_items (2.3.0 devel)
8 participants