{"action":"opened","issue":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/4464","repository_url":"https://api.github.com/repos/ansible/ansible-modules-core","labels_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/4464/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/4464/comments","events_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/4464/events","html_url":"https://github.com/ansible/ansible-modules-core/issues/4464","id":171896622,"number":4464,"title":"Cannot configure NX-OS device with nxos_command in CLI/SSH nor NX-API transport","user":{"login":"jean-christophe-manciot","id":13176858,"avatar_url":"https://avatars.githubusercontent.com/u/13176858?v=3","gravatar_id":"","url":"https://api.github.com/users/jean-christophe-manciot","html_url":"https://github.com/jean-christophe-manciot","followers_url":"https://api.github.com/users/jean-christophe-manciot/followers","following_url":"https://api.github.com/users/jean-christophe-manciot/following{/other_user}","gists_url":"https://api.github.com/users/jean-christophe-manciot/gists{/gist_id}","starred_url":"https://api.github.com/users/jean-christophe-manciot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jean-christophe-manciot/subscriptions","organizations_url":"https://api.github.com/users/jean-christophe-manciot/orgs","repos_url":"https://api.github.com/users/jean-christophe-manciot/repos","events_url":"https://api.github.com/users/jean-christophe-manciot/events{/privacy}","received_events_url":"https://api.github.com/users/jean-christophe-manciot/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-18T13:08:35Z","updated_at":"2016-08-18T13:08:35Z","closed_at":null,"body":"##### ISSUE TYPE\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\nnxos_command\r\n\r\n##### ANSIBLE VERSION\r\n```\r\nansible --version\r\nansible 2.1.1.0\r\n```\r\n\r\n##### CONFIGURATION\r\n```\r\ninventory      = ./hosts\r\ngathering      = explicit\r\nroles_path    = /home/actionmystique/Program-Files/Ubuntu/Ansible/git-Ansible/roles\r\nprivate_role_vars = yes\r\nlog_path = /var/log/ansible.log\r\n###latest release redis server & tools 3.2.3\r\nfact_caching = redis \r\nfact_caching_timeout = 86400\r\nretry_files_enabled = False\r\n```\r\n\r\n##### OS / ENVIRONMENT\r\n**Local host**: Ubuntu 16.04 4.4.0-34\r\n**Target node**: NX-OSv 7.3(0)D1(1)\r\n\r\n##### SUMMARY\r\nCannot configure anything using nxos_command module through CLI/SSH nor NX-API.\r\nUsing show commands works fine with nxos_command.\r\n\r\n##### STEPS TO REPRODUCE\r\n**Inventory** ./hosts:\r\n```\r\n[spines]\r\n172.21.100.11 ansible_host=NX_OSv_Spine_11 os_family=nx_osv\r\n172.21.100.12 ansible_host=NX_OSv_Spine_12 os_family=nx_osv\r\n\r\n[leaves]\r\n172.21.100.13 ansible_host=NX_OSv_Leaf_13 os_family=nx_osv\r\n172.21.100.14 ansible_host=NX_OSv_Leaf_14 os_family=nx_osv\r\n172.21.100.15 ansible_host=NX_OSv_Leaf_15 os_family=nx_osv\r\n172.21.100.16 ansible_host=NX_OSv_Leaf_16 os_family=nx_osv\r\n```\r\nStructure passed as **provider**: connections.ssh or connections.nxapi\r\nDefined in group_vars/nx_osv/connections.yml\r\n```\r\nconnections:\r\n        compute: local\r\n        protocol: https\r\n        target: cisco\r\n        ssh:\r\n          transport: cli \r\n          host: \"{{ inventory_hostname }}\"\r\n          # ansible_port\r\n          port: 22\r\n          # ansible_user\r\n          username: admin\r\n          # ansible_ssh_pass\r\n          password: Cisco2016$\r\n          authorize: yes\r\n          # enable_secret_password\r\n          auth_pass: Cisco2016$\r\n          # private_key_file\r\n          ssh_keyfile: \"~/.ssh/id_rsa\"\r\n          version: 2\r\n          timeout: 10\r\n        nxapi:\r\n          transport: nxapi\r\n          host: \"{{ inventory_hostname }}\"\r\n          # ansible_port\r\n          port: \"{{ https.port }}\"\r\n          # ansible_user\r\n          username: admin\r\n          password: Cisco2016$\r\n          authorize: yes\r\n          # enable_secret_password\r\n          auth_pass: Cisco2016$\r\n          # http or https\r\n          use_ssl: yes\r\n          validate_certs: \"{{ https.validate_certs }}\"\r\n\r\nansible_connection: \"{{ connections.compute }}\" \r\n```\r\nStructures **http & https**\r\nDefined in group_vars/nx_osv/http.yml\r\n```\r\nhttp:\r\n        # enable_http can be true / false\r\n        service: false\r\n        port: 8080\r\nhttps:\r\n        # enable_https can be true / false\r\n        service: true\r\n        port: 8181\r\n        # If you do not need to confirm the servers identity but this is unsafe\r\n        validate_certs: false\r\n```\r\n**Role**: nxos_init\r\n```\r\n- include_vars: \"{{ role_path }}/../../group_vars/{{ os_family }}/http.yml\"\r\n- include_vars: \"{{ role_path }}/../../group_vars/{{ os_family }}/connections.yml\"\r\n\r\n# Buggy https://github.com/ansible/ansible-modules-core/issues/4311\r\n#- name: Enable NX-API\r\n#  nxos_nxapi: \r\n#      state: started \r\n#      sandbox: \"{{ sandbox }}\"\r\n#      http: \"{{ http.service }}\"\r\n#      http_port: \"{{ http.port }}\"\r\n#      https: \"{{ https.service }}\"\r\n#      https_port: \"{{ https.port }}\"\r\n#      provider: \"{{ connections.ssh }}\"\r\n#  register: nxapi\r\n\r\n- name: Set hostname & license grace period\r\n  nxos_command:\r\n      provider: \"{{ connections.nxapi }}\"\r\n      commands:\r\n        - configure terminal\r\n        - \"hostname {{ ansible_host }}\"\r\n        - license grace-period\r\n  register: return\r\n...\r\n```\r\nPlaybook: init.yml\r\n```\r\n- name: Initialize all NX-OS features\r\n  hosts:\r\n    - nx_os\r\n    - nx_osv\r\n  roles:\r\n    - nxos_init\r\n```\r\n**Manually configure nxapi on the targets** since we cannot perform that with ansible (cf. https://github.com/ansible/ansible-modules-core/issues/4311):\r\n```\r\nfeature nxapi\r\nnxapi http port 8080\r\nnxapi https port 8181\r\nsh nxapi\r\n\r\nNX-API:       Enabled         Sandbox:      Disabled    \r\nHTTP Port:    8080            HTTPS Port:   8181        \r\n\r\nCertificate Information:\r\n    Issuer:   /C=US/ST=CA/L=San Jose/O=Cisco Systems Inc./OU=nsstg/CN=nxos     \r\n    Expires:  Dec 19 07:53:19 2015 GMT                                         \r\n    Content:  -----BEGIN CERTIFICATE-----\r\n...\r\n```\r\n\r\n##### EXPECTED RESULTS\r\nSuccessful nxos_command\r\n\r\n##### ACTUAL RESULTS\r\n```\r\nfatal: [172.21.100.16]: FAILED! => {\"changed\": false, \"clierror\": \"**Syntax error while parsing 'configure terminal**  | xml '\\n\\n\\nCmd exec error.\\n\", \"code\": \"400\", \"failed\": true, \"input\": \"configure terminal\", \"invocation\": {\"module_args\": {\"commands\": [\"configure terminal\", \"hostname NX_OSv_Leaf_16\", \"license grace-period\"], \"host\": \"172.21.100.16\", \"interval\": 1, \"password\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"port\": 8181, \"provider\": {\"auth_pass\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"authorize\": true, \"host\": \"172.21.100.16\", \"password\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"port\": \"8181\", \"transport\": \"nxapi\", \"use_ssl\": true, \"username\": \"admin\", \"validate_certs\": false}, \"retries\": 10, \"ssh_keyfile\": null, \"timeout\": 10, \"transport\": \"nxapi\", \"url_password\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"url_username\": \"admin\", \"use_ssl\": true, \"username\": \"admin\", \"validate_certs\": false, \"waitfor\": null}, \"module_name\": \"nxos_command\"}, \"msg\": \"Input CLI command error\"}\r\n```\r\n"}}
{"actor":{"display_login":"jean-christophe-manciot"}}