CiscoUcs / ucsm-ansible

Ansible Modules for Cisco Ucs Managed Blade and Rack servers.
59 stars 43 forks source link

ucs_vnic_template fails with UCS Platform Emulator 3.1 #76

Closed ghost closed 6 years ago

ghost commented 6 years ago

The UCS platform emulator does not support configuring a "Redundancy Type". Screenshot linked below. The ucs_vnic_template module fails as a result. I've removed all references to redundancy type in the code for testing although is it possible to remove this option as mandatory, therefore the code wouldn't need to be modified in order for the module to work in a lab environment.

https://imgur.com/hDGcd1F

dsoper2 commented 6 years ago

Just replied on the other issue as well - can you share the playbook you're using and version of UCSM (or UCSPE) being tested?

ghost commented 6 years ago

Playbook below. I'm using Cisco UCS Platform Emulator version 3.1(2ePE1). My production UCS managers do have an option for "Redundancy Type", so the module would most likely work, although I need to test all playbooks in the lab before I can move them into production.

---
- name: UCS VLANs
  hosts: lab-tor-ucs
  tasks:
    - name: Configure VLANs
      ucs_vlans:
        hostname: 10.71.254.250
        username: ucspe
        password: ucspe
        state: "{{ item.state }}"
        name: "{{ item.name }}"
        id: "{{ item.id }}"
      with_items: "{{ vlans }}"
    - name: Add VLAN to Fabric A vNIC Template
      ucs_vnic_template:
        hostname: 10.71.254.250
        username: ucspe
        password: ucspe
        name: Fabric-A
        fabric: A
        mtu: 9000
        target: adapter
        template_type: updating-template
        #redundancy_type: none
        vlans_list:
          - name: "{{ item.name }}"
      with_items: "{{ vlans }}"
    - name: Add VLAN to Fabric B vNIC Template
      ucs_vnic_template:
        hostname: 10.71.254.250
        username: ucspe
        password: ucspe
        name: Fabric-B
        fabric: B
        mtu: 9000
        target: adapter
        template_type: updating-template
        #redundancy_type: none
        vlans_list:
          - name: "{{ item.name }}"
      with_items: "{{ vlans }}"

Vlans located in group_vars/lab-tor-ucs

---
vlans:
  - id: 10
    name: WEB
    state: present
  - id: 20
    name: APP
    state: present
  - id: 30
    name: SQL
    state: present
  - id: 100
    name: TEST
    state: present
dsoper2 commented 6 years ago

Can you send ansible --version and verbose output (-vvv)? Redundancy templates look ok to me with UCSPE 3.1(2e) image And the CiscoUcs.ucs Ansible role (available on Ansible Galaxy) is successfully configuring VNIC templates in UCSPE 3.1(2e). Here's verbose output: ansible-playbook 2.5.1 config file = /Users/dsoper/.ansible.cfg configured module search path = ['/Users/dsoper/Documents/ucsm-ansible-1/library', '/Users/dsoper/Documents/intersight-ansible', '/Users/dsoper/Documents/imc-ansible'] ansible python module location = /usr/local/lib/python3.6/site-packages/ansible executable location = /usr/local/bin/ansible-playbook python version = 3.6.5 (default, Apr 20 2018, 18:22:17) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] Using /Users/dsoper/.ansible.cfg as config file Parsed /Users/dsoper/Documents/ucsm-ansible-1/inventories/ucspe inventory source with ini plugin

PLAYBOOK: cvd_roles.yml **** 1 plays in playbooks/cvd_roles.yml

PLAY [ucspe_remote] **** META: ran handlers

TASK [Set ucs_hostname] **** task path: /Users/dsoper/Documents/ucsm-ansible-1/playbooks/cvd_roles.yml:17 skipping: [ucspe_3_1_2e:] => { "changed": false, "skip_reason": "Conditional result was False" }

TASK [include_role] **** task path: /Users/dsoper/Documents/ucsm-ansible-1/playbooks/cvd_roles.yml:21

