├── .gitignore
├── .yamllint
├── CHANGELOG.rst
├── LICENSE
├── README.md
├── action_plugins
└── iosxr_user_manager.py
├── changelogs
├── config.yaml
└── fragments
│ ├── v0-initial-release.yaml
│ ├── v261-new-tasks.yaml
│ ├── v270-major-changes.yaml
│ └── v271-new-tasks.yaml
├── defaults
└── main.yml
├── docs
├── config_manager
│ ├── get.md
│ ├── load.md
│ └── save.md
├── configure_lldp.md
├── configure_system_properties.md
├── configure_vlans.md
└── get_facts.md
├── includes
├── configure
│ └── configure.yaml
├── init.yaml
└── run_cli.yaml
├── library
├── iosxr_bgp.py
├── iosxr_capabilities.py
└── iosxr_user_manager.py
├── meta
├── load_config_spec.yaml
└── main.yml
├── module_utils
├── __init__.py
└── network
│ ├── __init__.py
│ └── iosxr
│ ├── __init__.py
│ └── config
│ ├── __init__.py
│ └── bgp
│ ├── __init__.py
│ ├── address_family.py
│ ├── neighbor.py
│ ├── neighbor_group.py
│ ├── network.py
│ ├── process.py
│ ├── redistribute.py
│ └── timer.py
├── parser_templates
└── cli
│ ├── show_version_brief.yaml
│ └── show_vlan.yaml
├── tasks
├── config_manager
│ ├── get.yaml
│ ├── load.yaml
│ └── save.yaml
├── configure_lldp.yaml
├── configure_netconf.yaml
├── configure_system_properties.yaml
├── configure_user.yaml
├── configure_vlans.yaml
├── get_facts.yaml
└── main.yml
├── templates
├── configure_lldp.j2
├── configure_system_properties.j2
├── configure_user.j2
└── configure_vlans.j2
├── test-requirements.txt
├── tests
├── inventory
└── test.yml
├── tox.ini
└── vars
├── get_facts_command_map.yaml
└── main.yml
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | .tox
3 | .idea/
4 |
--------------------------------------------------------------------------------
/.yamllint:
--------------------------------------------------------------------------------
1 | extends: default
2 |
3 | rules:
4 | braces:
5 | max-spaces-inside: 1
6 | level: error
7 | brackets:
8 | max-spaces-inside: 1
9 | level: error
10 | line-length: disable
11 |
--------------------------------------------------------------------------------
/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | ===========================
2 | Ansible Network cisco_iosxr
3 | ===========================
4 |
5 | .. _Ansible Network cisco_iosxr_v2.7.1:
6 |
7 | v2.7.1
8 | ======
9 |
10 | .. _Ansible Network cisco_iosxr_v2.7.1_New Tasks:
11 |
12 | New Tasks
13 | ---------
14 |
15 | - Add ``configure_vlan`` task.
16 |
17 | - Add ``configure_system_properties`` task.
18 |
19 | - Add ``configure_lldp`` task.
20 |
21 |
22 | .. _Ansible Network cisco_iosxr_v2.7.0:
23 |
24 | v2.7.0
25 | ======
26 |
27 | .. _Ansible Network cisco_iosxr_v2.7.0_Major Changes:
28 |
29 | Major Changes
30 | -------------
31 |
32 | - Initial release of 2.7.0 ``cisco_iosxr`` Ansible role that is supported with Ansible 2.7.0
33 |
34 |
35 | .. _Ansible Network cisco_iosxr_v2.6.1:
36 |
37 | v2.6.1
38 | ======
39 |
40 | .. _Ansible Network cisco_iosxr_v2.6.1_New Tasks:
41 |
42 | New Tasks
43 | ---------
44 |
45 | - Add ``configure_user`` task.
46 |
47 |
48 | .. _Ansible Network cisco_iosxr_v2.6.0:
49 |
50 | v2.6.0
51 | ======
52 |
53 | .. _Ansible Network cisco_iosxr_v2.6.0_Major Changes:
54 |
55 | Major Changes
56 | -------------
57 |
58 | - Initial release of the ``cisco_iosxr`` Ansible role.
59 |
60 | - This role provides functions to perform automation activities on Cisco IOSXR devices.
61 |
62 |
63 | .. _Ansible Network cisco_iosxr_v2.6.0_New Functions:
64 |
65 | New Functions
66 | -------------
67 |
68 | - NEW ``get_facts`` function can be used to collect facts from Cisco IOSXR devices.
69 |
70 | - NEW ``config_manager/get`` function returns the either the current active or current saved configuration from Cisco IOSXR devices.
71 |
72 | - NEW ``config_manager/load`` function provides a means to load a configuration file onto a target device running Cisco IOSXR.
73 |
74 | - NEW ``config_manager/save`` function saves the current active (running) configuration to the startup configuration.
75 |
76 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # cisco_iosxr
2 |
3 | This Ansible Network role provides a set of platform dependent functions that
4 | are designed to work with Cisco IOS-XR network devices. The functions included
5 | in this role including both configuration and fact collection.
6 |
7 | ## Requirements
8 |
9 | * Ansible 2.6 or later
10 | * Ansible Network Engine Role 2.6.0 or later
11 |
12 | ## Functions
13 |
14 | This section provides a list of the available functions that are included
15 | in this role. Any of the provided functions can be implemented in Ansible
16 | playbooks to perform automation activities on Cisco iosxr devices.
17 |
18 | Please see the documentation link for each function for details on how to use
19 | the function in an Ansible playbook.
20 |
21 | * get_facts [[source]](https://github.com/ansible-network/cisco_iosxr/blob/devel/tasks/get_facts.yaml) [[docs]](https://github.com/ansible-network/cisco_iosxr/blob/devel/docs/get_facts.md)
22 | * configure_vlans [[source]](https://github.com/ansible-network/cisco_iosxr/blob/devel/tasks/configure_vlans.yaml) [[docs]](https://github.com/ansible-network/cisco_iosxr/blob/devel/docs/configure_vlans.md)
23 | * configure_system_properties [[source]](https://github.com/ansible-network/cisco_iosxr/blob/devel/tasks/configure_system_properties.yaml) [[docs]](https://github.com/ansible-network/cisco_iosxr/blob/devel/docs/configure_system_properties.md)
24 | * configure_lldp [[source]](https://github.com/ansible-network/cisco_iosxr/blob/devel/tasks/configure_lldp.yaml) [[docs]](https://github.com/ansible-network/cisco_iosxr/blob/devel/docs/configure_lldp.md)
25 |
26 | ### Config Manager
27 |
28 | * config_manager/get [[source]](https://github.com/ansible-network/cisco_iosxr/blob/devel/tasks/config_manager/get.yaml) [[docs]](https://github.com/ansible-network/cisco_iosxr/blob/devel/docs/config_manager/get.md)
29 | * config_manager/save [[source]](https://github.com/ansible-network/cisco_iosxr/blob/devel/tasks/config_manager/save.yaml) [[docs]](https://github.com/ansible-network/cisco_iosxr/blob/devel/docs/config_manager/save.md)
30 | * config_manager/load [[source]](https://github.com/ansible-network/cisco_iosxr/blob/devel/tasks/config_manager/load.yaml) [[docs]](https://github.com/ansible-network/cisco_iosxr/blob/devel/docs/config_manager/load.md)
31 |
32 | ## License
33 |
34 | GPLv3
35 |
36 | ## Author Information
37 |
38 | Ansible Network Community
39 |
--------------------------------------------------------------------------------
/action_plugins/iosxr_user_manager.py:
--------------------------------------------------------------------------------
1 | # (c) 2018, Ansible by Red Hat, inc
2 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
3 | #
4 | # You should have received a copy of the GNU General Public License
5 | # along with Ansible. If not, see .
6 | #
7 | from __future__ import (absolute_import, division, print_function)
8 | __metaclass__ = type
9 |
10 | ANSIBLE_METADATA = {'metadata_version': '1.1',
11 | 'status': ['preview'],
12 | 'supported_by': 'network'}
13 |
14 | from ansible.plugins.action import ActionBase
15 |
16 | class UserManager:
17 |
18 | def __init__(self, new_users, user_config_data):
19 | self.__new_users = new_users
20 | self.__user_config_data = user_config_data
21 |
22 | def generate_existing_users(self):
23 | users = self.__user_config_data.strip().rstrip('!').split('!')
24 |
25 | if not users:
26 | return []
27 |
28 | existing_users = []
29 |
30 | for user in users:
31 | user_config = user.strip().splitlines()
32 |
33 | name = user_config[0].strip().split()[1]
34 | group = None
35 |
36 | if len(user_config) > 1:
37 | group_or_secret = user_config[1].strip().split()
38 | if group_or_secret[0] == 'group':
39 | group = group_or_secret[1]
40 |
41 | obj = {
42 | 'name': name,
43 | 'group': group
44 | }
45 |
46 | existing_users.append(obj)
47 |
48 | return existing_users
49 |
50 | def filter_users(self):
51 | want = self.__new_users
52 | have = self.generate_existing_users()
53 | filtered_users = [x for x in want if x not in have]
54 |
55 | changed = True if len(filtered_users) > 0 else False
56 |
57 | return changed, filtered_users
58 |
59 |
60 | class ActionModule(ActionBase):
61 |
62 | def run(self, tmp=None, task_vars=None):
63 | if task_vars is None:
64 | task_vars = dict()
65 |
66 | result = super(ActionModule, self).run(tmp, task_vars)
67 |
68 | try:
69 | new_users = self._task.args['new_users']
70 | user_config_data = self._task.args['user_config']
71 | except KeyError as exc:
72 | return {'failed': True, 'msg': 'missing required argument: %s' % exc}
73 |
74 | result['changed'], result['stdout'] = UserManager(new_users, user_config_data).filter_users()
75 |
76 | return result
77 |
--------------------------------------------------------------------------------
/changelogs/config.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | release_tag_re: '(v(?:[\d.ab\-]|rc)+)'
3 | pre_release_tag_re: '(?P(?:[ab]|rc)+\d*)$'
4 | notesdir: fragments
5 | prelude_section_name: release_summary
6 | sections:
7 | - ['major_changes', 'Major Changes']
8 | - ['minor_changes', 'Minor Changes']
9 | - ['deprecated_features', 'Deprecated Features']
10 | - ['removed_features', 'Removed Features (previously deprecated)']
11 | - ['new_lookup_plugins', 'New Lookup Plugins']
12 | - ['new_callback_plugins', 'New Callback Plugins']
13 | - ['new_connection_plugins', 'New Connection Plugins']
14 | - ['new_test_plugins', 'New Test Plugins']
15 | - ['new_filter_plugins', 'New Filter Plugins']
16 | - ['new_modules', 'New Modules']
17 | - ['new_tasks', 'New Tasks']
18 | - ['new_functions', 'New Functions']
19 | - ['new_parser_templates', 'New Parser Templates']
20 | - ['bugfixes', 'Bugfixes']
21 | - ['known_issues', 'Known Issues']
22 | - ['docs', 'Documentation Updates']
23 |
--------------------------------------------------------------------------------
/changelogs/fragments/v0-initial-release.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | major_changes:
3 | - Initial release of the ``cisco_iosxr`` Ansible role.
4 | - This role provides functions to perform automation activities on Cisco IOSXR devices.
5 |
6 | new_functions:
7 | - NEW ``get_facts`` function can be used to collect facts from Cisco IOSXR devices.
8 | - NEW ``config_manager/get`` function returns the either the current active or current saved configuration from Cisco IOSXR devices.
9 | - NEW ``config_manager/load`` function provides a means to load a configuration file onto a target device running Cisco IOSXR.
10 | - NEW ``config_manager/save`` function saves the current active (running) configuration to the startup configuration.
11 |
--------------------------------------------------------------------------------
/changelogs/fragments/v261-new-tasks.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | new_tasks:
3 | - Add ``configure_user`` task.
4 |
--------------------------------------------------------------------------------
/changelogs/fragments/v270-major-changes.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | major_changes:
3 | - Initial release of 2.7.0 ``cisco_iosxr`` Ansible role that is supported with Ansible 2.7.0
4 |
--------------------------------------------------------------------------------
/changelogs/fragments/v271-new-tasks.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | new_tasks:
3 | - Add ``configure_vlan`` task.
4 | - Add ``configure_system_properties`` task.
5 | - Add ``configure_lldp`` task.
6 |
--------------------------------------------------------------------------------
/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for ansible-network.cisco_iosxr
3 | #
4 | iosxr_get_facts_command_map: "{{ role_path }}/vars/get_facts_command_map.yaml"
5 | iosxr_get_facts_subset: "{{ subset | default(['default']) }}"
6 |
7 | iosxr_netconf_port: "{{ netconf_port | default(830) }}"
8 | iosxr_netconf_vrf: "{{ netconf_vrf | default('default') }}"
9 |
10 | iosxr_rollback_enabled: "{{ rollback_enabled | default(True) }}"
11 | iosxr_config_file: "{{ config_file | default(None) }}"
12 | iosxr_config_text: "{{ config_text | default(None) }}"
13 | iosxr_config_replace: "{{ replace | default(False) }}"
14 |
--------------------------------------------------------------------------------
/docs/config_manager/get.md:
--------------------------------------------------------------------------------
1 | # Get configuration from device
2 | The `config_manager/get` function will return the either the current active or current
3 | saved configuration from Cisco IOSXR devices. This function is only
4 | supported over `network_cli` connections.
5 |
6 | The `config_manager/get` function will also parse the device active configuration into
7 | a set of host facts during its execution. All of the parsed facts are stored
8 | in the ``iosxr.config`` top level facts key.
9 |
10 | ## How to get the device configuration
11 | Retrieving the configuration from the device involves just calling the
12 | `config_manager/get` function from the role. By default, the `config_manager/get` role will
13 | return the device active (running) configuration. The text configuration will
14 | be returned as a fact for the host. The configuration text is stored in the
15 | `configuration` fact.
16 |
17 | Below is an example of calling the `config_manager/get` function from the playbook.
18 |
19 | ```
20 | - hosts: iosxr
21 |
22 | roles:
23 | - name: ansible-network.cisco_iosxr
24 | function: config_manager/get
25 | ```
26 |
27 | The above playbook will return the current running config from each host listed
28 | in the `iosxr` group in inventory.
29 |
30 | ### Get the current startup config
31 | By default the `config_manager/get` function will return the device running
32 | configuration. If you want to retrieve the device startup configuration, set
33 | the value of `source` to `startup`.
34 |
35 | ```
36 | - hosts: iosxr
37 |
38 | roles:
39 | - name: ansible-network.iosxr
40 | function: config_manager/get
41 | source: startup
42 | ```
43 |
44 | ### Implement using tasks
45 | The `config_manager/get` function can also be implemented in the `tasks` during the
46 | playbook run using either the `include_role` or `import_role` modules as shown
47 | below.
48 |
49 | ```
50 | - hosts: iosxr
51 |
52 | tasks:
53 | - name: collect facts from iosxr devices
54 | include_role:
55 | name: ansible-network.iosxr
56 | tasks_from: config_manager/get
57 | ```
58 |
59 | ## How to add additional parsers
60 |
61 | The configuration facts returned by this function are parsed using the
62 | parsers in the `parser_templates/config` folder. To add a new parser, simply
63 | create a PR and add the new parser to the folder. Once merged, the
64 | `config_manager/get` function will automatically use the new parser.
65 |
66 | ## Arguments
67 |
68 | ### source
69 |
70 | Defines the configuration source to return from the device. This argument
71 | accepts one of `running` or `startup`. When the value is set to `running`
72 | (default), the current active configuration is returned. When the value is set
73 | to `startup`, the device saved configuration is returned.
74 |
75 | The default value is `running`
76 |
77 | ## Notes
78 | None
79 |
--------------------------------------------------------------------------------
/docs/config_manager/load.md:
--------------------------------------------------------------------------------
1 | # Load configuration into device
2 | The `config_manager/load` function provides a means to load a configuration file onto a
3 | target device running Cisco IOSXR. The `config_manager/load` function provides configuration
4 | values that allow the source configuration to either be merged with the
5 | current active configuration (default) or to replace the current active
6 | configuration on the device.
7 |
8 |
9 | ## How to load a configuration
10 | Loading a configuration onto a target device is fairly simple and
11 | straightforward. By default, the `config_manager/load` function will merge the
12 | contents of the provided configuration file with the configuration running on
13 | the target device.
14 |
15 | Below is an example of how to call the `config_manager/load` function.
16 |
17 | ```
18 | - hosts: iosxr
19 |
20 | roles:
21 | - name: ansible-network.cisco_iosxr
22 | function: config_manager/load
23 | config_file: iosxr.cfg
24 | ```
25 |
26 | The example playbook above will simple load the contents of `iosxr.cfg` onto the
27 | target network devices.
28 |
29 | ### How to load and replace a configuration
30 | The `config_manager/load` function also provides support for replacing the current
31 | configuration on a device.
32 |
33 | In order to replace the configuration, the function as before but adds the
34 | value `replace: yes` to the playbook to indicate that the configuration should
35 | be replace.
36 |
37 | Note: Take caution when doing configuration replace that you do not
38 | inadvertantly replace your access to the device.
39 |
40 | ```
41 | - hosts: iosxr
42 |
43 | roles:
44 | - name: ansible-network.cisco_iosxr
45 | function: config_manager/load
46 | config_file: iosxr.cfg
47 | replace: yes
48 | ```
49 |
50 | ## Arguments
51 |
52 | ### iosxr_config_replace
53 |
54 | This value enables or disables the configuration replace feature of the
55 | function. In order to use `iosxr_config_replace` the target device must
56 | support config replace function.
57 |
58 | The default value is `False`
59 |
60 | #### Aliases
61 | * replace
62 |
63 | ### iosxr_config_file
64 |
65 | This required value provides the path to the configuration file to load when
66 | the function is called. The path to the file can either be provided as
67 | relative to the playbook root or an absolute path.
68 |
69 | The default value is `null`
70 |
71 | This value is *required*
72 |
73 | #### Aliases
74 |
75 | * config_file
76 |
77 | ### iosxr_config_remove_temp_files
78 |
79 | Configures the function to remove or not remove the temp files created when
80 | preparing to load the configuration file for replace. There are two locations
81 | for temp files, one on the Ansible controller and one on the device. This
82 | argument accepts a boolean value.
83 |
84 | The default value is `True`
85 |
86 | ##### Aliases
87 |
88 | * remove_temp_files
89 |
--------------------------------------------------------------------------------
/docs/config_manager/save.md:
--------------------------------------------------------------------------------
1 | # Save active configuration to config.boot
2 | The `config_manager/save` function will save the current active configuration to
3 | disk0:_tmp_config_ansible. This function is idempotent.
4 |
5 | ## How to save the active configuration
6 | To save the current active configuration to disk0:_tmp_config_ansibl simply
7 | invoke the `config_manager/save` function on the target device. There are no
8 | additional configuration options available for this function.
9 |
10 | Below is an example of calling the `config_manager/save` function from the playbook.
11 |
12 | ```
13 | - hosts: iosxr
14 |
15 | roles:
16 | - name: ansible-network.cisco_iosxr
17 | function: config_manager/save
18 | ```
19 |
20 | ## Arguments
21 |
22 | None
23 |
24 | ## Notes
25 | None
26 |
--------------------------------------------------------------------------------
/docs/configure_lldp.md:
--------------------------------------------------------------------------------
1 | # Configure LLDP on the device
2 |
3 | The `configure_lldp` function can be used to set LLDP on Cisco IOS-XR devices.
4 | This function is only supported over `network_cli` connection type and
5 | requires the `ansible_network_os` value set to `iosxr`.
6 |
7 | ## How to set LLDP on the device
8 |
9 | To set LLDP on the device, simply include this function in the playbook
10 | using either the `roles` directive or the `tasks` directive. If no other
11 | options are provided, then all of the available facts will be collected for
12 | the device.
13 |
14 | Below is an example of how to use the `roles` directive to set LLDP on the
15 | Cisco IOS-XR device.
16 |
17 | ```
18 | - hosts: iosxr
19 |
20 | roles:
21 | - name ansible-network.cisco_iosxr
22 | function: configure_lldp
23 | vars:
24 | lldp:
25 | - holdtime: 60
26 | reinit: 4
27 | timer: 60
28 | tlv-select: management-address
29 | interface: GigabitEthernet 0/0/0/3
30 | receive: disable
31 | transmit: disable
32 | ```
33 |
34 | The above playbook will set the LLDP with holdtime, reinit, tlv-select, receive,
35 | and transmit to particular interface under the `iosxr` top level key.
36 |
37 | ### Implement using tasks
38 |
39 | The `configure_lldp` function can also be implemented using the `tasks` directive
40 | instead of the `roles` directive. By using the `tasks` directive, you can
41 | control when the fact collection is run.
42 |
43 | Below is an example of how to use the `configure_lldp` function with `tasks`.
44 |
45 | ```
46 | - hosts: iosxr
47 |
48 | tasks:
49 | - name: set lldp to iosxr devices
50 | import_role:
51 | name: ansible-network.cisco_iosxr
52 | tasks_from: configure_lldp
53 | vars:
54 | lldp:
55 | - holdtime: 60
56 | reinit: 4
57 | timer: 60
58 | tlv-select: management-address
59 | interface: GigabitEthernet 0/0/0/3
60 | receive: disable
61 | transmit: disable
62 | ```
63 |
64 | ## Adding new parsers
65 |
66 | Over time new parsers can be added (or updated) to the role to add additional
67 | or enhanced functionality. To add or update parsers perform the following
68 | steps:
69 |
70 | * Add (or update) command parser located in `parse_templates/cli`
71 |
72 | ## Arguments
73 |
74 | ### holdtime
75 |
76 | LLDP holdtime specifies the length of time that information from an LLDP packet should
77 | be held by the receiving device before aging and removing it.
78 |
79 | The default value is `omit` which means even if the user doesn't pass the respective
80 | value the role will continue to run without any failure.
81 |
82 | ### reinit
83 |
84 | LLDP reint specifies the length of time, the initialization of LLDP on an interface should
85 | be delayed.
86 |
87 | The default value is `omit` which means even if the user doesn't pass the respective
88 | value the role will continue to run without any failure.
89 |
90 | ### timer
91 |
92 | LLDP timer specifies the LLDP packet rate.
93 |
94 | The default value is `omit` which means even if the user doesn't pass the respective
95 | value the role will continue to run without any failure.
96 |
97 | ### tlv-select
98 | LLDP tlv-select specifies that transmission of the selected TLV in LLDP packets is disabled.
99 | The tlv-name can be one of these LLDP TLV types:
100 |
101 | * management-address
102 | * port-description
103 | * system-capabilities
104 | * system-description
105 | * system-name
106 |
107 | The default value is `omit` which means even if the user doesn't pass the respective
108 | value the role will continue to run without any failure.
109 |
110 | ### interface
111 |
112 | When you enable LLDP globally on the router, all supported interfaces are automatically
113 | enabled for LLDP receive and transmit operations. It can be overriden by disabling these
114 | operations for a particular interface.
115 |
116 | ### receive
117 |
118 | LLDP receive disables LLDP receive operations on the interface. It can only be set if value
119 | of interface is set as `recieve` operations will be disabled on the respective interface.
120 |
121 | ### transmit
122 |
123 | LLDP receive disables LLDP transmit operations on the interface. It can only be set if value
124 | of interface is set as `transmit` operations will be disabled on the respective interface.
125 |
126 | ### state
127 |
128 | This sets the LLDP value to the Cisco IOS-XR device and if the value of the state is changed
129 | to `absent`, the role will go ahead and try to delete the condifured LLDP via the arguments
130 | passed.
131 |
132 | The default value is `present` which means even if the user doesn't pass the respective
133 | argument, the role will go ahead and try to set the LLDP via the arguments passed to the
134 | Cisco IOS-XR device.
135 |
136 | ## Notes
137 |
138 | None
139 |
--------------------------------------------------------------------------------
/docs/configure_system_properties.md:
--------------------------------------------------------------------------------
1 | # Configure System properties on the device
2 |
3 | The `configure_system_properties` function can be used to set system properties on
4 | Cisco IOS-XR devices. This function is only supported over `network_cli` connection
5 | type and requires the `ansible_network_os` value set to `iosxr`.
6 |
7 | ## How to set System properties on the device
8 |
9 | To set System properties on the device, simply include this function in the playbook
10 | using either the `roles` directive or the `tasks` directive. If no other
11 | options are provided, then all of the available facts will be collected for the
12 | device.
13 |
14 | Below is an example of how to use the `roles` directive to set system properties
15 | on the Cisco IOS-XR device.
16 |
17 | ```
18 | - hosts: iosxr
19 |
20 | roles:
21 | - name ansible-network.cisco_iosxr
22 | function: configure_system_properties
23 | vars:
24 | system_properties:
25 | - hostname: test-iosxr
26 | domain_name: hostname.com
27 | name_server: 192.168.1.1
28 | vrf_name: vrf-01
29 | vrf_description: new vrf named as vrf-01
30 | vrf_address_family: ipv4 multicast
31 | vrf_apply_group: vrf-group
32 | vrf_fallback: vrf-fallback-name
33 | vrf_mode: big
34 | vrf_vpn: id 4:ff
35 | vrf_remote_route_filter: disable
36 | ```
37 |
38 | The above playbook will set the hostname, domain-name and the name-server values to
39 | the host under the `iosxr` top level key.
40 |
41 | ### Implement using tasks
42 |
43 | The `configure_system_properties` function can also be implemented using the `tasks`
44 | directive instead of the `roles` directive. By using the `tasks` directive, you can
45 | control when the fact collection is run.
46 |
47 | Below is an example of how to use the `configure_system_properties` function with `tasks`.
48 |
49 | ```
50 | - hosts: iosxr
51 |
52 | tasks:
53 | - name: set system properties to iosxr devices
54 | import_role:
55 | name: ansible-network.cisco_iosxr
56 | tasks_from: configure_system_properties
57 | vars:
58 | system_properties:
59 | - hostname: test-iosxr
60 | domain_name: hostname.com
61 | name_server: 192.168.1.1
62 | vrf_name: vrf-01
63 | vrf_description: new vrf named as vrf-01
64 | vrf_address_family: ipv4 multicast
65 | vrf_apply_group: vrf-group
66 | vrf_fallback: vrf-fallback-name
67 | vrf_mode: big
68 | vrf_vpn: id 4:ff
69 | vrf_remote_route_filter: disable
70 | ```
71 |
72 | ## Adding new parsers
73 |
74 | Over time new parsers can be added (or updated) to the role to add additional
75 | or enhanced functionality. To add or update parsers perform the following
76 | steps:
77 |
78 | * Add (or update) command parser located in `parse_templates/cli`
79 |
80 | ## Arguments
81 |
82 | ### hostname
83 |
84 | This will set the System host name for the Cisco IOS-XR device.
85 |
86 | The default value is `omit` which means even if the user doesn't pass the respective
87 | value the role will continue to run without any failure.
88 |
89 | ### domain_name
90 |
91 | This will set the System domain name for the Cisco IOS-XR device.
92 |
93 | The default value is `omit` which means even if the user doesn't pass the respective
94 | value the role will continue to run without any failure.
95 |
96 | ### name_server
97 |
98 | This will set the Domain Name Server (DNS) for the Cisco IOS-XR device.
99 |
100 | The default value is `omit` which means even if the user doesn't pass the respective
101 | value the role will continue to run without any failure.
102 |
103 | ### vrf_name
104 |
105 | VRF name that need to be configured for the Cisco IOS-XR device. Also, this is mandatory
106 | parameter for VRF configuration.
107 |
108 | The default value is `omit` which means even if the user doesn't pass the respective
109 | value the role will continue to run without any failure.
110 |
111 | ### vrf_description
112 |
113 | A description for the VRF to be configured for the Cisco IOS-XR device.
114 |
115 | The default value is `omit` which means even if the user doesn't pass the respective
116 | value the role will continue to run without any failure.
117 |
118 | ### vrf_address_family
119 |
120 | AFI/SAFI configuration for the VRF to be configured for the Cisco IOS-XR device.
121 |
122 | The default value is `omit` which means even if the user doesn't pass the respective
123 | value the role will continue to run without any failure.
124 |
125 | ### vrf_apply_group
126 |
127 | Apply configuration from a group to be configured for the Cisco IOS-XR device.
128 |
129 | The default value is `omit` which means even if the user doesn't pass the respective
130 | value the role will continue to run without any failure.
131 |
132 | ### vrf_fallback
133 |
134 | Fallback vrf for the VRF to be configured for the Cisco IOS-XR device.
135 |
136 | The default value is `omit` which means even if the user doesn't pass the respective
137 | value the role will continue to run without any failure.
138 |
139 | ### vrf_mode
140 |
141 | VRF mode which determines the max prefix scale.
142 |
143 | The default value is `omit` which means even if the user doesn't pass the respective
144 | value the role will continue to run without any failure.
145 |
146 | ### vrf_vpn
147 |
148 | VPN ID for the VRF to be configured for the Cisco IOS-XR device.
149 |
150 | The default value is `omit` which means even if the user doesn't pass the respective
151 | value the role will continue to run without any failure.
152 |
153 | ### vrf_remote_route_filter:
154 |
155 | Enable/Disable remote route filtering per VRF.
156 |
157 | The default value is `omit` which means even if the user doesn't pass the respective
158 | value the role will continue to run without any failure.
159 |
160 | ### state
161 |
162 | This will set the hostname, domain-name, name-server and VRF value to the Cisco IOS-XR
163 | device and if the value of the state is changed to `absent`, role will go ahead and try
164 | to delete the hostname, domain-name, name-server and VRF passed via the arguments.
165 |
166 | The default value is `present` which means even if the user doesn't pass the respective
167 | argument, the role will go ahead and try to set the hostname, domain-name, name-server
168 | and VRF via the arguments passed to the Cisco IOS-XR device.
169 |
170 | ## Notes
171 |
172 | None
173 |
--------------------------------------------------------------------------------
/docs/configure_vlans.md:
--------------------------------------------------------------------------------
1 | # Configure VLANs on the device
2 |
3 | The `configure_vlans` function can be used to set VLANs on Cisco IOS-XR devices.
4 | This function is only supported over `network_cli` connection type and
5 | requires the `ansible_network_os` value set to `iosxr`.
6 |
7 | ## How to set VLANs on the device
8 |
9 | To set VLANs on the device, simply include this function in the playbook
10 | using either the `roles` directive or the `tasks` directive. If no other
11 | options are provided, then all of the available facts will be collected for
12 | the device.
13 |
14 | Below is an example of how to use the `roles` directive to set VLANs on the
15 | Cisco IOS-XR device.
16 |
17 | ```
18 | - hosts: iosxr
19 |
20 | roles:
21 | - name ansible-network.cisco_iosxr
22 | function: configure_vlans
23 | vars:
24 | vlans:
25 | - interface: Gi0/0/0/3
26 | id: 10
27 | description: this is vlan 10
28 | ipaddr: 192.168.1.0/24
29 | ```
30 |
31 | The above playbook will set the VLANs with ID, description, and address to particular
32 | interface under the `iosxr` top level key.
33 |
34 | ### Implement using tasks
35 |
36 | The `configure_vlans` function can also be implemented using the `tasks` directive
37 | instead of the `roles` directive. By using the `tasks` directive, you can
38 | control when the fact collection is run.
39 |
40 | Below is an example of how to use the `configure_vlans` function with `tasks`.
41 |
42 | ```
43 | - hosts: iosxr
44 |
45 | tasks:
46 | - name: set vlans to iosxr devices
47 | import_role:
48 | name: ansible-network.cisco_iosxr
49 | tasks_from: configure_vlans
50 | vars:
51 | vlans:
52 | - interface: Gi0/0/0/3
53 | id: 10
54 | description: this is vlan 10
55 | ipaddr: 192.168.1.0/24
56 | ```
57 |
58 | ## Adding new parsers
59 |
60 | Over time new parsers can be added (or updated) to the role to add additional
61 | or enhanced functionality. To add or update parsers perform the following
62 | steps:
63 |
64 | * Add (or update) command parser located in `parse_templates/cli`
65 |
66 | ## Arguments
67 |
68 | ### interface
69 |
70 | VLAN will be configured on the Cisco IOS-XR device using respective interface and hence
71 | this is a mandatory parameter.
72 |
73 | This being a mandatory parameter which means even if the user doesn't pass the respective
74 | argument the role will fail to run with missing argument error.
75 |
76 | ### id
77 |
78 | VLAN will be configured on the Cisco IOS-XR device using respective ID over the interface
79 | and this is also a mandatory parameter.
80 |
81 | This being a mandatory parameter which means even if the user doesn't pass the respective
82 | argument the role will fail to run with missing argument error. Also, valid VLANs id
83 | range is 1-4094, so the role checks if the user value for the argument matches the range
84 | and if not the execution of the role fails with id range error
85 |
86 | ### description
87 |
88 | This sets the description for the VLAN Id for the Cisco IOS-XR device.
89 |
90 | The default value is `omit` which means even if the user doesn't pass the respective
91 | value the role will continue to run without any failure.
92 |
93 | ### ipaddr
94 |
95 | This sets the ip address for the VLAN Id for the Cisco IOS-XR device.
96 |
97 | The default value is `omit` which means even if the user doesn't pass the respective
98 | value the role will continue to run without any failure.
99 |
100 | ### state
101 |
102 | This sets the VLANs value to the Cisco IOS-XR device and if the value of the state is changed
103 | to `absent`, the role will go ahead and try to delete the VLANs via the arguments passed.
104 |
105 | The default value is `present` which means even if the user doesn't pass the respective
106 | argument, the role will go ahead and try to set the VLANs via the arguments passed to the
107 | Cisco IOS-XR device.
108 |
109 | ## Notes
110 |
111 | None
112 |
--------------------------------------------------------------------------------
/docs/get_facts.md:
--------------------------------------------------------------------------------
1 | # Get facts from device
2 |
3 | The `get_facts` function can be used to collect facts from an Cisco iosxr-XR
4 | devices. This function is only supported over `network_cli` connection
5 | type and requires the `ansible_network_os` value set to `iosxr`.
6 |
7 | ## How to get facts from the device
8 |
9 | To collect facts from the device, simply include this function in the playbook
10 | using either the `roles` directive or the `tasks` directive. If no other
11 | options are provided, then all of the available facts will be collected for the
12 | device.
13 |
14 | Below is an example of how to use the `roles` directive to collect all facts
15 | from the iosxr-XR device.
16 |
17 | ```
18 | - hosts: cisco_iosxr
19 |
20 | roles:
21 | - name ansible-network.cisco_iosxr
22 | function: get_facts
23 | ```
24 |
25 | The above playbook will return the facts for the host under the `cisco_iosxr`
26 | top level key.
27 |
28 | ### Filter the subset of facts returned
29 |
30 | By default all available facts will be returned by the `get_facts` function.
31 | If you only want to return a subset of the facts, you can specify the `subset`
32 | variable and set one or more sub keys to return.
33 |
34 | For instance, the below will return only `interfaces` and `system` facts.
35 |
36 | ```
37 | - hosts: cisco_iosxr
38 |
39 | roles:
40 | - name ansible-network.cisco_iosxr
41 | function: get_facts
42 | subset:
43 | - interfaces
44 | - system
45 | ```
46 |
47 | ### Implement using tasks
48 |
49 | The `get_facts` function can also be implemented using the `tasks` directive
50 | instead of the `roles` directive. By using the `tasks` directive, you can
51 | control when the fact collection is run.
52 |
53 | Below is an example of how to use the `get_facts` function with `tasks`.
54 |
55 | ```
56 | - hosts: cisco_iosxr
57 |
58 | tasks:
59 | - name: collect facts from cisco iosxr devices
60 | import_role:
61 | name: ansible-network.cisco_iosxr
62 | tasks_from: get_facts
63 | vars:
64 | subset:
65 | - system
66 | - interfaces
67 | ```
68 |
69 | ## Adding new parsers
70 |
71 | Over time new parsers can be added (or updated) to the role to add additional
72 | or enhanced functionality. To add or update parsers perform the following
73 | steps:
74 |
75 | * Add (or update) command parser located ino `parse_templates/cli`
76 |
77 | * Update the `vars/get_facts_command_map.yaml` file to map the CLI command
78 | to the parser
79 |
80 | The `get_facts_command_map.yaml` file provides a mapping between CLI command
81 | and parser used to transform the output into Ansible facts.
82 |
83 | ### Understanding the mapping file
84 |
85 | The command map file provides the mapping between show command and parser file.
86 | The format of the file is a list of objects. Each object supports a set of
87 | keys that can be configured to provide granular control over how each command
88 | is implemented.
89 |
90 | Command map entries support the following keys:
91 |
92 | #### command
93 |
94 | The `command` key is required and specifies the actual CLI command to execute
95 | on the target device. The output from the command is then passed to the parser
96 | for further processing.
97 |
98 | #### parser
99 |
100 | The `parser` key provides the name of the parser used to accept the output from
101 | the command. The parser value shoule be the command parser filename either
102 | relative to `parser_templates/cli` or absolute path. This value is required.
103 |
104 | #### engine
105 |
106 | This key accepts one of two values, either `command_parser` or `textfsm_parser`.
107 | This value instructs the the parsing function as to which parsing engine to
108 | use to parse the output from the CLI command.
109 |
110 | This key is not required and, if not provided, the engine will assumed to be
111 | `command_parser`
112 |
113 | #### groups
114 |
115 | Commands can be contained in one (or more) groups to make it easy for playbook
116 | designers to filter specific facts to retreive from the network device. The
117 | `groups` key must be a list and contain the groups the this command should be
118 | associated with.
119 |
120 | #### pre_hook
121 |
122 | The `pre_hook` key provides the path to the set of tasks to include prior
123 | to running the command on the CLI. This is useful if there is a need to check
124 | if a command is available or supported on a particular version.
125 |
126 | #### post_hook
127 |
128 | The `post_hook` key provides the path to the set of tasks to include after the
129 | command has been run on the target device and its results have been parsed by
130 | the parser.
131 |
132 | ## Arguments
133 |
134 | ### iosxr_get_facts_subset
135 |
136 | Defines the subset of facts to collection when the `get_facts` function is
137 | called. This value must be a list value and contain only the sub keys for the
138 | facts you wish to return.
139 |
140 | The default value is `all`
141 |
142 | #### Aliases
143 |
144 | * subset
145 |
146 | #### Current supported values for subset are
147 |
148 | * default
149 | * interfaces
150 |
151 | ### iosxr_get_facts_command_map
152 |
153 | Defines the command / parser mapping file to use when the call to `get_facts`
154 | is made by the playbook. Normally this value does not need to be modified but
155 | can be used to pass a custom command map to the function.
156 |
157 | The default value is `vars/get_facts_command_map.yaml`
158 |
159 |
160 | ## Notes
161 |
162 | None
163 |
164 |
165 |
--------------------------------------------------------------------------------
/includes/configure/configure.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | # configure
3 | #
4 | - name: load configuration
5 | block:
6 | - name: enter configuration mode
7 | cli:
8 | command: configure
9 |
10 | - name: load configuration lines
11 | cli:
12 | command: "{{ line.strip() }}"
13 | loop: "{{ iosxr_config_text | to_lines }}"
14 | loop_control:
15 | loop_var: line
16 |
17 | - name: check the config diff before committing
18 | cli:
19 | command: show commit changes diff
20 | register: iosxr_config_diff
21 |
22 | - name: display config diff
23 | debug:
24 | msg: "{{ iosxr_config_diff.stdout.splitlines() }}"
25 |
26 | - name: commit the configuration only if there is difference
27 | cli:
28 | command: commit
29 | when: iosxr_config_diff.stdout.splitlines()|length > 3
30 | changed_when: true
31 |
32 | - name: abort the configuration due to check mode
33 | cli:
34 | command: abort
35 | when: ansible_check_mode
36 |
37 | - name: end the configuration session
38 | cli:
39 | command: end
40 | when: not ansible_check_mode
41 |
42 | rescue:
43 | - name: abort configuration
44 | cli:
45 | command: abort
46 |
47 | - name: mark the host as failed
48 | fail:
49 | msg: "error loading configuration onto target device"
50 |
--------------------------------------------------------------------------------
/includes/init.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: set the role version
3 | set_fact:
4 | ansible_network_iosxr_path: "{{ role_path }}"
5 | ansible_network_iosxr_version: "devel"
6 |
7 | - name: display the role version to stdout
8 | debug:
9 | msg: "ansible_network.cisco_iosxr version {{ ansible_network_iosxr_version }}"
10 |
11 | - name: validate ansible_network_os == 'iosxr'
12 | fail:
13 | msg: "expected ansible_network_os to be `iosxr`, got `{{ ansible_network_os }}`"
14 | when: ansible_network_os != 'iosxr'
15 |
16 | - name: validate ansible_connection == 'network_cli'
17 | fail:
18 | msg: "expected ansible_network to be `network_cli`, got `{{ ansible_connection }}`"
19 | when: ansible_connection != 'network_cli'
20 |
21 | - name: set ansible_provider_functions fact
22 | set_fact:
23 | ansible_network_provider_functions:
24 | - get_facts
25 | - configure_user
26 | - configure_vlan
27 | - configure_system_properties
28 | - configure_lldp
29 |
30 | - name: read ansible_min_version from meta data
31 | include_vars:
32 | file: ../meta/main.yml
33 | name: ansible_galaxy_meta
34 |
35 | - name: display minimun Network Engine version
36 | debug:
37 | msg: "This role requires Ansible Network Engine {{ ansible_galaxy_meta.galaxy_info.min_ansible_network_engine_version }} or higher."
38 |
39 | - name: validate minimum Ansible version
40 | fail:
41 | msg: "This role requires Ansible {{ ansible_galaxy_meta.galaxy_info.min_ansible_version }} or higher. You are currently running Ansible {{ ansible_version.full }}."
42 | when: 'ansible_version.full is version_compare(ansible_galaxy_meta.galaxy_info.min_ansible_version, "<")'
43 |
--------------------------------------------------------------------------------
/includes/run_cli.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: run cli command pre hook
3 | include_tasks: "{{ iosxr_run_cli_command_pre_hook }}"
4 | when: iosxr_run_cli_command_pre_hook is defined and iosxr_run_cli_command_pre_hook
5 |
6 | - name: run command and parse output
7 | cli:
8 | command: "{{ iosxr_command }}"
9 | parser: "{{ parser }}"
10 | engine: "{{ iosxr_parser_engine | default(None) }}"
11 | with_first_found:
12 | - files:
13 | - "{{ iosxr_parser }}"
14 | paths:
15 | - "{{ playbook_dir }}/parser_templates/iosxr"
16 | - "~/.ansible/ansible_network/parser_templates/iosxr"
17 | - "/etc/ansible/ansible_network/parser_templates/iosxr"
18 | - "{{ role_path }}/parser_templates"
19 | loop_control:
20 | loop_var: parser
21 |
22 | - name: run cli command post hook
23 | include_tasks: "{{ iosxr_run_cli_command_post_hook }}"
24 | when: iosxr_run_cli_command_post_hook is defined and iosxr_run_cli_command_post_hook
25 |
--------------------------------------------------------------------------------
/library/iosxr_bgp.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Ansible is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Ansible is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with Ansible. If not, see .
17 | #
18 |
19 | ANSIBLE_METADATA = {'metadata_version': '1.1',
20 | 'status': ['preview'],
21 | 'supported_by': 'network'}
22 |
23 |
24 | DOCUMENTATION = """
25 | ---
26 | module: iosxr_bgp
27 | version_added: "2.8"
28 | author: "Nilashish Chakraborty (@nilashishc)"
29 | short_description: Configure global BGP protocol settings on Cisco IOS-XR
30 | description:
31 | - This module provides configuration management of global BGP parameters
32 | on devices running Cisco IOS-XR
33 | notes:
34 | - Tested against Cisco IOS XR Software Version 6.1.3
35 | options:
36 | bgp_as:
37 | description:
38 | - Specifies the BGP Autonomous System number to configure on the device
39 | type: int
40 | required: true
41 | router_id:
42 | description:
43 | - Configures the BGP routing process router-id value
44 | default: null
45 | log_neighbor_changes:
46 | description:
47 | - Enable/disable logging neighbor up/down and reset reason
48 | type: bool
49 | neighbors:
50 | description:
51 | - Specifies BGP neighbor related configurations
52 | suboptions:
53 | neighbor:
54 | description:
55 | - Neighbor router address
56 | required: True
57 | remote_as:
58 | description:
59 | - Remote AS of the BGP neighbor to configure
60 | type: int
61 | required: True
62 | update_source:
63 | description:
64 | - Source of the routing updates
65 | password:
66 | description:
67 | - Password to authenticate BGP peer connection
68 | enabled:
69 | description:
70 | - Administratively shutdown or enable a neighbor
71 | type: bool
72 | description:
73 | description:
74 | - Neighbor specific description
75 | advertisement_interval:
76 | description:
77 | - Specifies the minimum interval (in seconds) between sending BGP routing updates
78 | - The range is from 0 to 600
79 | type: int
80 | tcp_mss:
81 | description:
82 | - Specifies the TCP initial maximum segment size to use
83 | - The range is from 68 to 10000
84 | type: int
85 | ebgp_multihop:
86 | description:
87 | - Specifies the maximum hop count for EBGP neighbors not on directly connected networks
88 | - The range is from 0 to 255.
89 | type: int
90 | use_neighbor_group:
91 | description:
92 | - Name of the neighbor group that the neighbor is a member of
93 | timers:
94 | description:
95 | - Specifies BGP neighbor timer related configurations
96 | suboptions:
97 | keepalive:
98 | description:
99 | - Frequency with which the Cisco IOS-XR software sends keepalive messages to its peer.
100 | - The range is from 0 to 65535.
101 | type: int
102 | required: True
103 | holdtime:
104 | description:
105 | - Interval after not receiving a keepalive message that the software declares a peer dead.
106 | - The range is from 3 to 65535.
107 | type: int
108 | required: True
109 | min_neighbor_holdtime:
110 | description:
111 | - Interval specifying the minimum acceptable hold-time from a BGP neighbor.
112 | - The minimum acceptable hold-time must be less than, or equal to, the interval specified in the holdtime argument.
113 | - The range is from 3 to 65535.
114 | type: int
115 | state:
116 | description:
117 | - Specifies the state of the BGP neighbor
118 | default: present
119 | choices:
120 | - present
121 | - absent
122 | neighbor_groups:
123 | description:
124 | - Specifies BGP neighbor group related configurations
125 | suboptions:
126 | name:
127 | description:
128 | - Specifies the name of the neighbor group
129 | required: True
130 | remote_as:
131 | description:
132 | - Remote AS to be assigned to neighbors that belong to this neighbor group
133 | type: int
134 | update_source:
135 | description:
136 | - Source of the routing updates for neighbor that belong to this neighbor group
137 | password:
138 | description:
139 | - Password to authenticate BGP peer connection
140 | enabled:
141 | description:
142 | - Administratively shutdown or enable a neighbor
143 | type: bool
144 | description:
145 | description:
146 | - Neighbor specific description
147 | ebgp_multihop:
148 | description:
149 | - Specifies the maximum hop count for EBGP neighbors not on directly connected networks
150 | - The range is from 0 to 255.
151 | advertisement_interval:
152 | description:
153 | - Specifies the minimum interval (in seconds) between sending BGP routing updates
154 | - The range is from 0 to 600
155 | type: int
156 | tcp_mss:
157 | description:
158 | - Specifies the TCP initial maximum segment size to use
159 | - The range is from 68 to 10000
160 | type: int
161 | use_neighbor_group:
162 | description:
163 | - Specify neighbor group to inherit configurations from
164 | timers:
165 | description:
166 | - Specifies BGP neighbor timer related configurations for neighbors belonging to this neighbor group
167 | suboptions:
168 | keepalive:
169 | description:
170 | - Frequency with which the Cisco IOS-XR software sends keepalive messages to its peer.
171 | - The range is from 0 to 65535.
172 | type: int
173 | required: True
174 | holdtime:
175 | description:
176 | - Interval after not receiving a keepalive message that the software declares a peer dead.
177 | - The range is from 3 to 65535.
178 | type: int
179 | required: True
180 | min_neighbor_holdtime:
181 | description:
182 | - Interval specifying the minimum acceptable hold-time from a BGP neighbor.
183 | - The minimum acceptable hold-time must be less than, or equal to, the interval specified in the holdtime argument.
184 | - The range is from 3 to 65535.
185 | type: int
186 | state:
187 | description:
188 | - Specifies the state of the BGP neighbor group
189 | default: present
190 | choices:
191 | - present
192 | - absent
193 | address_families:
194 | description:
195 | - Specifies BGP address family related configurations
196 | suboptions:
197 | name:
198 | description:
199 | - Type of address family to configure
200 | choices:
201 | - ipv4
202 | - ipv6
203 | required: True
204 | cast:
205 | description:
206 | - Specifies the type of cast for the address family
207 | choices:
208 | - flowspec
209 | - unicast
210 | - multicast
211 | - labeled-unicast
212 | default: unicast
213 | redistribute:
214 | description:
215 | - Specifies the redistribute information from another routing protocol
216 | suboptions:
217 | protocol:
218 | description:
219 | - Specifies the protocol for configuring redistribute information
220 | choices:
221 | - ospf
222 | - eigrp
223 | - isis
224 | - static
225 | - connected
226 | - lisp
227 | - mobile
228 | - rip
229 | - subscriber
230 | required: True
231 | id:
232 | description:
233 | - Identifier for the routing protocol for configuring redistribute information
234 | - Required only when protocol is in ['ospf', 'eigrp', 'isis']
235 | metric:
236 | description:
237 | - Specifies the metric for redistributed routes
238 | route_map:
239 | description:
240 | - Specifies the route map reference
241 | state:
242 | description:
243 | - Specifies the state of redistribution
244 | default: present
245 | choices:
246 | - present
247 | - absent
248 | networks:
249 | description:
250 | - Specify networks to announce via BGP
251 | suboptions:
252 | network:
253 | description:
254 | - Network ID to announce via BGP
255 | required: True
256 | mask:
257 | description:
258 | - Subnet mask for the network to announce
259 | route_map:
260 | description:
261 | - Route map to modify the attributes
262 | state:
263 | description:
264 | - Specifies the state of network
265 | default: present
266 | choices:
267 | - present
268 | - absent
269 | state:
270 | description:
271 | - Specifies the state of address family
272 | default: present
273 | choices:
274 | - present
275 | - absent
276 | state:
277 | description:
278 | - Specifies the state of the BGP process configured on the device
279 | default: present
280 | choices:
281 | - present
282 | - absent
283 | - replace
284 | """
285 |
286 | EXAMPLES = """
287 | - name: configure global bgp as 65000
288 | iosxr_bgp:
289 | bgp_as: 65000
290 | router_id: 1.1.1.1
291 | neighbors:
292 | - neighbor: 182.168.10.1
293 | remote_as: 500
294 | description: PEER_1
295 | - neighbor: 192.168.20.1
296 | remote_as: 500
297 | update_source: GigabitEthernet 0/0/0/0
298 | address_families:
299 | - name: ipv4
300 | cast: unicast
301 | networks:
302 | - network: 192.168.2.0/23
303 | - network: 10.0.0.0/8
304 | redistribute:
305 | - protocol: ospf
306 | id: 400
307 | metric: 110
308 |
309 | - name: remove bgp as 65000 from config
310 | ios_bgp:
311 | bgp_as: 65000
312 | state: absent
313 | """
314 |
315 | RETURN = """
316 | commands:
317 | description: The list of configuration mode commands to send to the device
318 | returned: always
319 | type: list
320 | sample:
321 | - router bgp 65000
322 | - bgp router-id 1.1.1.1
323 | - neighbor 182.168.10.1 remote-as 500
324 | - neighbor 182.168.10.1 description PEER_1
325 | - neighbor 192.168.20.1 remote-as 500
326 | - neighbor 192.168.20.1 update-source GigabitEthernet0/0/0/0
327 | - address-family ipv4 unicast
328 | - redistribute ospf 400 metric 110
329 | - network 192.168.2.0/23
330 | - network 10.0.0.0/8
331 | - exit
332 | """
333 | from ansible.module_utils.basic import AnsibleModule
334 | from ansible.module_utils.network.iosxr.iosxr import get_config, load_config
335 | from ansible.module_utils.network.iosxr.config.bgp import get_bgp_as
336 | from ansible.module_utils.network.iosxr.config.bgp.process import BgpProcess
337 | from ansible.module_utils.network.iosxr.iosxr import iosxr_argument_spec
338 |
339 |
340 | def main():
341 | """ main entry point for module execution
342 | """
343 | argument_spec = BgpProcess.argument_spec
344 | argument_spec.update(iosxr_argument_spec)
345 |
346 | module = AnsibleModule(argument_spec=argument_spec,
347 | supports_check_mode=True)
348 |
349 | config = get_config(module, config_filter='router bgp')
350 |
351 | result = {'changed': False}
352 | commands = list()
353 |
354 | bgp_as = get_bgp_as(config)
355 |
356 | if all((module.params['bgp_as'] is None, bgp_as is None)):
357 | module.fail_json(msg='missing required argument: bgp_as')
358 | elif module.params['bgp_as'] is None and bgp_as:
359 | module.params['bgp_as'] = bgp_as
360 |
361 | process = BgpProcess(**module.params)
362 |
363 | resp = process.render(config)
364 | if resp:
365 | commands.extend(resp)
366 | if commands:
367 | if not module.check_mode:
368 | load_config(module, commands, commit=True)
369 | result['changed'] = True
370 |
371 | result['commands'] = commands
372 |
373 | module.exit_json(**result)
374 |
375 |
376 | if __name__ == '__main__':
377 | main()
378 |
--------------------------------------------------------------------------------
/library/iosxr_capabilities.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Ansible is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Ansible is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with Ansible. If not, see .
17 | #
18 |
19 | ANSIBLE_METADATA = {'metadata_version': '1.1',
20 | 'status': ['preview'],
21 | 'supported_by': 'network'}
22 |
23 |
24 | DOCUMENTATION = """
25 | ---
26 | module: iosxr_capabilities
27 | version_added: "2.7"
28 | short_description: Collect device capabilities from Cisco IOS-XR
29 | description:
30 | - Collect basic fact capabilities from Cisco NX-OS devices and return
31 | the capabilities as Ansible facts.
32 | author:
33 | - Ansible Netowrk Community (ansible-network)
34 | options: {}
35 | """
36 |
37 | EXAMPLES = """
38 | - facts:
39 | """
40 |
41 | RETURN = """
42 | """
43 | from ansible.module_utils.basic import AnsibleModule
44 | from ansible.module_utils.connection import Connection
45 |
46 | def main():
47 | """ main entry point for Ansible module
48 | """
49 | argument_spec = {}
50 |
51 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
52 |
53 | connection = Connection(module._socket_path)
54 | facts = connection.get_capabilities()
55 | facts = module.from_json(facts)
56 | result = {
57 | 'changed': False,
58 | 'ansible_facts': {'cisco_iosxr': {'capabilities': facts['device_info']}}
59 | }
60 | module.exit_json(**result)
61 |
62 |
63 | if __name__ == '__main__':
64 | main()
65 |
--------------------------------------------------------------------------------
/library/iosxr_user_manager.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 |
4 | # Copyright 2018 Red Hat
5 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6 |
7 | from __future__ import absolute_import, division, print_function
8 | __metaclass__ = type
9 |
10 |
11 | ANSIBLE_METADATA = {'metadata_version': '1.1',
12 | 'status': ['preview'],
13 | 'supported_by': 'network'}
14 |
15 |
16 | DOCUMENTATION = '''
17 | ---
18 | module: iosxr_user_manager
19 | short_description: Manage an aggregate of users in Cisco IOSXR device(s)
20 | description:
21 | - Allows the `cisco_iosxr` provider role to manage aggregate of users
22 | by providing idempotency and other utility functions while running
23 | the `configure_user` task.
24 | version_added: "2.7"
25 | options:
26 | new_users:
27 | description:
28 | - Aggregate of local users to be configured on iosxr device(s)
29 | required: true
30 | user_config:
31 | description:
32 | - User config lines extracted from the devices' running-configuration.
33 | required: true
34 | author:
35 | - Nilashish Chakraborty (@NilashishC)
36 | '''
37 | RETURN = """
38 | stdout:
39 | description: Filtered set of users that should be configured on the device
40 | returned: always apart from low-level errors (such as action plugin)
41 | type: list
42 | sample: [{"name": "ansible", "group": root-system}, {"name": "test_user", "group": net-admin}]
43 | """
44 | EXAMPLES = '''
45 | - iosxr_user_manager:
46 | new_users: "{{ users }}"
47 | user_config: "{{ existing_user_config.stdout }}"
48 | '''
49 |
--------------------------------------------------------------------------------
/meta/load_config_spec.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | argument_spec:
3 | ansible_network_os:
4 | description:
5 | - Set the name of Ansible network os platform. This value should be
6 | set to `iosxr` for this provider role.
7 | required: true
8 |
9 | iosxr_config_text:
10 | description:
11 | - Provide the network device configuration as a single string. The
12 | configuration text will be loaded onto the target network device.
13 | type: str
14 | aliases:
15 | - config_text
16 |
17 | iosxr_config_file:
18 | description:
19 | - Provide relative or absolute path to the configuration file to be
20 | loaded onto the target network device.
21 | type: str
22 | aliases:
23 | - config_file
24 |
25 | mutually_exclusive:
26 | - ['iosxr_config_text', 'iosxr_config_file']
27 |
28 | required_one_of:
29 | - ['iosxr_config_text', 'iosxr_config_file']
30 |
--------------------------------------------------------------------------------
/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: Ansible Network Community (ansible-network)
4 | description: Ansible role for managing Cisco IOS-XR devices
5 | company: Ansible
6 |
7 | license: GPLv3
8 |
9 | min_ansible_version: 2.7
10 | min_ansible_network_engine_version: 2.6.2
11 |
12 | # If this a Container Enabled role, provide the minimum Ansible Container version.
13 | # min_ansible_container_version:
14 |
15 | # Optionally specify the branch Galaxy will use when accessing the GitHub
16 | # repo for this role. During role install, if no tags are available,
17 | # Galaxy will use this branch. During import Galaxy will access files on
18 | # this branch. If Travis integration is configured, only notifications for this
19 | # branch will be accepted. Otherwise, in all cases, the repo's default branch
20 | # (usually master) will be used.
21 | # github_branch:
22 |
23 | #
24 | # platforms is a list of platforms, and each platform has a name and a list of versions.
25 | #
26 | platforms:
27 | - name: iosxr
28 | version:
29 | - any
30 |
31 | galaxy_tags:
32 | - network
33 | - cisco
34 | - iosxr
35 |
36 | dependencies:
37 | - ansible-network.network-engine
38 |
--------------------------------------------------------------------------------
/module_utils/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ansible-network/cisco_iosxr/0ce44d0a539c05340e7641915785abe73712e8ff/module_utils/__init__.py
--------------------------------------------------------------------------------
/module_utils/network/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ansible-network/cisco_iosxr/0ce44d0a539c05340e7641915785abe73712e8ff/module_utils/network/__init__.py
--------------------------------------------------------------------------------
/module_utils/network/iosxr/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ansible-network/cisco_iosxr/0ce44d0a539c05340e7641915785abe73712e8ff/module_utils/network/iosxr/__init__.py
--------------------------------------------------------------------------------
/module_utils/network/iosxr/config/__init__.py:
--------------------------------------------------------------------------------
1 | # This code is part of Ansible, but is an independent component.
2 | # This particular file snippet, and this file snippet only, is BSD licensed.
3 | # Modules you write using this snippet, which is embedded dynamically by Ansible
4 | # still belong to the author of the module, and may assign their own license
5 | # to the complete work.
6 | #
7 | # (c) 2016 Red Hat Inc.
8 | #
9 | # Redistribution and use in source and binary forms, with or without modification,
10 | # are permitted provided that the following conditions are met:
11 | #
12 | # * Redistributions of source code must retain the above copyright
13 | # notice, this list of conditions and the following disclaimer.
14 | # * Redistributions in binary form must reproduce the above copyright notice,
15 | # this list of conditions and the following disclaimer in the documentation
16 | # and/or other materials provided with the distribution.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
26 | # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | #
28 | from ansible.module_utils.six import iteritems
29 | from ansible.module_utils.network.common.utils import to_list
30 | from ansible.module_utils.network.common.config import NetworkConfig
31 |
32 |
33 | class ConfigBase(object):
34 |
35 | argument_spec = {}
36 |
37 | mutually_exclusive = []
38 |
39 | identifier = ()
40 |
41 | def __init__(self, **kwargs):
42 | self.values = {}
43 | self._rendered_configuration = {}
44 | self.active_configuration = None
45 |
46 | for item in self.identifier:
47 | self.values[item] = kwargs.pop(item)
48 |
49 | for key, value in iteritems(kwargs):
50 | if key in self.argument_spec:
51 | setattr(self, key, value)
52 |
53 | for key, value in iteritems(self.argument_spec):
54 | if value.get('default'):
55 | if not getattr(self, key, None):
56 | setattr(self, key, value.get('default'))
57 |
58 | def __getattr__(self, key):
59 | if key in self.argument_spec:
60 | return self.values.get(key)
61 |
62 | def __setattr__(self, key, value):
63 | if key in self.argument_spec:
64 | if key in self.identifier:
65 | raise TypeError('cannot set value')
66 | elif value is not None:
67 | self.values[key] = value
68 | else:
69 | super(ConfigBase, self).__setattr__(key, value)
70 |
71 | def context_config(self, cmd):
72 | if 'context' not in self._rendered_configuration:
73 | self._rendered_configuration['context'] = list()
74 | self._rendered_configuration['context'].extend(to_list(cmd))
75 |
76 | def global_config(self, cmd):
77 | if 'global' not in self._rendered_configuration:
78 | self._rendered_configuration['global'] = list()
79 | self._rendered_configuration['global'].extend(to_list(cmd))
80 |
81 | def get_rendered_configuration(self):
82 | config = list()
83 | for section in ('context', 'global'):
84 | config.extend(self._rendered_configuration.get(section, []))
85 | return config
86 |
87 | def set_active_configuration(self, config):
88 | self.active_configuration = config
89 |
90 | def render(self, config=None):
91 | raise NotImplementedError
92 |
93 | def get_section(self, config, section):
94 | if config is not None:
95 | netcfg = NetworkConfig(indent=1, contents=config)
96 | try:
97 | config = netcfg.get_block_config(to_list(section))
98 | except ValueError:
99 | config = None
100 | return config
101 |
--------------------------------------------------------------------------------
/module_utils/network/iosxr/config/bgp/__init__.py:
--------------------------------------------------------------------------------
1 | # This code is part of Ansible, but is an independent component.
2 | # This particular file snippet, and this file snippet only, is BSD licensed.
3 | # Modules you write using this snippet, which is embedded dynamically by Ansible
4 | # still belong to the author of the module, and may assign their own license
5 | # to the complete work.
6 | #
7 | # (c) 2016 Red Hat Inc.
8 | #
9 | # Redistribution and use in source and binary forms, with or without modification,
10 | # are permitted provided that the following conditions are met:
11 | #
12 | # * Redistributions of source code must retain the above copyright
13 | # notice, this list of conditions and the following disclaimer.
14 | # * Redistributions in binary form must reproduce the above copyright notice,
15 | # this list of conditions and the following disclaimer in the documentation
16 | # and/or other materials provided with the distribution.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
26 | # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | #
28 | import re
29 |
30 |
31 | def get_bgp_as(config):
32 | match = re.search(r'^router bgp (\d+)', config, re.M)
33 | if match:
34 | return int(match.group(1))
35 |
--------------------------------------------------------------------------------
/module_utils/network/iosxr/config/bgp/address_family.py:
--------------------------------------------------------------------------------
1 | # This code is part of Ansible, but is an independent component.
2 | # This particular file snippet, and this file snippet only, is BSD licensed.
3 | # Modules you write using this snippet, which is embedded dynamically by Ansible
4 | # still belong to the author of the module, and may assign their own license
5 | # to the complete work.
6 | #
7 | # (c) 2016 Red Hat Inc.
8 | #
9 | # Redistribution and use in source and binary forms, with or without modification,
10 | # are permitted provided that the following conditions are met:
11 | #
12 | # * Redistributions of source code must retain the above copyright
13 | # notice, this list of conditions and the following disclaimer.
14 | # * Redistributions in binary form must reproduce the above copyright notice,
15 | # this list of conditions and the following disclaimer in the documentation
16 | # and/or other materials provided with the distribution.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
26 | # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | #
28 | from ansible.module_utils.network.common.utils import to_list
29 | from ansible.module_utils.network.iosxr.config import ConfigBase
30 | from ansible.module_utils.network.iosxr.config.bgp import get_bgp_as
31 | from ansible.module_utils.network.iosxr.config.bgp.network import BgpNetwork
32 | from ansible.module_utils.network.iosxr.config.bgp.redistribute import BgpRedistribute
33 |
34 |
35 | class BgpAddressFamily(ConfigBase):
36 |
37 | argument_spec = {
38 | 'name': dict(choices=['ipv4', 'ipv6'], required=True),
39 | 'cast': dict(choices=['flowspec', 'labeled-unicast', 'multicast', 'unicast'], default='unicast'),
40 | 'networks': dict(type='list', elements='dict', options=BgpNetwork.argument_spec),
41 | 'redistribute': dict(type='list', elements='dict', options=BgpRedistribute.argument_spec),
42 | 'state': dict(choices=['present', 'absent'], default='present')
43 | }
44 |
45 | identifier = ('name', )
46 |
47 | def render(self, config=None):
48 | commands = list()
49 |
50 | context = 'address-family %s' % self.name
51 | if self.cast:
52 | context += ' %s' % self.cast
53 |
54 | if config:
55 | bgp_as = get_bgp_as(config)
56 | if bgp_as:
57 | section = ['router bgp %s' % bgp_as, context]
58 | config = self.get_section(config, section)
59 |
60 | if self.state == 'absent':
61 | if context in config:
62 | commands.append('no %s' % context)
63 |
64 | if self.state == 'present':
65 | subcommands = list()
66 | for attr in self.argument_spec:
67 | if attr in self.values:
68 | meth = getattr(self, '_set_%s' % attr, None)
69 | if meth:
70 | resp = meth(config)
71 | if resp:
72 | subcommands.extend(to_list(resp))
73 |
74 | if subcommands:
75 | commands = [context]
76 | commands.extend(subcommands)
77 | commands.append('exit')
78 | elif not config or context not in config:
79 | commands.extend([context, 'exit'])
80 |
81 | return commands
82 |
83 | def _set_networks(self, config=None):
84 | commands = list()
85 | for entry in self.networks:
86 | net = BgpNetwork(**entry)
87 | resp = net.render(config)
88 | if resp:
89 | commands.append(resp)
90 | return commands
91 |
92 | def _set_redistribute(self, config=None):
93 | commands = list()
94 | for entry in self.redistribute:
95 | redis = BgpRedistribute(**entry)
96 | resp = redis.render(config)
97 | if resp:
98 | commands.append(resp)
99 | return commands
100 |
--------------------------------------------------------------------------------
/module_utils/network/iosxr/config/bgp/neighbor.py:
--------------------------------------------------------------------------------
1 | # This code is part of Ansible, but is an independent component.
2 | # This particular file snippet, and this file snippet only, is BSD licensed.
3 | # Modules you write using this snippet, which is embedded dynamically by Ansible
4 | # still belong to the author of the module, and may assign their own license
5 | # to the complete work.
6 | #
7 | # (c) 2016 Red Hat Inc.
8 | #
9 | # Redistribution and use in source and binary forms, with or without modification,
10 | # are permitted provided that the following conditions are met:
11 | #
12 | # * Redistributions of source code must retain the above copyright
13 | # notice, this list of conditions and the following disclaimer.
14 | # * Redistributions in binary form must reproduce the above copyright notice,
15 | # this list of conditions and the following disclaimer in the documentation
16 | # and/or other materials provided with the distribution.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
26 | # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | #
28 | from ansible.module_utils.network.common.utils import to_list
29 | from ansible.module_utils.network.iosxr.config import ConfigBase
30 | from ansible.module_utils.network.iosxr.config.bgp import get_bgp_as
31 | from ansible.module_utils.network.iosxr.config.bgp.timer import BgpTimer
32 |
33 |
34 | class BgpNeighbor(ConfigBase):
35 |
36 | argument_spec = {
37 | 'neighbor': dict(required=True),
38 | 'remote_as': dict(type='int', required=True),
39 | 'update_source': dict(),
40 | 'password': dict(no_log=True),
41 | 'enabled': dict(type='bool'),
42 | 'description': dict(),
43 | 'ebgp_multihop': dict(type='int'),
44 | 'tcp_mss': dict(type='int'),
45 | 'timers': dict(type='dict', elements='dict', options=BgpTimer.argument_spec),
46 | 'use_neighbor_group': dict(),
47 | 'state': dict(choices=['present', 'absent'], default='present')
48 | }
49 |
50 | identifier = ('neighbor', )
51 |
52 | def render(self, config=None):
53 | commands = list()
54 |
55 | if self.state == 'absent':
56 | cmd = 'neighbor %s' % self.neighbor
57 | if not config or cmd in config:
58 | commands = ['no %s' % cmd]
59 |
60 | elif self.state in ('present', None):
61 | context = 'neighbor %s' % self.neighbor
62 | section = ['router bgp %s' % get_bgp_as(config), context]
63 | config = self.get_section(config, section)
64 | cmd = 'remote-as %s' % (self.remote_as)
65 | if not config or cmd not in config:
66 | commands.append(' '.join([context, cmd]))
67 | for attr in self.argument_spec:
68 | if attr in self.values:
69 | meth = getattr(self, '_set_%s' % attr, None)
70 | if meth:
71 | command = meth(config)
72 | if command:
73 | commands.extend(to_list(' '.join([context,
74 | command])))
75 | return commands
76 |
77 | def _set_description(self, config=None):
78 | cmd = 'description %s' % self.description
79 | if not config or cmd not in config:
80 | return cmd
81 |
82 | def _set_enabled(self, config=None):
83 | cmd = 'shutdown'
84 | if self.enabled is True:
85 | cmd = 'no %s' % cmd
86 | if not config or cmd not in config:
87 | return cmd
88 |
89 | def _set_update_source(self, config=None):
90 | cmd = 'update-source %s' % (self.update_source.replace(' ', ''))
91 | if not config or cmd not in config:
92 | return cmd
93 |
94 | def _set_password(self, config=None):
95 | cmd = 'password %s' % self.password
96 | if not config or cmd not in config:
97 | return cmd
98 |
99 | def _set_ebgp_multihop(self, config=None):
100 | cmd = 'ebgp-multihop %s' % self.ebgp_multihop
101 | if not config or cmd not in config:
102 | return cmd
103 |
104 | def _set_tcp_mss(self, config=None):
105 | cmd = 'tcp mss %s' % self.tcp_mss
106 | if not config or cmd not in config:
107 | return cmd
108 |
109 | def _set_advertisement_interval(self, config=None):
110 | cmd = 'advertisement-interval %s' % self.advertisement_interval
111 | if not config or cmd not in config:
112 | return cmd
113 |
114 | def _set_neighbor_group(self, config=None):
115 | cmd = 'use neighbor-group %s' % self.neighbor_group
116 | if not config or cmd not in config:
117 | return cmd
118 |
119 | def _set_timers(self, config):
120 | """generate bgp timer related configuration
121 | """
122 | timer = BgpTimer(**self.timers)
123 | resp = timer.render(config)
124 | if resp:
125 | return resp
126 |
--------------------------------------------------------------------------------
/module_utils/network/iosxr/config/bgp/neighbor_group.py:
--------------------------------------------------------------------------------
1 | # This code is part of Ansible, but is an independent component.
2 | # This particular file snippet, and this file snippet only, is BSD licensed.
3 | # Modules you write using this snippet, which is embedded dynamically by Ansible
4 | # still belong to the author of the module, and may assign their own license
5 | # to the complete work.
6 | #
7 | # (c) 2016 Red Hat Inc.
8 | #
9 | # Redistribution and use in source and binary forms, with or without modification,
10 | # are permitted provided that the following conditions are met:
11 | #
12 | # * Redistributions of source code must retain the above copyright
13 | # notice, this list of conditions and the following disclaimer.
14 | # * Redistributions in binary form must reproduce the above copyright notice,
15 | # this list of conditions and the following disclaimer in the documentation
16 | # and/or other materials provided with the distribution.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
26 | # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | #
28 | from ansible.module_utils.network.common.utils import to_list
29 | from ansible.module_utils.network.iosxr.config.bgp import get_bgp_as
30 | from ansible.module_utils.network.iosxr.config.bgp.neighbor import BgpNeighbor
31 |
32 |
33 | class BgpNeighborGroup(BgpNeighbor):
34 |
35 | argument_spec = {
36 | 'name': dict(required=True)
37 | }
38 |
39 | argument_spec.update(BgpNeighbor.argument_spec)
40 |
41 | del argument_spec['neighbor']
42 |
43 | identifier = ('name', )
44 |
45 | def render(self, config=None):
46 | commands = list()
47 |
48 | context = 'neighbor-group %s' % self.name
49 |
50 | if config:
51 | bgp_as = get_bgp_as(config)
52 | if bgp_as:
53 | section = ['router bgp %s' % bgp_as, context]
54 | config = self.get_section(config, section)
55 |
56 | if self.state == 'absent':
57 | if context in config:
58 | commands.append('no %s' % context)
59 |
60 | if self.state == 'present':
61 | subcommands = list()
62 | for attr in self.argument_spec:
63 | if attr in self.values:
64 | meth = getattr(self, '_set_%s' % attr, None)
65 | if meth:
66 | resp = meth(config)
67 | if resp:
68 | subcommands.extend(to_list(resp))
69 | if subcommands:
70 | commands = [context]
71 | commands.extend(subcommands)
72 | commands.append('exit')
73 | elif not config or context not in config:
74 | commands.extend([context, 'exit'])
75 | return commands
76 |
77 | def _set_remote_as(self, config=None):
78 | cmd = 'remote-as %s' % self.remote_as
79 | if not config or cmd not in config:
80 | return cmd
81 |
--------------------------------------------------------------------------------
/module_utils/network/iosxr/config/bgp/network.py:
--------------------------------------------------------------------------------
1 | # This code is part of Ansible, but is an independent component.
2 | # This particular file snippet, and this file snippet only, is BSD licensed.
3 | # Modules you write using this snippet, which is embedded dynamically by Ansible
4 | # still belong to the author of the module, and may assign their own license
5 | # to the complete work.
6 | #
7 | # (c) 2016 Red Hat Inc.
8 | #
9 | # Redistribution and use in source and binary forms, with or without modification,
10 | # are permitted provided that the following conditions are met:
11 | #
12 | # * Redistributions of source code must retain the above copyright
13 | # notice, this list of conditions and the following disclaimer.
14 | # * Redistributions in binary form must reproduce the above copyright notice,
15 | # this list of conditions and the following disclaimer in the documentation
16 | # and/or other materials provided with the distribution.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
26 | # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | #
28 | from ansible.module_utils.network.iosxr.config import ConfigBase
29 |
30 |
31 | class BgpNetwork(ConfigBase):
32 |
33 | argument_spec = {
34 | 'network': dict(required=True),
35 | 'route_map': dict(),
36 | 'mask': dict(),
37 | 'state': dict(choices=['present', 'absent'], default='present')
38 | }
39 |
40 | identifier = ('network', )
41 |
42 | def render(self, config=None):
43 | if not self.mask and '/' not in self.network:
44 | raise ValueError('specify network in CIDR notation or specify the mask')
45 |
46 | cmd = 'network %s' % self.network
47 |
48 | if '/' not in self.network:
49 | cmd += ' %s' % self.mask
50 |
51 | if self.route_map:
52 | cmd += ' route-map %s' % self.route_map
53 |
54 | if self.state == 'absent':
55 | if not config or cmd in config:
56 | return 'no %s' % cmd
57 |
58 | elif self.state in ('present', None):
59 | if not config or cmd not in config:
60 | return cmd
61 |
--------------------------------------------------------------------------------
/module_utils/network/iosxr/config/bgp/process.py:
--------------------------------------------------------------------------------
1 | # This code is part of Ansible, but is an independent component.
2 | # This particular file snippet, and this file snippet only, is BSD licensed.
3 | # Modules you write using this snippet, which is embedded dynamically by Ansible
4 | # still belong to the author of the module, and may assign their own license
5 | # to the complete work.
6 | #
7 | # (c) 2016 Red Hat Inc.
8 | #
9 | # Redistribution and use in source and binary forms, with or without modification,
10 | # are permitted provided that the following conditions are met:
11 | #
12 | # * Redistributions of source code must retain the above copyright
13 | # notice, this list of conditions and the following disclaimer.
14 | # * Redistributions in binary form must reproduce the above copyright notice,
15 | # this list of conditions and the following disclaimer in the documentation
16 | # and/or other materials provided with the distribution.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
26 | # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | #
28 | from ansible.module_utils.network.common.utils import to_list
29 | from ansible.module_utils.network.iosxr.config import ConfigBase
30 | from ansible.module_utils.network.iosxr.config.bgp import get_bgp_as
31 | from ansible.module_utils.network.iosxr.config.bgp.neighbor import BgpNeighbor
32 | from ansible.module_utils.network.iosxr.config.bgp.neighbor_group import BgpNeighborGroup
33 | from ansible.module_utils.network.iosxr.config.bgp.address_family import BgpAddressFamily
34 |
35 |
36 | class BgpProcess(ConfigBase):
37 |
38 | argument_spec = {
39 | 'bgp_as': dict(type='int'),
40 | 'router_id': dict(),
41 | 'log_neighbor_changes': dict(type='bool'),
42 | 'neighbors': dict(type='list', elements='dict', options=BgpNeighbor.argument_spec),
43 | 'neighbor_groups': dict(type='list', elements='dict', options=BgpNeighborGroup.argument_spec),
44 | 'address_families': dict(type='list', elements='dict', options=BgpAddressFamily.argument_spec),
45 | 'state': dict(choices=['present', 'absent', 'replace'], default='present')
46 | }
47 |
48 | identifier = ('bgp_as', )
49 |
50 | def render(self, config=None):
51 | commands = list()
52 |
53 | context = 'router bgp %s' % self.bgp_as
54 |
55 | if self.state in ('absent', 'replace'):
56 | bgp_as = get_bgp_as(config)
57 | if bgp_as:
58 | commands.append('no router bgp %s' % bgp_as)
59 | if self.state == 'replace':
60 | commands.append(context)
61 |
62 | if self.state in ('present', 'replace'):
63 | for attr in self.argument_spec:
64 | if attr in self.values:
65 | meth = getattr(self, '_set_%s' % attr, None)
66 | if meth:
67 | resp = meth(config)
68 | if resp:
69 | if not commands:
70 | commands.append(context)
71 | commands.extend(to_list(resp))
72 | return commands
73 |
74 | def _set_router_id(self, config=None):
75 | cmd = 'bgp router-id %s' % self.router_id
76 | if not config or cmd not in config:
77 | return cmd
78 |
79 | def _set_log_neighbor_changes(self, config=None):
80 | cmd = 'bgp log neighbor changes'
81 | if self.log_neighbor_changes is True:
82 | if not config or cmd not in config:
83 | return '%s detail' % cmd
84 | elif self.log_neighbor_changes is False:
85 | if config and cmd in config:
86 | return '%s disable' % cmd
87 |
88 | def _set_neighbors(self, config):
89 | """ generate bgp neighbor configuration
90 | """
91 | commands = list()
92 | for entry in self.neighbors:
93 | nbr = BgpNeighbor(**entry)
94 | resp = nbr.render(config)
95 | if resp:
96 | commands.extend(resp)
97 | return commands
98 |
99 | def _set_neighbor_groups(self, config):
100 | """ generate bgp neighbor group configuration
101 | """
102 | commands = list()
103 | for entry in self.neighbor_groups:
104 | nbr_grp = BgpNeighborGroup(**entry)
105 | resp = nbr_grp.render(config)
106 | if resp:
107 | commands.extend(resp)
108 | return commands
109 |
110 | def _set_address_families(self, config):
111 | """ generate address-family configuration
112 | """
113 | commands = list()
114 | for entry in self.address_families:
115 | af = BgpAddressFamily(**entry)
116 | resp = af.render(config)
117 | if resp:
118 | commands.extend(resp)
119 | return commands
120 |
--------------------------------------------------------------------------------
/module_utils/network/iosxr/config/bgp/redistribute.py:
--------------------------------------------------------------------------------
1 | # This code is part of Ansible, but is an independent component.
2 | # This particular file snippet, and this file snippet only, is BSD licensed.
3 | # Modules you write using this snippet, which is embedded dynamically by Ansible
4 | # still belong to the author of the module, and may assign their own license
5 | # to the complete work.
6 | #
7 | # (c) 2016 Red Hat Inc.
8 | #
9 | # Redistribution and use in source and binary forms, with or without modification,
10 | # are permitted provided that the following conditions are met:
11 | #
12 | # * Redistributions of source code must retain the above copyright
13 | # notice, this list of conditions and the following disclaimer.
14 | # * Redistributions in binary form must reproduce the above copyright notice,
15 | # this list of conditions and the following disclaimer in the documentation
16 | # and/or other materials provided with the distribution.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
26 | # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | #
28 | from ansible.module_utils.network.iosxr.config import ConfigBase
29 |
30 |
31 | class BgpRedistribute(ConfigBase):
32 | PROTOCOLS = ['ospf', 'eigrp', 'isis', 'static', 'connected', 'lisp', 'mobile', 'rip', 'subscriber']
33 |
34 | argument_spec = {
35 | 'protocol': dict(choices=PROTOCOLS, required=True),
36 | 'id': dict(),
37 | 'metric': dict(type='int'),
38 | 'route_map': dict(),
39 | 'state': dict(choices=['present', 'absent'], default='present')
40 | }
41 |
42 | identifier = ('protocol', )
43 |
44 | def render(self, config=None):
45 | cmd = 'redistribute %s' % self.protocol
46 |
47 | if self.id and self.protocol in self.PROTOCOLS[0:3]:
48 | cmd += ' %s' % self.id
49 |
50 | if self.metric:
51 | cmd += ' metric %s' % str(self.metric)
52 |
53 | if self.route_map:
54 | cmd += ' route-map %s' % self.route_map
55 |
56 | if self.state == 'absent':
57 | if not config or cmd in config:
58 | return 'no %s' % cmd
59 |
60 | elif self.state in ('present', None):
61 | if not config or cmd not in config:
62 | return cmd
63 |
--------------------------------------------------------------------------------
/module_utils/network/iosxr/config/bgp/timer.py:
--------------------------------------------------------------------------------
1 | # This code is part of Ansible, but is an independent component.
2 | # This particular file snippet, and this file snippet only, is BSD licensed.
3 | # Modules you write using this snippet, which is embedded dynamically by Ansible
4 | # still belong to the author of the module, and may assign their own license
5 | # to the complete work.
6 | #
7 | # (c) 2016 Red Hat Inc.
8 | #
9 | # Redistribution and use in source and binary forms, with or without modification,
10 | # are permitted provided that the following conditions are met:
11 | #
12 | # * Redistributions of source code must retain the above copyright
13 | # notice, this list of conditions and the following disclaimer.
14 | # * Redistributions in binary form must reproduce the above copyright notice,
15 | # this list of conditions and the following disclaimer in the documentation
16 | # and/or other materials provided with the distribution.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
26 | # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | #
28 | from ansible.module_utils.network.iosxr.config import ConfigBase
29 |
30 |
31 | class BgpTimer(ConfigBase):
32 |
33 | argument_spec = {
34 | 'keepalive': dict(type='int'),
35 | 'holdtime': dict(type='int'),
36 | 'min_neighbor_holdtime': dict(type='int'),
37 | 'state': dict(choices=['present', 'absent', 'replace'], default='present')
38 | }
39 |
40 | identifier = ('keepalive', )
41 |
42 | def render(self, config=None):
43 | cmd = 'timers'
44 |
45 | if self.state in ('present', None):
46 | if self.keepalive and self.holdtime:
47 | cmd = '%s %s %s' % (cmd, self.keepalive, self.holdtime)
48 | if self.min_neighbor_holdtime:
49 | cmd += ' %s' % self.min_neighbor_holdtime
50 | if not config or cmd not in config:
51 | return cmd
52 | else:
53 | raise ValueError("required both options for timers: keepalive and holdtime")
54 |
55 | elif self.state == 'absent':
56 | if not config or cmd in config:
57 | return 'no %s' % cmd
58 |
--------------------------------------------------------------------------------
/parser_templates/cli/show_version_brief.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: parser meta data
3 | parser_metadata:
4 | version: 1.0
5 | command: show version brief
6 | network_os: iosxr
7 |
8 | - name: parse softare version
9 | pattern_match:
10 | regex: ", Version (.+)"
11 | register: version
12 |
13 | - name: parse hostname
14 | pattern_match:
15 | regex: "(\\S+) uptime is"
16 | register: hostname
17 |
18 | - name: match image
19 | pattern_match:
20 | regex: "^System image file is \"(\\S+)\""
21 | register: image
22 |
23 | - name: build iosxr version facts
24 | set_vars:
25 | version: "{{ version.matches.0 }}"
26 | hostname: "{{ hostname.matches.0 }}"
27 | image_file: "{{ image.matches.0 }}"
28 | register: system
29 | export: true
30 | extend: cisco_iosxr
31 |
--------------------------------------------------------------------------------
/parser_templates/cli/show_vlan.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: parser meta data
3 | parser_metadata:
4 | version: 1.0
5 | command: show vlan trunks
6 | network_os: iosxr
7 |
8 | - name: match cli sections
9 | pattern_match:
10 | regex: "^Gi(\\w+)"
11 | match_all: true
12 | match_greedy: true
13 | register: cli_section
14 |
15 | - name: match cli values
16 | pattern_group:
17 | - name: match row
18 | pattern_match:
19 | regex: '^(?P\w+\d/\d/\d/\d)\s+(?P\d+)'
20 | content: "{{ item }}"
21 | register: fact
22 | loop: "{{ cli_section }}"
23 | register: cli_values
24 |
25 | - name: template facts
26 | json_template:
27 | template:
28 | - key: interface
29 | value: "{{ item.fact.interface}}"
30 | - key: id
31 | value: "{{ item.fact.id }}"
32 | loop: "{{ cli_values }}"
33 | export: true
34 | register: vlan_facts
35 |
--------------------------------------------------------------------------------
/tasks/config_manager/get.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: initialize function
3 | include_tasks: includes/init.yaml
4 |
5 | - name: collect platform capabilities as facts
6 | iosxr_capabilities:
7 |
8 | - name: run command and return configuration
9 | cli:
10 | command: "{{ iosxr_config_source[source | default('running')] }}"
11 | register: configuration
12 |
13 | - name: set configuration fact
14 | set_fact:
15 | configuration: "{{ configuration.stdout }}"
16 |
17 | - name: parse system configuration
18 | command_parser:
19 | dir: "{{ role_path }}/parser_templates/config"
20 | content: "{{ configuration }}"
21 | when: false
22 |
--------------------------------------------------------------------------------
/tasks/config_manager/load.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | # load_config task
3 | #
4 | - name: initialize function
5 | include_tasks: includes/init.yaml
6 |
7 | - name: validate task arguments
8 | validate_role_spec:
9 | spec: load_config_spec.yaml
10 |
11 | - name: lookup config file
12 | set_fact:
13 | iosxr_config_text: "{{ lookup('config_template', iosxr_config_file) | join('\n') }}"
14 | when: iosxr_config_file != ''
15 |
16 | - name: Include configure task
17 | include_tasks: includes/configure/configure.yaml
18 | when: not ansible_check_mode and not iosxr_config_replace
19 |
--------------------------------------------------------------------------------
/tasks/config_manager/save.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | # save config tasks
3 | - name: initialize function
4 | include_tasks: includes/init.yaml
5 |
6 | - name: copy running-config to file
7 | cli:
8 | command: "show running-config | file disk0:{{ iosxr_config_save_config }}"
9 |
10 | - block:
11 | - name: create a new configuration session
12 | cli:
13 | command: configure
14 |
15 | - name: load the running-config from already saved file
16 | cli:
17 | command: "load disk0:{{ iosxr_config_save_config }}"
18 |
19 | - name: commit the changes
20 | cli:
21 | command: commit
22 |
23 | - name: terminate the configuration session
24 | cli:
25 | command: end
26 |
27 | - name: delete the saved file
28 | cli:
29 | command: "delete /noprompt disk0:{{ iosxr_config_save_config }}"
30 |
31 | rescue:
32 | - name: terminate the configuration session
33 | cli:
34 | command: end
35 |
--------------------------------------------------------------------------------
/tasks/configure_lldp.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: "check for required fact - interface when lldp receive is defined"
3 | fail:
4 | msg: "missing required fact: Interface"
5 | with_items: "{{ lldp }}"
6 | when: ( item.interface is not defined and item.receive is defined)
7 | loop_control:
8 | loop_var: item
9 | delegate_to: localhost
10 |
11 | - name: "check for required fact - interface when lldp transmit is defined"
12 | fail:
13 | msg: "missing required fact: Interface"
14 | with_items: "{{ lldp }}"
15 | when: ( item.interface is not defined and item.transmit is defined)
16 | loop_control:
17 | loop_var: item
18 | delegate_to: localhost
19 |
20 | - name: "fetch template for configuring LLDP"
21 | set_fact:
22 | iosxr_config_text: "{{ lookup('config_template', 'configure_lldp.j2') }}"
23 | when: lldp
24 |
25 | - include_tasks: config_manager/load.yaml
26 | when: lldp
27 |
--------------------------------------------------------------------------------
/tasks/configure_netconf.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: validate required connection is configured
3 | fail:
4 | msg: "expected connection value to be set to network_cli, got {{ ansible_connection }}"
5 | when: ansible_connection != 'network_cli'
6 |
7 | - name: "iosxr: enable netconf if not already enabled"
8 | iosxr_netconf:
9 | netconf_port: "{{ iosxr_netconf_port }}"
10 | netconf_vrf: "{{ iosxr_netconf_vrf }}"
11 | state: present
12 |
--------------------------------------------------------------------------------
/tasks/configure_system_properties.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: "fetch template for configuring system property(s)"
3 | set_fact:
4 | iosxr_config_text: "{{ lookup('config_template', 'configure_system_properties.j2') }}"
5 | when: sys_props
6 |
7 | - include_tasks: config_manager/load.yaml
8 | when: sys_props
9 |
--------------------------------------------------------------------------------
/tasks/configure_user.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: "check if user(s) to configure is provided"
3 | fail:
4 | msg: "no user provided to configure"
5 | when: users is not defined
6 | delegate_to: localhost
7 |
8 | - name: "check for required fact - name"
9 | fail:
10 | msg: "missing required fact: name"
11 | loop: "{{ users }}"
12 | when: ( user.name is not defined )
13 | loop_control:
14 | loop_var: user
15 | delegate_to: localhost
16 |
17 | - name: "fetch existing user account details"
18 | cli:
19 | command: show running-config username
20 | register: user_config
21 |
22 | - name: "filter out users through user_manager"
23 | iosxr_user_manager:
24 | new_users: "{{ users }}"
25 | user_config: "{{ user_config.stdout }}"
26 | register: filtered_users
27 | delegate_to: localhost
28 |
29 | - name: "set users to be configured"
30 | set_fact:
31 | users: "{{ filtered_users.stdout }}"
32 | delegate_to: localhost
33 |
34 | - name: "fetch template for configuring user(s)"
35 | set_fact:
36 | iosxr_config_text: "{{ lookup('config_template', 'configure_user.j2') }}"
37 | when: users
38 | delegate_to: localhost
39 |
40 | - include_tasks: config_manager/load.yaml
41 | when: users
42 | delegate_to: localhost
43 |
--------------------------------------------------------------------------------
/tasks/configure_vlans.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: "check for required fact - interface"
3 | fail:
4 | msg: "missing required fact: Interface"
5 | with_items: "{{ vlans }}"
6 | when: ( vlan.interface is not defined )
7 | loop_control:
8 | loop_var: vlan
9 | delegate_to: localhost
10 |
11 | - name: "check for required fact - vlan ID"
12 | fail:
13 | msg: "missing required fact: Vlan ID"
14 | with_items: "{{ vlans }}"
15 | when: ( vlan.id is not defined )
16 | loop_control:
17 | loop_var: vlan
18 | delegate_to: localhost
19 |
20 | - name: "check if vlan ID is greater than 1"
21 | fail:
22 | msg: "vlan_id is less than 1 (valid-range: 1-4094)"
23 | with_items: "{{ vlans }}"
24 | loop_control:
25 | loop_var: vlan
26 | when:
27 | - vlan.id < 1
28 | delegate_to: localhost
29 |
30 | - name: "check if vlan ID is less than 4094"
31 | fail:
32 | msg: "vlan_id is greater than 4094 (valid-range: 1-4094)"
33 | with_items: "{{ vlans }}"
34 | loop_control:
35 | loop_var: vlan
36 | when:
37 | - vlan.id > 4094
38 | delegate_to: localhost
39 |
40 | - name: "fetch existing vlan(s)"
41 | cli:
42 | command: show vlan tags
43 | register: vlan_output
44 |
45 | - name: "generate existing user(s) facts as JSON"
46 | command_parser:
47 | file: "{{ role_path }}/parser_templates/cli/show_vlan.yaml"
48 | content: "{{ vlan_output.stdout }}"
49 |
50 | - name: "show existing user information"
51 | debug:
52 | var: vlan_facts
53 |
54 | - name: "filter out vlans that need to be configured"
55 | set_fact:
56 | vlans: "{{ vlans | difference(vlan_facts) }}"
57 |
58 | - name: "display vlans to configure"
59 | debug:
60 | var: vlans
61 |
62 | - set_fact:
63 | iosxr_vlans: "{{ vlans }}"
64 |
65 | - name: "fetch template for configuring vlan(s)"
66 | set_fact:
67 | iosxr_config_text: "{{ lookup('config_template', 'configure_vlans.j2') }}"
68 | when: vlans
69 |
70 | - include_tasks: config_manager/load.yaml
71 | when: vlans
72 |
--------------------------------------------------------------------------------
/tasks/get_facts.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: validate required connection is configured
3 | fail:
4 | msg: "expected connection value to be set to network_cli, got {{ ansible_connection }}"
5 | when: ansible_connection != 'network_cli'
6 |
7 | - name: collect platform capabilities as facts
8 | iosxr_capabilities:
9 |
10 | - name: run command and parse output
11 | include_tasks: run_cli.yaml
12 | vars:
13 | iosxr_command: "{{ item.command }}"
14 | iosxr_parser: "cli/{{ item.parser }}"
15 | iosxr_parser_engine: "{{ item.engine | default('command_parser') }}"
16 | iosxr_run_cli_command_pre_hook: "{{ item.pre_hook | default(None) }}"
17 | iosxr_run_cli_command_post_hook: "{{ item.post_hook | default(None) }}"
18 | loop: "{{ lookup('file', iosxr_get_facts_command_map) | from_yaml }}"
19 | when: iosxr_get_facts_subset | intersect(item.groups)
20 |
--------------------------------------------------------------------------------
/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for ansible-network.cisco_iosxr
3 |
--------------------------------------------------------------------------------
/templates/configure_lldp.j2:
--------------------------------------------------------------------------------
1 | {% for item in lldp %}
2 |
3 | {% if item.state is defined and item.state == 'absent' %}
4 | no lldp
5 | {% if item.interface is defined %}
6 | interface {{ item.interface | default(omit) }}
7 | no lldp
8 | {% endif %}
9 |
10 | {% else %}
11 |
12 | lldp
13 | holdtime {{ item.holdtime | default(omit) }}
14 | reinit {{ item.reinit | default(omit) }}
15 | timer {{ item.timer | default(omit) }}
16 | tlv-select {{ item.tlv_select | default(omit) }} disable
17 |
18 | {% if item.interface is defined %}
19 | interface {{ item.interface }}
20 | lldp
21 | receive {{ item.receive }}
22 | transmit {{ item.transmit }}
23 | {% endif %}
24 |
25 | {% endif %}
26 | {% endfor %}
27 |
--------------------------------------------------------------------------------
/templates/configure_system_properties.j2:
--------------------------------------------------------------------------------
1 | {% for sys_prop in sys_props %}
2 |
3 | {% if sys_prop.state is defined and sys_prop.state == 'absent' %}
4 |
5 | {% if sys_prop.hostname is defined %}
6 | no hostname {{ sys_prop.hostname }}
7 | {% endif %}
8 |
9 | {% if sys_prop.domain_name is defined %}
10 | no domain name {{ sys_prop.domain_name }}
11 | {% endif %}
12 |
13 | {% if sys_prop.domain_name_server is defined %}
14 | no domain name-server {{ sys_prop.domain_name_server }}
15 | {% endif %}
16 |
17 | {% if sys_prop.vrf_name is defined %}
18 | no vrf {{ sys_prop.vrf_name }}
19 | {% endif %}
20 |
21 |
22 | {% else %}
23 |
24 |
25 | {% if sys_prop.hostname is defined %}
26 | hostname {{ sys_prop.hostname }}
27 | {% endif %}
28 |
29 | {% if sys_prop.domain_name is defined %}
30 | domain name {{ sys_prop.domain_name }}
31 | {% endif %}
32 |
33 | {% if sys_prop.domain_name_server is defined %}
34 | domain name-server {{ sys_prop.domain_name_server | default(omit) }}
35 | {% endif %}
36 |
37 | {% if sys_prop.vrf_name is defined %}
38 | vrf {{ sys_prop.vrf_name }}
39 | address-family {{ sys_prop.vrf_address_family | default(omit) }}
40 | apply-group {{ sys_prop.vrf_apply_group | default(omit) }}
41 | description {{ sys_prop.description | default(omit) }}
42 | fallback-vrf {{ sys_prop.vrf_fallback | default(omit) }}
43 | mode {{ sys_prop.vrf_mode | default(omit) }}
44 | vpn {{ sys_prop.vrf_vpn | default(omit) }}
45 | remote-route-filtering {{ sys_prop.vrf_remote_route_filter | default(omit) }}
46 | {% endif %}
47 |
48 |
49 | {% endif %}
50 | {% endfor %}
51 |
--------------------------------------------------------------------------------
/templates/configure_user.j2:
--------------------------------------------------------------------------------
1 | {% for user in users %}
2 |
3 | {% if user.state is defined and user.state == 'absent' %}
4 | no username {{ user.name }}
5 |
6 | {% else %}
7 |
8 | {% if user.password is not defined %}
9 | username {{ user.name }}
10 | {% elif user.password %}
11 | username {{ user.name }} secret {{ user.password }}
12 | {% endif %}
13 |
14 | {% if user.group is defined %}
15 | username {{ user.name }} group {{ user.group }}
16 | {% endif %}
17 |
18 | {% endif %}
19 | {% endfor %}
20 |
--------------------------------------------------------------------------------
/templates/configure_vlans.j2:
--------------------------------------------------------------------------------
1 | {% for vlan in vlans %}
2 |
3 | {% if vlan.state is defined and vlan.state == 'absent' %}
4 | interface {{ vlan.interface }}
5 | no dot1q native vlan {{ vlan.id }}
6 |
7 | {% else %}
8 |
9 | interface {{ vlan.interface }}
10 | dot1q native vlan {{ vlan.id }}
11 | ipv4 address {{ vlan.ipaddr | default(omit) }}
12 |
13 | {% endif %}
14 | {% endfor %}
15 |
--------------------------------------------------------------------------------
/test-requirements.txt:
--------------------------------------------------------------------------------
1 | flake8
2 | yamllint
3 |
--------------------------------------------------------------------------------
/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - ansible-network.cisco_iosxr
6 |
--------------------------------------------------------------------------------
/tox.ini:
--------------------------------------------------------------------------------
1 | [tox]
2 | minversion = 1.6
3 | skipsdist = True
4 | envlist = linters
5 |
6 | [testenv]
7 | install_command = pip install {opts} {packages}
8 | deps = -r{toxinidir}/test-requirements.txt
9 |
10 | [testenv:linters]
11 | basepython = python3
12 | commands =
13 | yamllint -s .
14 | flake8 {posargs}
15 |
16 | [testenv:venv]
17 | commands = {posargs}
18 |
19 | [flake8]
20 | # These are ignored intentionally;
21 | # please don't submit patches that solely correct them or enable them.
22 | ignore = E125,E129,E302,E402
23 | max-line-length = 160
24 | show-source = True
25 | exclude = .venv,.tox,dist,doc,build,*.egg
26 |
--------------------------------------------------------------------------------
/vars/get_facts_command_map.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | # This file is used to map show commands to parser templates. When this file
3 | # is processed, the command is issued on the target device and the output is
4 | # passed to the parser to be converted to Ansible facts. The parser file
5 | # should be located in `parser_templates/cli`.
6 | #
7 | # Each entry in this file supports the following keys:
8 | #
9 | # * command - the cli command to execute on the target device
10 | # * parser - the filename of the parser relative to parse_templates/cli
11 | # * engine - one of `command_parser` (default) or `textfsm_parser`
12 | # * groups - a list of one or more groups the commadn belongs to
13 | # * pre_hook - path to the set of tasks to execute before running the command
14 | # * post_hook - path to the set of tasks to execute after running the command
15 | #
16 | # Please see the [documentation](https://github.com/ansible-network/cisco_iosxr/blob/devel/tasks/get_facts.yaml) for more details.
17 | #
18 | - command: show version brief
19 | parser: show_version_brief.yaml
20 | groups:
21 | - default
22 |
--------------------------------------------------------------------------------
/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for ansible-network.cisco_iosx
3 |
--------------------------------------------------------------------------------