Debian Codegraph @

ansible_collections/dellemc/enterprise_sonic/docs/dellemc.enterprise_sonic.sonic_config_module.rst

raw
1 .. _dellemc.enterprise_sonic.sonic_config_module:
2
3
4 *************************************
5 dellemc.enterprise_sonic.sonic_config
6 *************************************
7
8 **Manages configuration sections on devices running Enterprise SONiC**
9
10
11 Version added: 1.0.0
12
13 .. contents::
14 :local:
15 :depth: 1
16
17
18 Synopsis
19 --------
20 - Manages configuration sections of Enterprise SONiC Distribution by Dell Technologies. SONiC configurations use a simple block indent file syntax for segmenting configuration into sections. This module provides an implementation for working with SONiC configuration sections in a deterministic way.
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>after</b>
40 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
41 <div style="font-size: small">
42 <span style="color: purple">list</span>
43 / <span style="color: purple">elements=string</span>
44 </div>
45 </td>
46 <td>
47 </td>
48 <td>
49 <div>The ordered set of commands to append to the end of the command stack if a change needs to be made. Just like with <em>before</em>, this allows the playbook designer to append a set of commands to be executed after the command set.</div>
50 </td>
51 </tr>
52 <tr>
53 <td colspan="2">
54 <div class="ansibleOptionAnchor" id="parameter-"></div>
55 <b>backup</b>
56 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
57 <div style="font-size: small">
58 <span style="color: purple">boolean</span>
59 </div>
60 </td>
61 <td>
62 <ul style="margin: 0; padding: 0"><b>Choices:</b>
63 <li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
64 <li>yes</li>
65 </ul>
66 </td>
67 <td>
68 <div>This argument causes the module to create a full backup of the current <code>running-configuration</code> from the remote device before any changes are made. If the <code>backup_options</code> value is not given, the backup file is written to the <code>backup</code> folder in the playbook root directory. If the directory does not exist, it is created.</div>
69 </td>
70 </tr>
71 <tr>
72 <td colspan="2">
73 <div class="ansibleOptionAnchor" id="parameter-"></div>
74 <b>backup_options</b>
75 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
76 <div style="font-size: small">
77 <span style="color: purple">dictionary</span>
78 </div>
79 </td>
80 <td>
81 </td>
82 <td>
83 <div>This is a dictionary object containing configurable options related to backup file path. The value of this option is read only when <code>backup</code> is set to <em>yes</em>, if <code>backup</code> is set to <em>no</em> this option is ignored.</div>
84 </td>
85 </tr>
86 <tr>
87 <td class="elbow-placeholder"></td>
88 <td colspan="1">
89 <div class="ansibleOptionAnchor" id="parameter-"></div>
90 <b>dir_path</b>
91 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
92 <div style="font-size: small">
93 <span style="color: purple">path</span>
94 </div>
95 </td>
96 <td>
97 </td>
98 <td>
99 <div>This option provides the path ending with directory name in which the backup configuration file is stored. If the directory does not exist it is first created, and the filename is either the value of <code>filename</code> or default filename as described in <code>filename</code> options description. If the path value is not given, an <em>backup</em> directory is created in the current working directory and backup configuration is copied in <code>filename</code> within the <em>backup</em> directory.</div>
100 </td>
101 </tr>
102 <tr>
103 <td class="elbow-placeholder"></td>
104 <td colspan="1">
105 <div class="ansibleOptionAnchor" id="parameter-"></div>
106 <b>filename</b>
107 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
108 <div style="font-size: small">
109 <span style="color: purple">string</span>
110 </div>
111 </td>
112 <td>
113 </td>
114 <td>
115 <div>The filename to be used to store the backup configuration. If the filename is not given, it is generated based on the hostname, current time, and date in the format defined by &lt;hostname&gt;_config.&lt;current-date&gt;@&lt;current-time&gt;.</div>
116 </td>
117 </tr>
118
119 <tr>
120 <td colspan="2">
121 <div class="ansibleOptionAnchor" id="parameter-"></div>
122 <b>before</b>
123 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
124 <div style="font-size: small">
125 <span style="color: purple">list</span>
126 / <span style="color: purple">elements=string</span>
127 </div>
128 </td>
129 <td>
130 </td>
131 <td>
132 <div>The ordered set of commands to push on to the command stack if a change needs to be made. This allows the playbook designer the opportunity to perform configuration commands prior to pushing any changes without affecting how the set of commands are matched against the system.</div>
133 </td>
134 </tr>
135 <tr>
136 <td colspan="2">
137 <div class="ansibleOptionAnchor" id="parameter-"></div>
138 <b>config</b>
139 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
140 <div style="font-size: small">
141 <span style="color: purple">string</span>
142 </div>
143 </td>
144 <td>
145 </td>
146 <td>
147 <div>The module, by default, connects to the remote device and retrieves the current running-configuration to use as a base for comparing against the contents of source. There are times when it is not desirable to have the task get the current running-configuration for every task in a playbook. The <em>config</em> argument allows the implementer to pass in the configuration to use as the base configuration for comparison.</div>
148 </td>
149 </tr>
150 <tr>
151 <td colspan="2">
152 <div class="ansibleOptionAnchor" id="parameter-"></div>
153 <b>lines</b>
154 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
155 <div style="font-size: small">
156 <span style="color: purple">list</span>
157 / <span style="color: purple">elements=string</span>
158 </div>
159 </td>
160 <td>
161 </td>
162 <td>
163 <div>The ordered set of commands that should be configured in the section. The commands must be the exact same commands as found in the device running-configuration. Be sure to note the configuration command syntax as some commands are automatically modified by the device configuration parser. This argument is mutually exclusive with <em>src</em>.</div>
164 <div style="font-size: small; color: darkgreen"><br/>aliases: commands</div>
165 </td>
166 </tr>
167 <tr>
168 <td colspan="2">
169 <div class="ansibleOptionAnchor" id="parameter-"></div>
170 <b>match</b>
171 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
172 <div style="font-size: small">
173 <span style="color: purple">string</span>
174 </div>
175 </td>
176 <td>
177 <ul style="margin: 0; padding: 0"><b>Choices:</b>
178 <li><div style="color: blue"><b>line</b>&nbsp;&larr;</div></li>
179 <li>strict</li>
180 <li>exact</li>
181 <li>none</li>
182 </ul>
183 </td>
184 <td>
185 <div>Instructs the module on the way to perform the matching of the set of commands against the current device configuration. If match is set to <em>line</em>, commands are matched line by line. If match is set to <em>strict</em>, command lines are matched with respect to position. If match is set to <em>exact</em>, command lines must be an equal match. If match is set to <em>none</em>, the module does not attempt to compare the source configuration with the running-configuration on the remote device.</div>
186 </td>
187 </tr>
188 <tr>
189 <td colspan="2">
190 <div class="ansibleOptionAnchor" id="parameter-"></div>
191 <b>parents</b>
192 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
193 <div style="font-size: small">
194 <span style="color: purple">list</span>
195 / <span style="color: purple">elements=string</span>
196 </div>
197 </td>
198 <td>
199 </td>
200 <td>
201 <div>The ordered set of parents that uniquely identify the section or hierarchy the commands should be checked against. If the parents argument is omitted, the commands are checked against the set of top level or global commands.</div>
202 </td>
203 </tr>
204 <tr>
205 <td colspan="2">
206 <div class="ansibleOptionAnchor" id="parameter-"></div>
207 <b>replace</b>
208 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
209 <div style="font-size: small">
210 <span style="color: purple">string</span>
211 </div>
212 </td>
213 <td>
214 <ul style="margin: 0; padding: 0"><b>Choices:</b>
215 <li><div style="color: blue"><b>line</b>&nbsp;&larr;</div></li>
216 <li>block</li>
217 </ul>
218 </td>
219 <td>
220 <div>Instructs the module how to perform a configuration on the device. If the replace argument is set to <em>line</em>, then the modified lines are pushed to the device in configuration mode. If the replace argument is set to <em>block</em>, then the entire command block is pushed to the device in configuration mode if any line is not correct.</div>
221 </td>
222 </tr>
223 <tr>
224 <td colspan="2">
225 <div class="ansibleOptionAnchor" id="parameter-"></div>
226 <b>save</b>
227 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
228 <div style="font-size: small">
229 <span style="color: purple">boolean</span>
230 </div>
231 </td>
232 <td>
233 <ul style="margin: 0; padding: 0"><b>Choices:</b>
234 <li>no</li>
235 <li>yes</li>
236 </ul>
237 <b>Default:</b><br/><div style="color: blue">"false"</div>
238 </td>
239 <td>
240 <div>The <code>save</code> argument instructs the module to save the running- configuration to the startup-configuration at the conclusion of the module running. If check mode is specified, this argument is ignored.</div>
241 </td>
242 </tr>
243 <tr>
244 <td colspan="2">
245 <div class="ansibleOptionAnchor" id="parameter-"></div>
246 <b>src</b>
247 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
248 <div style="font-size: small">
249 <span style="color: purple">path</span>
250 </div>
251 </td>
252 <td>
253 </td>
254 <td>
255 <div>Specifies the source path to the file that contains the configuration or configuration template to load. The path to the source file can either be the full path on the Ansible control host, or a relative path from the playbook or role root directory. This argument is mutually exclusive with <em>lines</em>.</div>
256 </td>
257 </tr>
258 <tr>
259 <td colspan="2">
260 <div class="ansibleOptionAnchor" id="parameter-"></div>
261 <b>update</b>
262 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
263 <div style="font-size: small">
264 <span style="color: purple">string</span>
265 </div>
266 </td>
267 <td>
268 <ul style="margin: 0; padding: 0"><b>Choices:</b>
269 <li><div style="color: blue"><b>merge</b>&nbsp;&larr;</div></li>
270 <li>check</li>
271 </ul>
272 </td>
273 <td>
274 <div>The <em>update</em> argument controls how the configuration statements are processed on the remote device. Valid choices for the <em>update</em> argument are <em>merge</em> and <em>check</em>. When you set this argument to <em>merge</em>, the configuration changes merge with the current device running-configuration. When you set this argument to <em>check</em>, the configuration updates are determined but not configured on the remote device.</div>
275 </td>
276 </tr>
277 </table>
278 <br/>
279
280
281 Notes
282 -----
283
284 .. note::
285 - Tested against Enterprise SONiC Distribution by Dell Technologies.
286 - Supports ``check_mode``.
287
288
289
290 Examples
291 --------
292
293 .. code-block:: yaml
294
295 - dellemc.enterprise_sonic.sonic_config:
296 lines: ['username {{ user_name }} password {{ user_password }} role {{ user_role }}']
297
298 - dellemc.enterprise_sonic.sonic_config:
299 lines:
300 - description 'SONiC'
301 parents: ['interface Eth1/10']
302
303 - dellemc.enterprise_sonic.sonic_config:
304 lines:
305 - seq 2 permit udp any any
306 - seq 3 deny icmp any any
307 parents: ['ip access-list test']
308 before: ['no ip access-list test']
309
310
311
312 Return Values
313 -------------
314 Common return values are documented `here <https://docs.ansible.com/projects/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
315
316 .. raw:: html
317
318 <table border=0 cellpadding=0 class="documentation-table">
319 <tr>
320 <th colspan="1">Key</th>
321 <th>Returned</th>
322 <th width="100%">Description</th>
323 </tr>
324 <tr>
325 <td colspan="1">
326 <div class="ansibleOptionAnchor" id="return-"></div>
327 <b>commands</b>
328 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
329 <div style="font-size: small">
330 <span style="color: purple">list</span>
331 </div>
332 </td>
333 <td>always</td>
334 <td>
335 <div>The set of commands that is pushed to the remote device.</div>
336 <br/>
337 <div style="font-size: smaller"><b>Sample:</b></div>
338 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;username foo password foo role admin&#x27;, &#x27;router bgp 1&#x27;, &#x27;router-id 1.1.1.1&#x27;]</div>
339 </td>
340 </tr>
341 <tr>
342 <td colspan="1">
343 <div class="ansibleOptionAnchor" id="return-"></div>
344 <b>saved</b>
345 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
346 <div style="font-size: small">
347 <span style="color: purple">boolean</span>
348 </div>
349 </td>
350 <td>When not check_mode.</td>
351 <td>
352 <div>Returns whether the configuration is saved to the startup configuration or not.</div>
353 <br/>
354 <div style="font-size: smaller"><b>Sample:</b></div>
355 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">True</div>
356 </td>
357 </tr>
358 <tr>
359 <td colspan="1">
360 <div class="ansibleOptionAnchor" id="return-"></div>
361 <b>updates</b>
362 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
363 <div style="font-size: small">
364 <span style="color: purple">list</span>
365 </div>
366 </td>
367 <td>always</td>
368 <td>
369 <div>The set of commands that is pushed to the remote device.</div>
370 <br/>
371 <div style="font-size: smaller"><b>Sample:</b></div>
372 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;username foo password foo role admin&#x27;, &#x27;router bgp 1&#x27;, &#x27;router-id 1.1.1.1&#x27;]</div>
373 </td>
374 </tr>
375 </table>
376 <br/><br/>
377
378
379 Status
380 ------
381
382
383 Authors
384 ~~~~~~~
385
386 - Abirami N (@abirami-n)