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

Speedup inventory breaks include_role over with_items #30903

Closed
willthames opened this issue Sep 26, 2017 · 5 comments · Fixed by #31111
Closed

Speedup inventory breaks include_role over with_items #30903

willthames opened this issue Sep 26, 2017 · 5 comments · Fixed by #31111
Assignees
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. include_role module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@willthames
Copy link
Contributor

ISSUE TYPE
  • Bug Report
COMPONENT NAME

include_role

ANSIBLE VERSION
ansible 2.5.0 (devel cb5f2c7ac3) last updated 2017/09/26 11:45:15 (GMT +1000)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/will/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/will/src/ansible/lib/ansible
  executable location = /home/will/src/ansible/bin/ansible
  python version = 2.7.13 (default, Sep  5 2017, 08:53:59) [GCC 7.1.1 20170622 (Red Hat 7.1.1-3)]
CONFIGURATION

N/A

OS / ENVIRONMENT

N/A

SUMMARY

include_role combined with with_items no longer works after the inventory speedup #30587

STEPS TO REPRODUCE

playbook:

- hosts: host1
  connection: local
  gather_facts: false

  tasks:
    - name: apply role whatever over list of items
      include_role:
        name: whatever
      with_items:
        - a

inventory file:

[group4]
host1

[group2]
host2

[group3]
host1
host2

[group3]
host3

[group2]
host3

To see the working version (it's not needed for the failure)

mkdir -p roles/whatever/tasks && echo "- debug: msg=hello" > roles/whatever/tasks/main.yml
EXPECTED RESULTS

With Ansible 2.4.0, I get:

$ ansible-playbook playbook.yml -i inventory

PLAY [host1] *************************************************************************************************************************************************

TASK [apply role whatever over list of items] ****************************************************************************************************************

TASK [whatever : debug] **************************************************************************************************************************************
ok: [host1] => {
    "msg": "hello"
}

PLAY RECAP ***************************************************************************************************************************************************
host1                      : ok=1    changed=0    unreachable=0    failed=0   
ACTUAL RESULTS
$ ansible-playbook playbook.yml -i inventory

PLAY [host1] *************************************************************************************************************************************************

TASK [apply role whatever over list of items] ****************************************************************************************************************
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 804, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.7/threading.py", line 757, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/will/src/ansible/lib/ansible/plugins/strategy/__init__.py", line 84, in results_thread_main
    result = strategy._final_q.get()
  File "/usr/lib64/python2.7/multiprocessing/queues.py", line 117, in get
    res = self._recv()
  File "/home/will/src/ansible/lib/ansible/inventory/host.py", line 37, in __setstate__
    return self.deserialize(data)
  File "/home/will/src/ansible/lib/ansible/inventory/host.py", line 82, in deserialize
    g.deserialize(group_data)
  File "/home/will/src/ansible/lib/ansible/inventory/group.py", line 77, in deserialize
    self._hosts = set(self.hosts)
  File "/home/will/src/ansible/lib/ansible/inventory/host.py", line 48, in __hash__
    return hash(self.name)
AttributeError: 'Host' object has no attribute 'name'

At which point the playbook just hangs.

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 bug_report 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. labels Sep 26, 2017
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Sep 26, 2017
@bcoca bcoca self-assigned this Sep 26, 2017
@bcoca
Copy link
Member

bcoca commented Sep 26, 2017

... wrong deserialization, should be host names ..

bcoca added a commit to bcoca/ansible that referenced this issue Sep 26, 2017
@bcoca bcoca added this to TODO in Inventory revamp Sep 27, 2017
@mattclay
Copy link
Member

@willthames Thanks for the repro, it helped me isolate the issue faster than running it through CI.

The timeout issue we're seeing in CI is intermittent, and only on Python 3, but this repro triggers it and yields the same error. It occurs while deserializing a Group which has multiple Host references.

During deserialization of Group, it tries to add all the Host objects to a set. However, not all of the Host objects have been deserialized yet, so they are missing attributes, causing the AttributeError.

@mattclay
Copy link
Member

@willthames Can you test the fix in #31033 to see if it resolves your issue?

@mattclay mattclay added this to TODO: Next release in 2.4.x Blocker List Sep 29, 2017
@mattclay mattclay moved this from TODO: Next release to TODO: Blocker in 2.4.x Blocker List Sep 29, 2017
bcoca added a commit to bcoca/ansible that referenced this issue Sep 29, 2017
@abadger abadger moved this from TODO: Blocker to In Progress in 2.4.x Blocker List Sep 29, 2017
@bcoca
Copy link
Member

bcoca commented Sep 29, 2017

@willthames can you test that #31103 fixes it for you? nvmd .. 2.6 doesn't support fix, try the one below

bcoca added a commit to bcoca/ansible that referenced this issue Sep 29, 2017
hopefully bpyass srlz10n issues to fix ansible#30903
@olfway
Copy link

olfway commented Sep 30, 2017

#31111 fixes #31093 for me on stable-2.4 and devel

mattclay pushed a commit that referenced this issue Oct 3, 2017
set _hosts on access if None to bpyass srlz10n issues to fix #30903
mattclay pushed a commit that referenced this issue Oct 3, 2017
set _hosts on access if None to bpyass srlz10n issues to fix #30903

(cherry picked from commit cf3414d)
@bcoca bcoca moved this from In Progress to Done in 2.4.x Blocker List Oct 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. include_role module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
No open projects
6 participants