Debian Codegraph @

ansible_collections/cisco/nxos/docs/cisco.nxos.nxos_hostname_module.rst

raw
1 .. _cisco.nxos.nxos_hostname_module:
2
3
4 ************************
5 cisco.nxos.nxos_hostname
6 ************************
7
8 **Hostname resource module.**
9
10
11 Version added: 2.9.0
12
13 .. contents::
14 :local:
15 :depth: 1
16
17
18 Synopsis
19 --------
20 - This module manages hostname configuration on devices running Cisco NX-OS.
21
22
23
24
25 Parameters
26 ----------
27
28 .. raw:: html
29
30 <table border=0 cellpadding=0 class="documentation-table">
31 <tr>
32 <th colspan="2">Parameter</th>
33 <th>Choices/<font color="blue">Defaults</font></th>
34 <th width="100%">Comments</th>
35 </tr>
36 <tr>
37 <td colspan="2">
38 <div class="ansibleOptionAnchor" id="parameter-"></div>
39 <b>config</b>
40 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
41 <div style="font-size: small">
42 <span style="color: purple">dictionary</span>
43 </div>
44 </td>
45 <td>
46 </td>
47 <td>
48 <div>A dictionary of hostname configuration.</div>
49 </td>
50 </tr>
51 <tr>
52 <td class="elbow-placeholder"></td>
53 <td colspan="1">
54 <div class="ansibleOptionAnchor" id="parameter-"></div>
55 <b>hostname</b>
56 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
57 <div style="font-size: small">
58 <span style="color: purple">string</span>
59 </div>
60 </td>
61 <td>
62 </td>
63 <td>
64 <div>Hostname of the device.</div>
65 </td>
66 </tr>
67
68 <tr>
69 <td colspan="2">
70 <div class="ansibleOptionAnchor" id="parameter-"></div>
71 <b>running_config</b>
72 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
73 <div style="font-size: small">
74 <span style="color: purple">string</span>
75 </div>
76 </td>
77 <td>
78 </td>
79 <td>
80 <div>This option is used only with state <em>parsed</em>.</div>
81 <div>The value of this option should be the output received from the NX-OS device by executing the command <b>show running-config | section hostname</b>.</div>
82 <div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into Ansible structured data as per the resource module&#x27;s argspec and the value is then returned in the <em>parsed</em> key within the result.</div>
83 </td>
84 </tr>
85 <tr>
86 <td colspan="2">
87 <div class="ansibleOptionAnchor" id="parameter-"></div>
88 <b>state</b>
89 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
90 <div style="font-size: small">
91 <span style="color: purple">string</span>
92 </div>
93 </td>
94 <td>
95 <ul style="margin: 0; padding: 0"><b>Choices:</b>
96 <li><div style="color: blue"><b>merged</b>&nbsp;&larr;</div></li>
97 <li>replaced</li>
98 <li>overridden</li>
99 <li>deleted</li>
100 <li>parsed</li>
101 <li>gathered</li>
102 <li>rendered</li>
103 </ul>
104 </td>
105 <td>
106 <div>The state the configuration should be left in.</div>
107 <div>The states <em>merged</em>, <em>replaced</em> and <em>overridden</em> have identical behaviour for this module.</div>
108 <div>Refer to examples for more details.</div>
109 </td>
110 </tr>
111 </table>
112 <br/>
113
114
115 Notes
116 -----
117
118 .. note::
119 - Tested against NX-OS 9.3.6.
120 - This module works with connection ``network_cli`` and ``httpapi``.
121
122
123
124 Examples
125 --------
126
127 .. code-block:: yaml
128
129 # Using merged (replaced, overridden has the same behaviour)
130
131 # Before state:
132 # -------------
133 # nxos-9k-rdo# show running-config | section ^hostname
134 # nxos-9k-rdo#
135
136 - name: Merge the provided configuration with the existing running configuration
137 cisco.nxos.nxos_hostname:
138 config:
139 hostname: NXOSv-9k
140
141 # Task output
142 # -------------
143 # before: {}
144 #
145 # commands:
146 # - hostname NXOSv-9k
147 #
148 # after:
149 # hostname: NXOSv-9k
150
151 # After state:
152 # ------------
153 # nxos-9k-rdo# show running-config | section ^hostname
154 # hostname NXOSv-9k
155 #
156
157 # Using deleted
158
159 # Before state:
160 # ------------
161 # nxos-9k-rdo# show running-config | section ^hostname
162 # hostname NXOSv-9k
163
164 - name: Delete hostname from running-config
165 cisco.nxos.nxos_hostname:
166 state: deleted
167
168 # Task output
169 # -------------
170 # before:
171 # hostname: NXOSv-9k
172 #
173 # commands:
174 # - no hostname NXOSv-9k
175 #
176 # after: {}
177
178 # Using gathered
179
180 - name: Gather hostname facts using gathered
181 cisco.nxos.nxos_hostname:
182 state: gathered
183
184 # Task output (redacted)
185 # -----------------------
186 # gathered:
187 # hostname: NXOSv-9k
188
189 # Using rendered
190
191 - name: Render platform specific configuration lines (without connecting to the device)
192 cisco.nxos.nxos_hostname:
193 config:
194 hostname: NXOSv-9k
195
196 # Task Output (redacted)
197 # -----------------------
198 # rendered:
199 # - hostname NXOSv-9k
200
201 # Using parsed
202
203 # parsed.cfg
204 # ------------
205 # hostname NXOSv-9k
206
207 - name: Parse externally provided hostname config
208 cisco.nxos.nxos_hostname:
209 running_config: "{{ lookup('file', 'parsed.cfg') }}"
210 state: parsed
211
212 # Task output (redacted)
213 # -----------------------
214 # parsed:
215 # hostname: NXOSv-9k
216
217
218
219 Return Values
220 -------------
221 Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
222
223 .. raw:: html
224
225 <table border=0 cellpadding=0 class="documentation-table">
226 <tr>
227 <th colspan="1">Key</th>
228 <th>Returned</th>
229 <th width="100%">Description</th>
230 </tr>
231 <tr>
232 <td colspan="1">
233 <div class="ansibleOptionAnchor" id="return-"></div>
234 <b>after</b>
235 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
236 <div style="font-size: small">
237 <span style="color: purple">dictionary</span>
238 </div>
239 </td>
240 <td>when changed</td>
241 <td>
242 <div>The resulting configuration after module execution.</div>
243 <br/>
244 <div style="font-size: smaller"><b>Sample:</b></div>
245 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">This output will always be in the same format as the module argspec.</div>
246 </td>
247 </tr>
248 <tr>
249 <td colspan="1">
250 <div class="ansibleOptionAnchor" id="return-"></div>
251 <b>before</b>
252 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
253 <div style="font-size: small">
254 <span style="color: purple">dictionary</span>
255 </div>
256 </td>
257 <td>when <em>state</em> is <code>merged</code>, <code>replaced</code>, <code>overridden</code>, <code>deleted</code> or <code>purged</code></td>
258 <td>
259 <div>The configuration prior to the module execution.</div>
260 <br/>
261 <div style="font-size: smaller"><b>Sample:</b></div>
262 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">This output will always be in the same format as the module argspec.</div>
263 </td>
264 </tr>
265 <tr>
266 <td colspan="1">
267 <div class="ansibleOptionAnchor" id="return-"></div>
268 <b>commands</b>
269 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
270 <div style="font-size: small">
271 <span style="color: purple">list</span>
272 </div>
273 </td>
274 <td>when <em>state</em> is <code>merged</code>, <code>replaced</code>, <code>overridden</code>, <code>deleted</code> or <code>purged</code></td>
275 <td>
276 <div>The set of commands pushed to the remote device.</div>
277 <br/>
278 <div style="font-size: smaller"><b>Sample:</b></div>
279 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;hostname switch01&#x27;]</div>
280 </td>
281 </tr>
282 <tr>
283 <td colspan="1">
284 <div class="ansibleOptionAnchor" id="return-"></div>
285 <b>gathered</b>
286 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
287 <div style="font-size: small">
288 <span style="color: purple">list</span>
289 </div>
290 </td>
291 <td>when <em>state</em> is <code>gathered</code></td>
292 <td>
293 <div>Facts about the network resource gathered from the remote device as structured data.</div>
294 <br/>
295 <div style="font-size: smaller"><b>Sample:</b></div>
296 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">This output will always be in the same format as the module argspec.</div>
297 </td>
298 </tr>
299 <tr>
300 <td colspan="1">
301 <div class="ansibleOptionAnchor" id="return-"></div>
302 <b>parsed</b>
303 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
304 <div style="font-size: small">
305 <span style="color: purple">list</span>
306 </div>
307 </td>
308 <td>when <em>state</em> is <code>parsed</code></td>
309 <td>
310 <div>The device native config provided in <em>running_config</em> option parsed into structured data as per module argspec.</div>
311 <br/>
312 <div style="font-size: smaller"><b>Sample:</b></div>
313 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">This output will always be in the same format as the module argspec.</div>
314 </td>
315 </tr>
316 <tr>
317 <td colspan="1">
318 <div class="ansibleOptionAnchor" id="return-"></div>
319 <b>rendered</b>
320 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
321 <div style="font-size: small">
322 <span style="color: purple">list</span>
323 </div>
324 </td>
325 <td>when <em>state</em> is <code>rendered</code></td>
326 <td>
327 <div>The provided configuration in the task rendered in device-native format (offline).</div>
328 <br/>
329 <div style="font-size: smaller"><b>Sample:</b></div>
330 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;hostname switch01&#x27;]</div>
331 </td>
332 </tr>
333 </table>
334 <br/><br/>
335
336
337 Status
338 ------
339
340
341 Authors
342 ~~~~~~~
343
344 - Nilashish Chakraborty (@NilashishC)