TASK [CiscoUcs.ucs/lan/vnic_templates : Configure vNIC Templates] ** task path: /Users/dsoper/.ansible/roles/CiscoUcs.ucs/lan/vnic_templates/tasks/main.yml:13 Using module file /Users/dsoper/Documents/ucsm-ansible-1/library/ucs_vnic_template.py

ESTABLISH LOCAL CONNECTION FOR USER: dsoper EXEC /bin/sh -c 'echo ~ && sleep 0' EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/dsoper/.ansible/tmp/ansible-tmp-1528413369.022986-118127893556736 `" && echo ansible-tmp-1528413369.022986-118127893556736="` echo /Users/dsoper/.ansible/tmp/ansible-tmp-1528413369.022986-118127893556736 `" ) && sleep 0' PUT /Users/dsoper/.ansible/tmp/ansible-local-71692r0rclt7s/tmpkvbifdks TO /Users/dsoper/.ansible/tmp/ansible-tmp-1528413369.022986-118127893556736/ucs_vnic_template.py EXEC /bin/sh -c 'chmod u+x /Users/dsoper/.ansible/tmp/ansible-tmp-1528413369.022986-118127893556736/ /Users/dsoper/.ansible/tmp/ansible-tmp-1528413369.022986-118127893556736/ucs_vnic_template.py && sleep 0' EXEC /bin/sh -c '/usr/bin/python /Users/dsoper/.ansible/tmp/ansible-tmp-1528413369.022986-118127893556736/ucs_vnic_template.py && sleep 0' EXEC /bin/sh -c 'rm -f -r /Users/dsoper/.ansible/tmp/ansible-tmp-1528413369.022986-118127893556736/ > /dev/null 2>&1 && sleep 0' changed: [ucspe_3_1_2e:] => (item={'name': 'Cntr-Template', 'fabric': 'A-B', 'template_type': 'updating-template', 'mac_pool': 'MAC-Pool-A', 'network_control_policy': 'Enable-CDP-LLDP', 'vlans_list': [{'name': 'Container-MGMT-VLAN', 'native': 'yes'}]}) => { "changed": true, "invocation": { "module_args": { "cdn_name": "", "cdn_source": "vnic-name", "description": "", "fabric": "A-B", "hostname": "172.22.249.124", "mac_pool": "MAC-Pool-A", "mtu": "1500", "name": "Cntr-Template", "network_control_policy": "Enable-CDP-LLDP", "org_dn": "org-root", "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "peer_redundancy_template": "", "pin_group": "", "port": null, "proxy": null, "qos_policy": "", "redundancy_type": "none", "state": "present", "stats_policy": "default", "target": "adaptor", "template_type": "updating-template", "use_proxy": true, "use_ssl": true, "username": "admin", "vlans_list": [ { "name": "Container-MGMT-VLAN", "native": "yes" } ] } }, "item": { "fabric": "A-B", "mac_pool": "MAC-Pool-A", "name": "Cntr-Template", "network_control_policy": "Enable-CDP-LLDP", "template_type": "updating-template", "vlans_list": [ { "name": "Container-MGMT-VLAN", "native": "yes" } ] } } Using module file /Users/dsoper/Documents/ucsm-ansible-1/library/ucs_vnic_template.py EXEC /bin/sh -c 'echo ~ && sleep 0' EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/dsoper/.ansible/tmp/ansible-tmp-1528413372.075377-156899780380355 `" && echo ansible-tmp-1528413372.075377-156899780380355="` echo /Users/dsoper/.ansible/tmp/ansible-tmp-1528413372.075377-156899780380355 `" ) && sleep 0' PUT /Users/dsoper/.ansible/tmp/ansible-local-71692r0rclt7s/tmpeuau0xs8 TO /Users/dsoper/.ansible/tmp/ansible-tmp-1528413372.075377-156899780380355/ucs_vnic_template.py EXEC /bin/sh -c 'chmod u+x /Users/dsoper/.ansible/tmp/ansible-tmp-1528413372.075377-156899780380355/ /Users/dsoper/.ansible/tmp/ansible-tmp-1528413372.075377-156899780380355/ucs_vnic_template.py && sleep 0' EXEC /bin/sh -c '/usr/bin/python /Users/dsoper/.ansible/tmp/ansible-tmp-1528413372.075377-156899780380355/ucs_vnic_template.py && sleep 0' EXEC /bin/sh -c 'rm -f -r /Users/dsoper/.ansible/tmp/ansible-tmp-1528413372.075377-156899780380355/ > /dev/null 2>&1 && sleep 0' changed: [ucspe_3_1_2e:] => (item={'name': 'Container-NFS-A', 'fabric': 'A', 'redundancy_type': 'primary', 'peer_redundancy_templ': 'Container-NFS-B', 'template_type': 'updating-template', 'mtu': '9000', 'mac_pool': 'MAC-Pool-A', 'network_control_policy': 'Enable-CDP-LLDP', 'vlans_list': [{'name': 'Container-MGMT-NFS', 'native': 'yes'}, {'name': 'Container-TNT-A-NFS', 'native': 'no'}]}) => { "changed": true, "invocation": { "module_args": { "cdn_name": "", "cdn_source": "vnic-name", "description": "", "fabric": "A", "hostname": "172.22.249.124", "mac_pool": "MAC-Pool-A", "mtu": "9000", "name": "Container-NFS-A", "network_control_policy": "Enable-CDP-LLDP", "org_dn": "org-root", "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "peer_redundancy_templ": "Container-NFS-B", "peer_redundancy_template": "Container-NFS-B", "pin_group": "", "port": null, "proxy": null, "qos_policy": "", "redundancy_type": "primary", "state": "present", "stats_policy": "default", "target": "adaptor", "template_type": "updating-template", "use_proxy": true, "use_ssl": true, "username": "admin", "vlans_list": [ { "name": "Container-MGMT-NFS", "native": "yes" }, { "name": "Container-TNT-A-NFS", "native": "no" } ] } }, "item": { "fabric": "A", "mac_pool": "MAC-Pool-A", "mtu": "9000", "name": "Container-NFS-A", "network_control_policy": "Enable-CDP-LLDP", "peer_redundancy_templ": "Container-NFS-B", "redundancy_type": "primary", "template_type": "updating-template", "vlans_list": [ { "name": "Container-MGMT-NFS", "native": "yes" }, { "name": "Container-TNT-A-NFS", "native": "no" } ] } } Using module file /Users/dsoper/Documents/ucsm-ansible-1/library/ucs_vnic_template.py EXEC /bin/sh -c 'echo ~ && sleep 0' EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/dsoper/.ansible/tmp/ansible-tmp-1528413374.68146-76389097931691 `" && echo ansible-tmp-1528413374.68146-76389097931691="` echo /Users/dsoper/.ansible/tmp/ansible-tmp-1528413374.68146-76389097931691 `" ) && sleep 0' PUT /Users/dsoper/.ansible/tmp/ansible-local-71692r0rclt7s/tmpl29jqnmq TO /Users/dsoper/.ansible/tmp/ansible-tmp-1528413374.68146-76389097931691/ucs_vnic_template.py EXEC /bin/sh -c 'chmod u+x /Users/dsoper/.ansible/tmp/ansible-tmp-1528413374.68146-76389097931691/ /Users/dsoper/.ansible/tmp/ansible-tmp-1528413374.68146-76389097931691/ucs_vnic_template.py && sleep 0' EXEC /bin/sh -c '/usr/bin/python /Users/dsoper/.ansible/tmp/ansible-tmp-1528413374.68146-76389097931691/ucs_vnic_template.py && sleep 0' EXEC /bin/sh -c 'rm -f -r /Users/dsoper/.ansible/tmp/ansible-tmp-1528413374.68146-76389097931691/ > /dev/null 2>&1 && sleep 0' changed: [ucspe_3_1_2e:] => (item={'name': 'Container-NFS-B', 'fabric': 'B', 'redundancy_type': 'secondary', 'peer_redundancy_templ': 'Container-NFS-A', 'mac_pool': 'MAC-Pool-B'}) => { "changed": true, "invocation": { "module_args": { "cdn_name": "", "cdn_source": "vnic-name", "description": "", "fabric": "B", "hostname": "172.22.249.124", "mac_pool": "MAC-Pool-B", "mtu": "1500", "name": "Container-NFS-B", "network_control_policy": "", "org_dn": "org-root", "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "peer_redundancy_templ": "Container-NFS-A", "peer_redundancy_template": "Container-NFS-A", "pin_group": "", "port": null, "proxy": null, "qos_policy": "", "redundancy_type": "secondary", "state": "present", "stats_policy": "default", "target": "adaptor", "template_type": "initial-template", "use_proxy": true, "use_ssl": true, "username": "admin", "vlans_list": null } }, "item": { "fabric": "B", "mac_pool": "MAC-Pool-B", "name": "Container-NFS-B", "peer_redundancy_templ": "Container-NFS-A", "redundancy_type": "secondary" } }
ghost commented 6 years ago

One correction, I'm using UCS Platform Emulator version 3.1(1e), as I'm not able to get 3.1(2ePE1) talking on port 80/443.

Below is the playbook output. If I remove all references to redundancy_type in the module code the playbook works fine.

ansible-playbook 2.5.4
config file = /localservices/ansible/ansible.cfg ansible python module location = /usr/lib/python2.7/dist-packages/ansible executable location = /usr/bin/ansible-playbook python version = 2.7.9 (default, Jun 29 2016, 13:08:31) [GCC 4.9.2] Using /localservices/ansible/ansible.cfg as config file Parsed /localservices/ansible/inventory/lab inventory source with ini plugin

PLAYBOOK: lab-ucs-vlan-ucspe2.yml *** 1 plays in lab-ucs-vlan-ucspe2.yml

PLAY [UCS VLANs] **** META: ran handlers

TASK [Add VLAN to Fabric A vNIC Template] *** task path: /localservices/ansible/lab-ucs-vlan-ucspe2.yml:17 Using module file /usr/lib/python2.7/dist-packages/ansible/modules/remote_management/ucs/ucs_vnic_template.py <10.71.254.250> ESTABLISH LOCAL CONNECTION FOR USER: minimalz <10.71.254.250> EXEC /bin/sh -c '/usr/bin/python && sleep 0' The full traceback is: File "/tmp/ansible_TMWRg3/ansible_module_ucs_vnic_template.py", line 331, in main ucs.login_handle.commit() File "/usr/local/lib/python2.7/dist-packages/ucsmsdk/ucshandle.py", line 939, in commit response = self.post_elem(elem, timeout=timeout) File "/usr/local/lib/python2.7/dist-packages/ucsmsdk/ucssession.py", line 318, in post_elem response = xc.from_xml_str(response_str, self) File "/usr/local/lib/python2.7/dist-packages/ucsmsdk/ucsxmlcodec.py", line 94, in from_xml_str raise ex.UcsException(error_code, error_descr)

fatal: [lab-ucs]: FAILED! => changed=false invocation: module_args: cdn_name: '' cdn_source: vnic-name description: '' fabric: A hostname: 10.71.254.250 mac_pool: '' mtu: '9000' name: Fabric-A network_control_policy: '' org_dn: org-root password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER peer_redundancy_template: '' pin_group: '' port: null proxy: null qos_policy: '' redundancy_type: none state: present stats_policy: default target: adaptor template_type: updating-template use_proxy: true use_ssl: true username: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER vlans_list:

PLAY RECAP ** lab-ucs : ok=0 changed=0 unreachable=0 failed=1

ghost commented 6 years ago

We were able deploy a working 3.1(2ePE1) emulator at another site. This version does have a Redundancy Type option in the vNIC configuration, therefore the playbook works fine. Version 3.1(1e) of the emulator omits the Redundancy Type (https://imgur.com/hDGcd1F) therefore the playbook was failing whether the parameter was defined or not. We'll stop using 3.1(1e) in our labs.