Public bug reported:

Ansible raises an exception when running list plugin:

Version: 2.5.1+dfsg-1ubuntu0.1+esm3

$ ansible -vvv -m debug -a msg="{{lookup('list', 'junk')|zip}}" localhost
ansible 2.5.1
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/vyom/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.17 (default, Nov 21 2024, 12:09:09) [GCC 7.5.0]
Using /etc/ansible/ansible.cfg as config file
Parsed /etc/ansible/hosts inventory source with ini plugin
 [WARNING]: provided hosts list is empty, only localhost is available. Note 
that the implicit localhost does not match 'all'

META: ran handlers
The full traceback is:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", 
line 138, in run
    res = self._execute()
  File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", 
line 503, in _execute
    self._task.post_validate(templar=templar)
  File "/usr/lib/python2.7/dist-packages/ansible/playbook/task.py", line 260, 
in post_validate
    super(Task, self).post_validate(templar)
  File "/usr/lib/python2.7/dist-packages/ansible/playbook/base.py", line 387, 
in post_validate
    value = method(attribute, getattr(self, name), templar)
  File "/usr/lib/python2.7/dist-packages/ansible/playbook/task.py", line 268, 
in _post_validate_args
    args = templar.template(value)
  File "/usr/lib/python2.7/dist-packages/ansible/template/__init__.py", line 
535, in template
    disable_lookups=disable_lookups,
  File "/usr/lib/python2.7/dist-packages/ansible/template/__init__.py", line 
491, in template
    disable_lookups=disable_lookups,
  File "/usr/lib/python2.7/dist-packages/ansible/template/__init__.py", line 
727, in do_template
    res = j2_concat(rf)
  File "<template>", line 12, in root
  File "/usr/lib/python2.7/dist-packages/ansible/utils/unsafe_proxy.py", line 
91, in __iter__
    return (cls(c) for c in super(AnsibleUnsafeText, self).__iter__())
AttributeError: 'super' object has no attribute '__iter__'

localhost | FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}

The problem is: AttributeError: 'super' object has no attribute
'__iter__'

This works fine on non esm version:

Version: 2.5.1+dfsg-1ubuntu0.1

$ ansible -vvv -m debug -a msg="{{lookup('list', 'junk')|zip}}" localhost
ansible 2.5.1
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/vyom/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.17 (default, Nov 21 2024, 12:09:09) [GCC 7.5.0]
Using /etc/ansible/ansible.cfg as config file
Parsed /etc/ansible/hosts inventory source with ini plugin
 [WARNING]: provided hosts list is empty, only localhost is available. Note 
that the implicit localhost does not match 'all'

META: ran handlers
localhost | SUCCESS => {
    "msg": "<itertools.izip object at 0x7f1f2c3b55f0>"
}
META: ran handlers
META: ran handlers

Thanks Martin Hutchins <[email protected]> for the bug report.

Analysis:

This relates to the fix for CVE-2023-5764. The patch file doesn't
support python2. MRO for the affected class: (AnsibleUnsafeText,
unicode, AnsibleUnsafe, object) and none of these classes have a
__iter__ method in python 2.7.17

https://github.com/ansible/ansible/commit/7239d2d371bc6e274cbb7314e01431adce6ae25a#diff-65f6e2e7666c65b61d2dd334ca36e459e04854c3dc040e91c870886d01ce7aa7

Although the source code has logic for supporting older python versions
(and syntax also indicates similar support):
https://github.com/ansible/ansible/blob/7239d2d371bc6e274cbb7314e01431adce6ae25a/lib/ansible/module_utils/six/__init__.py#L49-L62

While it's setup.cfg doesn't: python_requires = >=3.9. So it's hard to
classify this as an upstream patch bug.

** Affects: ubuntu-pro
     Importance: Undecided
     Assignee: Vyom Yadav (vyomydv)
         Status: In Progress

** Affects: ansible (Ubuntu)
     Importance: High
     Assignee: Vyom Yadav (vyomydv)
         Status: In Progress

** Also affects: ubuntu-pro
   Importance: Undecided
       Status: New

** Changed in: ubuntu-pro
     Assignee: (unassigned) => Vyom Yadav (vyomydv)

** Changed in: ubuntu-pro
       Status: New => In Progress

** Changed in: ansible (Ubuntu)
       Status: New => In Progress

** Changed in: ansible (Ubuntu)
   Importance: Undecided => High

** Description changed:

  Ansible raises an exception when running list plugin:
  
  Version: 2.5.1+dfsg-1ubuntu0.1+esm3
  
  $ ansible -vvv -m debug -a msg="{{lookup('list', 'junk')|zip}}" localhost
  ansible 2.5.1
