Bug 1727813

Summary: TypeError: argument of type 'int' is not iterable, as vlanid (int) is not changed into string
Product: [Fedora] Fedora Reporter: Masahiro Matsuya <mmatsuya>
Component: ansibleAssignee: Kevin Fenzi <kevin>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 30CC: a.badger, athmanem, kevin, maxim, yaneti
Target Milestone: ---Keywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: ansible-2.8.6-1.fc31 ansible-2.8.6-1.fc29 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-06 13:45:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Masahiro Matsuya 2019-07-08 08:53:05 UTC
Description of problem:

I tried to configure vlan, and I got the following error.


fatal: [192.168.122.215]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "module_stderr": "Shared connection to 192.168.122.215 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1562572575.7791524-180821907536373/AnsiballZ_nmcli.py\", line 114, in <module>\r\n    _ansiballz_main()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1562572575.7791524-180821907536373/AnsiballZ_nmcli.py\", line 106, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/root/.ansible/tmp/ansible-tmp-1562572575.7791524-180821907536373/AnsiballZ_nmcli.py\", line 49, in invoke_module\r\n    imp.load_module('__main__', mod, module, MOD_DESC)\r\n  File \"/tmp/ansible_nmcli_payload_qP0vS5/__main__.py\", line 1549, in <module>\r\n  File \"/tmp/ansible_nmcli_payload_qP0vS5/__main__.py\", line 1527, in main\r\n  File \"/tmp/ansible_nmcli_payload_qP0vS5/__main__.py\", line 1425, in modify_connection\r\n  File \"/tmp/ansible_nmcli_payload_qP0vS5/__main__.py\", line 682, in execute_command\r\n  File \"/tmp/ansible_nmcli_payload_qP0vS5/ansible_nmcli_payload.zip/ansible/module_utils/basic.py\", line 2477, in run_command\r\n  File \"/usr/lib64/python2.7/posixpath.py\", line 293, in expandvars\r\n    if '$' not in path:\r\nTypeError: argument of type 'int' is not iterable\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}


$ cat vlan_test1.yaml
- hosts: targets
  gather_facts: no
  remote_user: root
  tasks:
  - name: Add Vlan 120
    nmcli:
      type: vlan
      conn_name: vlan120-eth1
      vlanid: 120
      vlandev: eth1
      ip4: 192.168.140.100/24
      state: present

The root cause is because vlanid was added into command args array as integer.
vlanid is the integer type. It should be changed into a string to make the command args array. The following is my proposed patch.


$ gendiff /usr/lib/python3.7/site-packages/ansible/modules/net_tools .original
diff -up /usr/lib/python3.7/site-packages/ansible/modules/net_tools/nmcli.py.original /usr/lib/python3.7/site-packages/ansible/modules/net_tools/nmcli.py
--- /usr/lib/python3.7/site-packages/ansible/modules/net_tools/nmcli.py.original	2019-07-08 16:51:25.282282730 +0900
+++ /usr/lib/python3.7/site-packages/ansible/modules/net_tools/nmcli.py	2019-07-08 17:48:34.081422730 +0900
@@ -1145,7 +1145,7 @@ class Nmcli(object):
             cmd.append('vlan%s' % self.vlanid)
 
         params = {'dev': self.vlandev,
-                  'id': self.vlanid,
+                  'id': str(self.vlanid),
                   'ip4': self.ip4 or '',
                   'gw4': self.gw4 or '',
                   'ip6': self.ip6 or '',
@@ -1170,7 +1170,7 @@ class Nmcli(object):
             cmd.append('vlan%s' % self.vlanid)
 
         params = {'vlan.parent': self.vlandev,
-                  'vlan.id': self.vlanid,
+                  'vlan.id': str(self.vlanid),
                   'ipv4.address': self.ip4 or '',
                   'ipv4.gateway': self.gw4 or '',
                   'ipv4.dns': self.dns4 or '',

Version-Release number of selected component (if applicable):
Fedora 30

How reproducible:
Always

Steps to Reproduce:
1. run a ansible playbook to create a new vlan. See above example.


Actual results:
ansible-playbook failed

Expected results:
ansible-playbook doesn't fail.

Additional info:

Comment 1 Kevin Fenzi 2019-07-10 20:32:58 UTC
Thanks for the debugging and patch. 

Would you be willing to file this upstream at https://github.com/ansible/ansible ?

Comment 2 Masahiro Matsuya 2019-07-11 02:47:09 UTC
Hi Kevin,

OK, I filed it here: https://github.com/ansible/ansible/issues/58949

Thanks!

Comment 3 Fedora Update System 2019-10-29 17:14:14 UTC
FEDORA-2019-a9195834a9 has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-a9195834a9

Comment 4 Fedora Update System 2019-10-29 17:14:20 UTC
FEDORA-2019-5f9a9b20f3 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-5f9a9b20f3

Comment 5 Fedora Update System 2019-10-30 01:19:55 UTC
ansible-2.8.6-1.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-a9195834a9

Comment 6 Fedora Update System 2019-10-30 01:34:23 UTC
ansible-2.8.6-1.fc31 has been pushed to the Fedora 31 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-355f9240c5

Comment 7 Fedora Update System 2019-10-30 02:40:32 UTC
ansible-2.8.6-1.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-5f9a9b20f3

Comment 8 Fedora Update System 2019-11-02 18:57:42 UTC
FEDORA-2019-355f9240c5 has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2019-355f9240c5

Comment 9 Fedora Update System 2019-11-02 18:58:17 UTC
FEDORA-2019-a9195834a9 has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-a9195834a9

Comment 10 Fedora Update System 2019-11-02 18:58:39 UTC
FEDORA-2019-5f9a9b20f3 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-5f9a9b20f3

Comment 11 Fedora Update System 2019-11-04 02:09:23 UTC
ansible-2.8.6-1.fc30, ansible-lint-4.1.1a0-4.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-a9195834a9

Comment 12 Fedora Update System 2019-11-04 02:18:13 UTC
ansible-2.8.6-1.fc31, ansible-lint-4.1.1a0-4.fc31 has been pushed to the Fedora 31 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-355f9240c5

Comment 13 Fedora Update System 2019-11-04 04:12:40 UTC
ansible-2.8.6-1.fc29, ansible-lint-4.1.1a0-4.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-5f9a9b20f3

Comment 14 Fedora Update System 2019-11-06 13:45:03 UTC
ansible-2.8.6-1.fc31, ansible-lint-4.1.1a0-4.fc31 has been pushed to the Fedora 31 stable repository. If problems still persist, please make note of it in this bug report.

Comment 15 Fedora Update System 2019-11-11 17:39:36 UTC
ansible-2.8.6-1.fc29, ansible-lint-4.1.1a0-4.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.