Debian Codegraph @

ansible_collections/cisco/iosxr/docs/cisco.iosxr.iosxr_hostname_module.rst

raw
1 .. _cisco.iosxr.iosxr_hostname_module:
2
3
4 **************************
5 cisco.iosxr.iosxr_hostname
6 **************************
7
8 **Resource module to configure hostname.**
9
10
11 Version added: 2.7.0
12
13 .. contents::
14 :local:
15 :depth: 1
16
17
18 Synopsis
19 --------
20 - This module configures and manages the attributes of hostname on Cisco IOSXR platforms.
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>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 iosxr box.</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 IOSXR device by executing the command <b>show running-config 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>deleted</li>
97 <li><div style="color: blue"><b>merged</b>&nbsp;&larr;</div></li>
98 <li>overridden</li>
99 <li>replaced</li>
100 <li>gathered</li>
101 <li>rendered</li>
102 <li>parsed</li>
103 </ul>
104 </td>
105 <td>
106 <div>The state the configuration should be left in</div>
107 <div>The states <em>rendered</em>, <em>gathered</em> and <em>parsed</em> does not perform any change on the device.</div>
108 <div>The state <em>rendered</em> will transform the configuration in <code>config</code> option to platform specific CLI commands which will be returned in the <em>rendered</em> key within the result. For state <em>rendered</em> active connection to remote host is not required.</div>
109 <div>The states <em>merged</em>, <em>replaced</em> and <em>overridden</em> have identical behaviour for this module.</div>
110 <div>The state <em>gathered</em> will fetch the running configuration from device and transform it into structured data in the format as per the resource module argspec and the value is returned in the <em>gathered</em> key within the result.</div>
111 <div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into JSON format as per the resource module parameters and the value is returned in the <em>parsed</em> key within the result. The value of <code>running_config</code> option should be the same format as the output of command <em>show running-config hostname</em> executed on device. For state <em>parsed</em> active connection to remote host is not required.</div>
112 </td>
113 </tr>
114 </table>
115 <br/>
116
117
118 Notes
119 -----
120
121 .. note::
122 - Tested against Cisco Iosxr 7.0.2
123 - This module works with connection ``network_cli``.
124
125
126
127 Examples
128 --------
129
130 .. code-block:: yaml
131
132 # Using state: merged
133 # Before state:
134 # -------------
135
136 # RP/0/RP0/CPU0:ios#show running-config hostname
137 # Thu Jan 20 19:48:56.011 UTC
138 # hostname ios
139
140 # Merged play:
141 # ------------
142
143 - name: Apply the provided configuration
144 cisco.iosxr.iosxr_hostname:
145 config:
146 hostname: Router1
147 state: merged
148
149 # Commands Fired:
150 # ---------------
151 # "commands": [
152 # "hostname Router1",
153 # ],
154
155 # After state:
156 # ------------
157
158 # RP/0/0/CPU0:Router1#show running-config hostname
159 # Thu Jan 20 19:48:56.011 UTC
160 # hostname Router1
161
162
163 # Using state: deleted
164 # Before state:
165 # -------------
166
167 # RP/0/0/CPU0:Router1#show running-config hostname
168 # Thu Jan 20 19:48:56.011 UTC
169 # hostname Router1
170
171 # Deleted play:
172 # -------------
173
174 - name: Remove all existing configuration
175 cisco.iosxr.iosxr_hostname:
176 state: deleted
177
178 # Commands Fired:
179 # ---------------
180
181 # "commands": [
182 # "no hostname Router1",
183 # ],
184
185 # After state:
186 # ------------
187 # RP/0/RP0/CPU0:ios#show running-config hostname
188 # Thu Jan 20 19:55:12.971 UTC
189 # hostname ios
190
191 # Using state: overridden
192 # Before state:
193 # -------------
194
195 # RP/0/0/CPU0:ios#show running-config hostname
196 # hostname ios
197
198 # Overridden play:
199 # ----------------
200
201 - name: Override commands with provided configuration
202 cisco.iosxr.iosxr_hostname:
203 config:
204 hostname: RouterTest
205 state: overridden
206
207 # Commands Fired:
208 # ---------------
209 # "commands": [
210 # "hostname RouterTest",
211 # ],
212
213 # After state:
214 # ------------
215
216 # RP/0/RP0/CPU0:RouterTest#show running-config hostname
217 # Thu Jan 20 19:48:56.011 UTC
218 # hostname RouterTest
219
220 # Using state: replaced
221 # Before state:
222 # -------------
223
224 # RP/0/RP0/CPU0:RouterTest#show running-config hostname
225 # Thu Jan 20 19:48:56.011 UTC
226 # hostname RouterTest
227
228 # Replaced play:
229 # --------------
230
231 - name: Replace commands with provided configuration
232 cisco.iosxr.iosxr_hostname:
233 config:
234 hostname: RouterTest
235 state: replaced
236
237 # Commands Fired:
238 # ---------------
239 # "commands": [],
240
241 # After state:
242 # ------------
243 # RP/0/0/CPU0:RouterTest#show running-config hostname
244 # hostname RouterTest
245
246 # Using state: gathered
247 # Before state:
248 # -------------
249
250 # RP/0/RP0/CPU0:RouterTest#show running-config hostname
251 # Thu Jan 20 19:48:56.011 UTC
252 # hostname RouterTest
253
254 # Gathered play:
255 # --------------
256
257 - name: Gather listed hostname config
258 cisco.iosxr.iosxr_hostname:
259 state: gathered
260
261 # Module Execution Result:
262 # ------------------------
263 # "gathered": {
264 # "hostname": "RouterTest"
265 # },
266
267 # Using state: rendered
268 # Rendered play:
269 # --------------
270
271 - name: Render the commands for provided configuration
272 cisco.iosxr.iosxr_hostname:
273 config:
274 hostname: RouterTest
275 state: rendered
276
277 # Module Execution Result:
278 # ------------------------
279 # "rendered": [
280 # "hostname RouterTest",
281 # ]
282
283 # Using state: parsed
284 # File: parsed.cfg
285 # ----------------
286
287 # hostname RouterTest
288 # Parsed play:
289 # ------------
290
291 - name: Parse the provided configuration with the existing running configuration
292 cisco.iosxr.iosxr_hostname:
293 running_config: "{{ lookup('file', 'parsed.cfg') }}"
294 state: parsed
295
296 # Module Execution Result:
297 # ------------------------
298 # "parsed": {
299 # "hostname": "RouterTest"
300 # }
301
302
303
304 Return Values
305 -------------
306 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:
307
308 .. raw:: html
309
310 <table border=0 cellpadding=0 class="documentation-table">
311 <tr>
312 <th colspan="1">Key</th>
313 <th>Returned</th>
314 <th width="100%">Description</th>
315 </tr>
316 <tr>
317 <td colspan="1">
318 <div class="ansibleOptionAnchor" id="return-"></div>
319 <b>after</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">dictionary</span>
323 </div>
324 </td>
325 <td>when changed</td>
326 <td>
327 <div>The resulting configuration after module execution.</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;">This output will always be in the same format as the module argspec.</div>
331 </td>
332 </tr>
333 <tr>
334 <td colspan="1">
335 <div class="ansibleOptionAnchor" id="return-"></div>
336 <b>before</b>
337 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
338 <div style="font-size: small">
339 <span style="color: purple">dictionary</span>
340 </div>
341 </td>
342 <td>when <em>state</em> is <code>merged</code>, <code>replaced</code>, <code>overridden</code>, <code>deleted</code> or <code>purged</code></td>
343 <td>
344 <div>The configuration prior to the module execution.</div>
345 <br/>
346 <div style="font-size: smaller"><b>Sample:</b></div>
347 <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>
348 </td>
349 </tr>
350 <tr>
351 <td colspan="1">
352 <div class="ansibleOptionAnchor" id="return-"></div>
353 <b>commands</b>
354 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
355 <div style="font-size: small">
356 <span style="color: purple">list</span>
357 </div>
358 </td>
359 <td>when <em>state</em> is <code>merged</code>, <code>replaced</code>, <code>overridden</code>, <code>deleted</code> or <code>purged</code></td>
360 <td>
361 <div>The set of commands pushed to the remote device.</div>
362 <br/>
363 <div style="font-size: smaller"><b>Sample:</b></div>
364 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;hostname Router1&#x27;]</div>
365 </td>
366 </tr>
367 <tr>
368 <td colspan="1">
369 <div class="ansibleOptionAnchor" id="return-"></div>
370 <b>gathered</b>
371 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
372 <div style="font-size: small">
373 <span style="color: purple">list</span>
374 </div>
375 </td>
376 <td>when <em>state</em> is <code>gathered</code></td>
377 <td>
378 <div>Facts about the network resource gathered from the remote device as structured data.</div>
379 <br/>
380 <div style="font-size: smaller"><b>Sample:</b></div>
381 <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>
382 </td>
383 </tr>
384 <tr>
385 <td colspan="1">
386 <div class="ansibleOptionAnchor" id="return-"></div>
387 <b>parsed</b>
388 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
389 <div style="font-size: small">
390 <span style="color: purple">list</span>
391 </div>
392 </td>
393 <td>when <em>state</em> is <code>parsed</code></td>
394 <td>
395 <div>The device native config provided in <em>running_config</em> option parsed into structured data as per module argspec.</div>
396 <br/>
397 <div style="font-size: smaller"><b>Sample:</b></div>
398 <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>
399 </td>
400 </tr>
401 <tr>
402 <td colspan="1">
403 <div class="ansibleOptionAnchor" id="return-"></div>
404 <b>rendered</b>
405 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
406 <div style="font-size: small">
407 <span style="color: purple">list</span>
408 </div>
409 </td>
410 <td>when <em>state</em> is <code>rendered</code></td>
411 <td>
412 <div>The provided configuration in the task rendered in device-native format (offline).</div>
413 <br/>
414 <div style="font-size: smaller"><b>Sample:</b></div>
415 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;hostname Router1&#x27;]</div>
416 </td>
417 </tr>
418 </table>
419 <br/><br/>
420
421
422 Status
423 ------
424
425
426 Authors
427 ~~~~~~~
428
429 - Ashwini Mhatre (@amhatre)