-   config file = /etc/ansible/ansible.cfg
-   configured module search path = [u'/home/vyom/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
-   ansible python module location = /usr/lib/python2.7/dist-packages/ansible
-   executable location = /usr/bin/ansible
-   python version = 2.7.17 (default, Nov 21 2024, 12:09:09) [GCC 7.5.0]
+   config file = /etc/ansible/ansible.cfg
+   configured module search path = [u'/home/vyom/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
+   ansible python module location = /usr/lib/python2.7/dist-packages/ansible
+   executable location = /usr/bin/ansible
+   python version = 2.7.17 (default, Nov 21 2024, 12:09:09) [GCC 7.5.0]
  Using /etc/ansible/ansible.cfg as config file
  Parsed /etc/ansible/hosts inventory source with ini plugin
-  [WARNING]: provided hosts list is empty, only localhost is available. Note 
that the implicit localhost does not match 'all'
+  [WARNING]: provided hosts list is empty, only localhost is available. Note 
that the implicit localhost does not match 'all'
  
  META: ran handlers
  The full traceback is:
  Traceback (most recent call last):
-   File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", 
line 138, in run
-     res = self._execute()
-   File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", 
line 503, in _execute
-     self._task.post_validate(templar=templar)
-   File "/usr/lib/python2.7/dist-packages/ansible/playbook/task.py", line 260, 
in post_validate
-     super(Task, self).post_validate(templar)
-   File "/usr/lib/python2.7/dist-packages/ansible/playbook/base.py", line 387, 
in post_validate
-     value = method(attribute, getattr(self, name), templar)
-   File "/usr/lib/python2.7/dist-packages/ansible/playbook/task.py", line 268, 
in _post_validate_args
-     args = templar.template(value)
-   File "/usr/lib/python2.7/dist-packages/ansible/template/__init__.py", line 
535, in template
-     disable_lookups=disable_lookups,
-   File "/usr/lib/python2.7/dist-packages/ansible/template/__init__.py", line 
491, in template
-     disable_lookups=disable_lookups,
-   File "/usr/lib/python2.7/dist-packages/ansible/template/__init__.py", line 
727, in do_template
-     res = j2_concat(rf)
-   File "<template>", line 12, in root
-   File "/usr/lib/python2.7/dist-packages/ansible/utils/unsafe_proxy.py", line 
91, in __iter__
-     return (cls(c) for c in super(AnsibleUnsafeText, self).__iter__())
+   File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", 
line 138, in run
+     res = self._execute()
+   File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", 
line 503, in _execute
+     self._task.post_validate(templar=templar)
+   File "/usr/lib/python2.7/dist-packages/ansible/playbook/task.py", line 260, 
in post_validate
+     super(Task, self).post_validate(templar)
+   File "/usr/lib/python2.7/dist-packages/ansible/playbook/base.py", line 387, 
in post_validate
+     value = method(attribute, getattr(self, name), templar)
+   File "/usr/lib/python2.7/dist-packages/ansible/playbook/task.py", line 268, 
in _post_validate_args
+     args = templar.template(value)
+   File "/usr/lib/python2.7/dist-packages/ansible/template/__init__.py", line 
535, in template
+     disable_lookups=disable_lookups,
+   File "/usr/lib/python2.7/dist-packages/ansible/template/__init__.py", line 
491, in template
+     disable_lookups=disable_lookups,
+   File "/usr/lib/python2.7/dist-packages/ansible/template/__init__.py", line 
727, in do_template
+     res = j2_concat(rf)
+   File "<template>", line 12, in root
+   File "/usr/lib/python2.7/dist-packages/ansible/utils/unsafe_proxy.py", line 
91, in __iter__
+     return (cls(c) for c in super(AnsibleUnsafeText, self).__iter__())
  AttributeError: 'super' object has no attribute '__iter__'
  
  localhost | FAILED! => {
-     "msg": "Unexpected failure during module execution.", 
-     "stdout": ""
+     "msg": "Unexpected failure during module execution.",
+     "stdout": ""
  }
  
  The problem is: AttributeError: 'super' object has no attribute
  '__iter__'
  
  This works fine on non esm version:
  
  Version: 2.5.1+dfsg-1ubuntu0.1
  
  $ ansible -vvv -m debug -a msg="{{lookup('list', 'junk')|zip}}" localhost
  ansible 2.5.1
-   config file = /etc/ansible/ansible.cfg
-   configured module search path = [u'/home/vyom/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
-   ansible python module location = /usr/lib/python2.7/dist-packages/ansible
-   executable location = /usr/bin/ansible
-   python version = 2.7.17 (default, Nov 21 2024, 12:09:09) [GCC 7.5.0]
+   config file = /etc/ansible/ansible.cfg
+   configured module search path = [u'/home/vyom/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
+   ansible python module location = /usr/lib/python2.7/dist-packages/ansible
+   executable location = /usr/bin/ansible
+   python version = 2.7.17 (default, Nov 21 2024, 12:09:09) [GCC 7.5.0]
  Using /etc/ansible/ansible.cfg as config file
  Parsed /etc/ansible/hosts inventory source with ini plugin
-  [WARNING]: provided hosts list is empty, only localhost is available. Note 
that the implicit localhost does not match 'all'
+  [WARNING]: provided hosts list is empty, only localhost is available. Note 
that the implicit localhost does not match 'all'
  
  META: ran handlers
  localhost | SUCCESS => {
-     "msg": "<itertools.izip object at 0x7f1f2c3b55f0>"
+     "msg": "<itertools.izip object at 0x7f1f2c3b55f0>"
  }
  META: ran handlers
  META: ran handlers
+ 
+ Thanks Martin Hutchins <[email protected]> for the bug report.
+ 
+ Analysis:
  
  This relates to the fix for CVE-2023-5764. The patch file doesn't
  support python2. MRO for the affected class: (AnsibleUnsafeText,
  unicode, AnsibleUnsafe, object) and none of these classes have a
  __iter__ method in python 2.7.17
  
  
https://github.com/ansible/ansible/commit/7239d2d371bc6e274cbb7314e01431adce6ae25a#diff-65f6e2e7666c65b61d2dd334ca36e459e04854c3dc040e91c870886d01ce7aa7
  
  Although the source code has logic for supporting older python versions
  (and syntax also indicates similar support):
  
https://github.com/ansible/ansible/blob/7239d2d371bc6e274cbb7314e01431adce6ae25a/lib/ansible/module_utils/six/__init__.py#L49-L62
  
  While it's setup.cfg doesn't: python_requires = >=3.9. So it's hard to
  classify this as an upstream patch bug.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2097504

Title:
  Ansible raises exception while invoking list plugin

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu-pro/+bug/2097504/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to