Debian Codegraph @

ansible_collections/cisco/nxos/platform_guide.rst

raw
1 .. _nxos_platform_options:
2
3 ***************************************
4 NXOS Platform Options
5 ***************************************
6
7 The `Cisco NXOS <https://galaxy.ansible.com/ui/repo/published/cisco/nxos>`_ supports multiple connections. This page offers details on how each connection works in Ansible and how to use it.
8
9 .. contents::
10 :local:
11
12 Connections available
13 ================================================================================
14
15 .. table::
16 :class: documentation-table
17
18 ==================== ========================================== =========================
19 .. CLI NX-API
20 ==================== ========================================== =========================
21 Protocol SSH HTTP(S)
22
23 Credentials uses SSH keys / SSH-agent if present uses HTTPS certificates if
24 present
25 accepts ``-u myuser -k`` if using password
26
27 Indirect Access by a bastion (jump host) by a web proxy
28
29 Connection Settings ``ansible_connection:`` ``ansible_connection:``
30 ``ansible.netcommon.network_cli`` ``ansible.netcommon.httpapi``
31
32 Enable Mode supported: use ``ansible_become: true`` not supported by NX-API
33 with ``ansible_become_method: enable``
34 and ``ansible_become_password:``
35
36 Returned Data Format ``stdout[0].`` ``stdout[0].messages[0].``
37 ==================== ========================================== =========================
38
39
40 Using CLI in Ansible
41 ====================
42
43 Example CLI ``group_vars/nxos.yml``
44 -----------------------------------
45
46 .. code-block:: yaml
47
48 ansible_connection: ansible.netcommon.network_cli
49 ansible_network_os: cisco.nxos.nxos
50 ansible_user: myuser
51 ansible_password: !vault...
52 ansible_become: true
53 ansible_become_method: enable
54 ansible_become_password: !vault...
55 ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion01"'
56
57
58 - If you are using SSH keys (including an ssh-agent) you can remove the ``ansible_password`` configuration.
59 - If you are accessing your host directly (not through a bastion/jump host) you can remove the ``ansible_ssh_common_args`` configuration.
60 - If you are accessing your host through a bastion/jump host, you cannot include your SSH password in the ``ProxyCommand`` directive. To prevent secrets from leaking out (for example in ``ps`` output), SSH does not support providing passwords through environment variables.
61
62 Note
63 -----
64
65 When using ``ansible_connection: ansible.netcommon.network_cli``, the ``ansible_user`` must have permissions to execute the ``terminal length 0`` and ``terminal width 511`` commands on the target device.
66
67 Example CLI task
68 ----------------
69
70 .. code-block:: yaml
71
72 - name: Backup current switch config (nxos)
73 cisco.nxos.nxos_config:
74 backup: yes
75 register: backup_nxos_location
76 when: ansible_network_os == 'cisco.nxos.nxos'
77
78
79
80 Using NX-API in Ansible
81 =======================
82
83 Enabling NX-API
84 ---------------
85
86 Before you can use NX-API to connect to a switch, you must enable NX-API. To enable NX-API on a new switch through Ansible, use the ``nxos_nxapi`` module through the CLI connection. Set up group_vars/nxos.yml just like in the CLI example above, then run a playbook task like this:
87
88 .. code-block:: yaml
89
90 - name: Enable NX-API
91 cisco.nxos.nxos_nxapi:
92 enable_http: yes
93 enable_https: yes
94 when: ansible_network_os == 'cisco.nxos.nxos'
95
96 To find out more about the options for enabling HTTP/HTTPS and local http see the :ref:`nxos_nxapi <nxos_nxapi_module>` module documentation.
97
98 Once NX-API is enabled, change your ``group_vars/nxos.yml`` to use the NX-API connection.
99
100 Example NX-API ``group_vars/nxos.yml``
101 --------------------------------------
102
103 .. code-block:: yaml
104
105 ansible_connection: ansible.netcommon.httpapi
106 ansible_network_os: cisco.nxos.nxos
107 ansible_user: myuser
108 ansible_password: !vault...
109 proxy_env:
110 http_proxy: http://proxy.example.com:8080
111
112 - If you are accessing your host directly (not through a web proxy) you can remove the ``proxy_env`` configuration.
113 - If you are accessing your host through a web proxy using ``https``, change ``http_proxy`` to ``https_proxy``.
114
115
116 Example NX-API task
117 -------------------
118
119 .. code-block:: yaml
120
121 - name: Backup current switch config (nxos)
122 cisco.nxos.nxos_config:
123 backup: yes
124 register: backup_nxos_location
125 environment: "{{ proxy_env }}"
126 when: ansible_network_os == 'cisco.nxos.nxos'
127
128 In this example the ``proxy_env`` variable defined in ``group_vars`` gets passed to the ``environment`` option of the module used in the task.
129
130 Warning
131 --------
132 Never store passwords in plain text. We recommend using SSH keys to authenticate SSH connections. Ansible supports ssh-agent to manage your SSH keys. If you must use passwords to authenticate SSH connections, we recommend encrypting them with Ansible Vault.
133
134 Cisco Nexus platform support matrix
135 ===================================
136
137 The following platforms and software versions have been certified by Cisco to work with this version of Ansible.
138
139 .. table:: Platform / Software Minimum Requirements
140 :align: center
141
142 =================== =====================
143 Supported Platforms Minimum NX-OS Version
144 =================== =====================
145 Cisco Nexus N3k 7.0(3)I2(5) and later
146 Cisco Nexus N9k 7.0(3)I2(5) and later
147 Cisco Nexus N5k 7.3(0)N1(1) and later
148 Cisco Nexus N6k 7.3(0)N1(1) and later
149 Cisco Nexus N7k 7.3(0)D1(1) and later
150 Cisco Nexus MDS 8.4(1) and later (Please see individual module documentation for compatibility)
151 =================== =====================
152
153 .. table:: Platform Models
154 :align: center
155
156 ======== ==============================================
157 Platform Description
158 ======== ==============================================
159 N3k Support includes N30xx, N31xx and N35xx models
160 N5k Support includes all N5xxx models
161 N6k Support includes all N6xxx models
162 N7k Support includes all N7xxx models
163 N9k Support includes all N9xxx models
164 MDS Support includes all MDS 9xxx models
165 ======== ==============================================
166
167 Notes
168 -----
169
170 `Setting Timeout Option <https://docs.ansible.com/ansible/latest/network/getting_started/network_connection_options.html#timeout-options>`_