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

Adding a Network-Backed Serial Port Fails #1043

Closed
aj-cruz opened this issue Sep 21, 2021 · 3 comments · Fixed by #1055
Closed

Adding a Network-Backed Serial Port Fails #1043

aj-cruz opened this issue Sep 21, 2021 · 3 comments · Fixed by #1055
Assignees
Labels
bug This issue/PR relates to a bug has_pr needs_info This issue requires further information. Please answer any outstanding questions

Comments

@aj-cruz
Copy link

aj-cruz commented Sep 21, 2021

SUMMARY

Adding a serial port to a VM with backing_type = network fails with an error: KeyError: 'type'

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_guest_serial_port

ANSIBLE VERSION
ansible [core 2.11.5] 
  config file = /home/aj/projects/ansible/vxlan-lab/ansible.cfg
  configured module search path = ['/home/aj/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/aj/projects/ansible/vxlan-lab/venv-vxlan-ansible/lib/python3.8/site-packages/ansible
  ansible collection location = /home/aj/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/aj/projects/ansible/vxlan-lab/venv-vxlan-ansible/bin/ansible
  python version = 3.8.10 (default, Jun  2 2021, 10:49:15) [GCC 9.4.0]
  jinja version = 3.0.1
  libyaml = True
COLLECTION VERSION
# /home/aj/projects/ansible/vxlan-lab/venv-vxlan-ansible/lib/python3.8/site-packages/ansible_collections
Collection       Version
---------------- -------
community.vmware 1.13.0 

# /home/aj/.ansible/collections/ansible_collections
Collection       Version
---------------- -------
community.vmware 1.14.0 
CONFIGURATION
DEFAULT_FILTER_PLUGIN_PATH(/home/aj/projects/ansible/vxlan-lab/ansible.cfg) = ['/home/aj/projects/ansible/vxlan-lab/roles/vmware.networking/plugins/filter']
OS / ENVIRONMENT

WSL2 (Ubuntu)

STEPS TO REPRODUCE

ansible-playbook playbook.yml

- name: Add Serial Console Port on All Switches
    community.vmware.vmware_guest_serial_port:
      <<: *vsphere_login
      name: '{{ item.vm }}'
      backings:
        - backing_type: network
          direction: server
          service_uri: 'telnet://192.168.253.4:{{ item.telnet_port }}'
          yield_on_poll: yes
          state: present
    loop:
      - vm: Ansible-DC1-SPINE
        telnet_port: 2100
      - vm: Ansible-DC1-LEAF1
        telnet_port: 2101
EXPECTED RESULTS

Serial Port Created

ACTUAL RESULTS
(venv-vxlan-ansible) aj@USHY-bzNWdTYduw:~/projects/ansible/vxlan-lab$ ansible-playbook -i inventory.yml playbook.yml -vvvv
ansible-playbook [core 2.11.5] 
  config file = /home/aj/projects/ansible/vxlan-lab/ansible.cfg
  configured module search path = ['/home/aj/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/aj/projects/ansible/vxlan-lab/venv-vxlan-ansible/lib/python3.8/site-packages/ansible
  ansible collection location = /home/aj/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/aj/projects/ansible/vxlan-lab/venv-vxlan-ansible/bin/ansible-playbook
  python version = 3.8.10 (default, Jun  2 2021, 10:49:15) [GCC 9.4.0]
  jinja version = 3.0.1
  libyaml = True
Using /home/aj/projects/ansible/vxlan-lab/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /home/aj/projects/ansible/vxlan-lab/inventory.yml as it did not pass its verify_file() method
script declined parsing /home/aj/projects/ansible/vxlan-lab/inventory.yml as it did not pass its verify_file() method
Parsed /home/aj/projects/ansible/vxlan-lab/inventory.yml inventory source with yaml plugin
Loading collection community.vmware from /home/aj/.ansible/collections/ansible_collections/community/vmware
statically imported: /home/aj/projects/ansible/vxlan-lab/roles/vmware.guest_provisioning/tasks/nxos_vm_settings.yml
Loading callback plugin default of type stdout, v2.0 from /home/aj/projects/ansible/vxlan-lab/venv-vxlan-ansible/lib/python3.8/site-packages/ansible/plugins/callback/default.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: playbook.yml ***********************************************************************************************************************************************************************************************************************************************************
Positional arguments: playbook.yml
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/home/aj/projects/ansible/vxlan-lab/inventory.yml',)
forks: 5
1 plays in playbook.yml

PLAY [Deploy Lab VMs] ************************************************************************************************************************************************************************************************************************************************************
META: ran handlers

TASK [vmware.guest_provisioning : Add Serial Console Port on All Switches] *******************************************************************************************************************************************************************************************************
task path: /home/aj/projects/ansible/vxlan-lab/roles/vmware.guest_provisioning/tasks/nxos_vm_settings.yml:69
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: aj
<localhost> EXEC /bin/sh -c 'echo ~aj && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/aj/.ansible/tmp `"&& mkdir "` echo /home/aj/.ansible/tmp/ansible-tmp-1632188691.9711795-23734-59241131083335 `" && echo ansible-tmp-1632188691.9711795-23734-59241131083335="` echo /home/aj/.ansible/tmp/ansible-tmp-1632188691.9711795-23734-59241131083335 `" ) && sleep 0'
Using module file /home/aj/.ansible/collections/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py
<localhost> PUT /home/aj/.ansible/tmp/ansible-local-237294w7ghi_f/tmp2jsj262j TO /home/aj/.ansible/tmp/ansible-tmp-1632188691.9711795-23734-59241131083335/AnsiballZ_vmware_guest_serial_port.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/aj/.ansible/tmp/ansible-tmp-1632188691.9711795-23734-59241131083335/ /home/aj/.ansible/tmp/ansible-tmp-1632188691.9711795-23734-59241131083335/AnsiballZ_vmware_guest_serial_port.py && sleep 0'
<localhost> EXEC /bin/sh -c '/home/aj/projects/ansible/vxlan-lab/venv-vxlan-ansible/bin/python3 /home/aj/.ansible/tmp/ansible-tmp-1632188691.9711795-23734-59241131083335/AnsiballZ_vmware_guest_serial_port.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/aj/.ansible/tmp/ansible-tmp-1632188691.9711795-23734-59241131083335/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/home/aj/.ansible/tmp/ansible-tmp-1632188691.9711795-23734-59241131083335/AnsiballZ_vmware_guest_serial_port.py", line 100, in <module>
    _ansiballz_main()
  File "/home/aj/.ansible/tmp/ansible-tmp-1632188691.9711795-23734-59241131083335/AnsiballZ_vmware_guest_serial_port.py", line 92, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/aj/.ansible/tmp/ansible-tmp-1632188691.9711795-23734-59241131083335/AnsiballZ_vmware_guest_serial_port.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.community.vmware.plugins.modules.vmware_guest_serial_port', init_globals=dict(_module_fqn='ansible_collections.community.vmware.plugins.modules.vmware_guest_serial_port', _modlib_path=modlib_path),
  File "/usr/lib/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_8howb0cj/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py", line 548, in <module>
  File "/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_8howb0cj/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py", line 532, in main
  File "/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_8howb0cj/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py", line 267, in reconfigure_vm_serial_port
  File "/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_8howb0cj/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py", line 258, in get_serial_port_config_spec
  File "/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_8howb0cj/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py", line 371, in create_serial_port
KeyError: 'type'
failed: [vcenter -> localhost] (item={'vm': 'Ansible-DC1-SPINE', 'telnet_port': 2100}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": {
        "telnet_port": 2100,
        "vm": "Ansible-DC1-SPINE"
    },
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/aj/.ansible/tmp/ansible-tmp-1632188691.9711795-23734-59241131083335/AnsiballZ_vmware_guest_serial_port.py\", line 100, in <module>\n    _ansiballz_main()\n  File \"/home/aj/.ansible/tmp/ansible-tmp-1632188691.9711795-23734-59241131083335/AnsiballZ_vmware_guest_serial_port.py\", line 92, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/aj/.ansible/tmp/ansible-tmp-1632188691.9711795-23734-59241131083335/AnsiballZ_vmware_guest_serial_port.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.community.vmware.plugins.modules.vmware_guest_serial_port', init_globals=dict(_module_fqn='ansible_collections.community.vmware.plugins.modules.vmware_guest_serial_port', _modlib_path=modlib_path),\n  File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_8howb0cj/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py\", line 548, in <module>\n  File \"/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_8howb0cj/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py\", line 532, in main\n  File \"/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_8howb0cj/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py\", line 267, in reconfigure_vm_serial_port\n  File \"/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_8howb0cj/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py\", line 258, in get_serial_port_config_spec\n  File \"/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_8howb0cj/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py\", line 371, in create_serial_port\nKeyError: 'type'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}
<localhost> EXEC /bin/sh -c 'echo ~aj && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/aj/.ansible/tmp `"&& mkdir "` echo /home/aj/.ansible/tmp/ansible-tmp-1632188692.9521089-23734-228995616558622 `" && echo ansible-tmp-1632188692.9521089-23734-228995616558622="` echo /home/aj/.ansible/tmp/ansible-tmp-1632188692.9521089-23734-228995616558622 `" ) && sleep 0'
Using module file /home/aj/.ansible/collections/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py
<localhost> PUT /home/aj/.ansible/tmp/ansible-local-237294w7ghi_f/tmpthk6kllc TO /home/aj/.ansible/tmp/ansible-tmp-1632188692.9521089-23734-228995616558622/AnsiballZ_vmware_guest_serial_port.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/aj/.ansible/tmp/ansible-tmp-1632188692.9521089-23734-228995616558622/ /home/aj/.ansible/tmp/ansible-tmp-1632188692.9521089-23734-228995616558622/AnsiballZ_vmware_guest_serial_port.py && sleep 0'
<localhost> EXEC /bin/sh -c '/home/aj/projects/ansible/vxlan-lab/venv-vxlan-ansible/bin/python3 /home/aj/.ansible/tmp/ansible-tmp-1632188692.9521089-23734-228995616558622/AnsiballZ_vmware_guest_serial_port.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/aj/.ansible/tmp/ansible-tmp-1632188692.9521089-23734-228995616558622/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/home/aj/.ansible/tmp/ansible-tmp-1632188692.9521089-23734-228995616558622/AnsiballZ_vmware_guest_serial_port.py", line 100, in <module>
    _ansiballz_main()
  File "/home/aj/.ansible/tmp/ansible-tmp-1632188692.9521089-23734-228995616558622/AnsiballZ_vmware_guest_serial_port.py", line 92, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/aj/.ansible/tmp/ansible-tmp-1632188692.9521089-23734-228995616558622/AnsiballZ_vmware_guest_serial_port.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.community.vmware.plugins.modules.vmware_guest_serial_port', init_globals=dict(_module_fqn='ansible_collections.community.vmware.plugins.modules.vmware_guest_serial_port', _modlib_path=modlib_path),
  File "/usr/lib/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_6w84zbdb/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py", line 548, in <module>
  File "/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_6w84zbdb/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py", line 532, in main
  File "/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_6w84zbdb/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py", line 267, in reconfigure_vm_serial_port
  File "/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_6w84zbdb/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py", line 258, in get_serial_port_config_spec
  File "/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_6w84zbdb/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py", line 371, in create_serial_port
KeyError: 'type'
failed: [vcenter -> localhost] (item={'vm': 'Ansible-DC1-LEAF1', 'telnet_port': 2101}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": {
        "telnet_port": 2101,
        "vm": "Ansible-DC1-LEAF1"
    },
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/aj/.ansible/tmp/ansible-tmp-1632188692.9521089-23734-228995616558622/AnsiballZ_vmware_guest_serial_port.py\", line 100, in <module>\n    _ansiballz_main()\n  File \"/home/aj/.ansible/tmp/ansible-tmp-1632188692.9521089-23734-228995616558622/AnsiballZ_vmware_guest_serial_port.py\", line 92, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/aj/.ansible/tmp/ansible-tmp-1632188692.9521089-23734-228995616558622/AnsiballZ_vmware_guest_serial_port.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.community.vmware.plugins.modules.vmware_guest_serial_port', init_globals=dict(_module_fqn='ansible_collections.community.vmware.plugins.modules.vmware_guest_serial_port', _modlib_path=modlib_path),\n  File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_6w84zbdb/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py\", line 548, in <module>\n  File \"/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_6w84zbdb/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py\", line 532, in main\n  File \"/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_6w84zbdb/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py\", line 267, in reconfigure_vm_serial_port\n  File \"/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_6w84zbdb/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py\", line 258, in get_serial_port_config_spec\n  File \"/tmp/ansible_community.vmware.vmware_guest_serial_port_payload_6w84zbdb/ansible_community.vmware.vmware_guest_serial_port_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest_serial_port.py\", line 371, in create_serial_port\nKeyError: 'type'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

PLAY RECAP ***********************************************************************************************************************************************************************************************************************************************************************
vcenter                    : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0 
Akasurde added a commit to Akasurde/community.vmware that referenced this issue Sep 27, 2021
@Akasurde
Copy link
Member

@aj-cruz Could you please check if #1055 solves your problem and let me know? Thanks.

@Akasurde Akasurde added the bug This issue/PR relates to a bug label Sep 27, 2021
@Akasurde Akasurde self-assigned this Sep 27, 2021
Akasurde added a commit to Akasurde/community.vmware that referenced this issue Sep 27, 2021
@mariolenz
Copy link
Collaborator

@aj-cruz Did you find the time to test #1055? Does it solve your problem?

@mariolenz mariolenz added has_pr needs_info This issue requires further information. Please answer any outstanding questions labels Oct 19, 2021
@aj-cruz
Copy link
Author

aj-cruz commented Nov 1, 2021

@Akasurde @mariolenz Sorry, for some reason I didn't receive notification of a message until the pull request was approved. I'll test this today. Thanks.

ansible-zuul bot pushed a commit that referenced this issue Nov 2, 2021
vmware_guest_serial_port: Handle serial backing type

SUMMARY
Fixes: #1043
Signed-off-by: Abhijeet Kasurde [email protected]
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
changelogs/fragments/1043_vmware_guest_serial.yml
plugins/modules/vmware_guest_serial_port.py

Reviewed-by: Mario Lenz <[email protected]>
Reviewed-by: None <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_pr needs_info This issue requires further information. Please answer any outstanding questions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants