dellemc.enterprise_sonic.sonic_config module – Manages configuration sections on devices running Enterprise SONiC
Note
This module is part of the dellemc.enterprise_sonic collection (version 1.1.1).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install dellemc.enterprise_sonic
.
To use it in a playbook, specify: dellemc.enterprise_sonic.sonic_config
.
New in version 1.0.0: of dellemc.enterprise_sonic
Synopsis
Manages configuration sections of Enterprise SONiC Distribution by Dell Technologies. SONiC configurations use a simple block indent file syntax for segmenting configuration into sections. This module provides an implementation for working with SONiC configuration sections in a deterministic way.
Note
This module has a corresponding action plugin.
Parameters
Parameter |
Comments |
---|---|
The ordered set of commands to append to the end of the command stack if a change needs to be made. Just like with before, this allows the playbook designer to append a set of commands to be executed after the command set. |
|
This argument causes the module to create a full backup of the current Choices:
|
|
This is a dictionary object containing configurable options related to backup file path. The value of this option is read only when |
|
This option provides the path ending with directory name in which the backup configuration file is stored. If the directory does not exist it is first created, and the filename is either the value of |
|
The filename to be used to store the backup configuration. If the filename is not given, it is generated based on the hostname, current time, and date in the format defined by <hostname>_config.<current-date>@<current-time>. |
|
The ordered set of commands to push on to the command stack if a change needs to be made. This allows the playbook designer the opportunity to perform configuration commands prior to pushing any changes without affecting how the set of commands are matched against the system. |
|
The module, by default, connects to the remote device and retrieves the current running-configuration to use as a base for comparing against the contents of source. There are times when it is not desirable to have the task get the current running-configuration for every task in a playbook. The config argument allows the implementer to pass in the configuration to use as the base configuration for comparison. |
|
The ordered set of commands that should be configured in the section. The commands must be the exact same commands as found in the device running-configuration. Be sure to note the configuration command syntax as some commands are automatically modified by the device configuration parser. This argument is mutually exclusive with src. |
|
Instructs the module on the way to perform the matching of the set of commands against the current device configuration. If match is set to line, commands are matched line by line. If match is set to strict, command lines are matched with respect to position. If match is set to exact, command lines must be an equal match. If match is set to none, the module does not attempt to compare the source configuration with the running-configuration on the remote device. Choices:
|
|
The ordered set of parents that uniquely identify the section or hierarchy the commands should be checked against. If the parents argument is omitted, the commands are checked against the set of top level or global commands. |
|
Instructs the module how to perform a configuration on the device. If the replace argument is set to line, then the modified lines are pushed to the device in configuration mode. If the replace argument is set to block, then the entire command block is pushed to the device in configuration mode if any line is not correct. Choices:
|
|
The Choices:
|
|
Specifies the source path to the file that contains the configuration or configuration template to load. The path to the source file can either be the full path on the Ansible control host, or a relative path from the playbook or role root directory. This argument is mutually exclusive with lines. |
|
The update argument controls how the configuration statements are processed on the remote device. Valid choices for the update argument are merge and check. When you set this argument to merge, the configuration changes merge with the current device running-configuration. When you set this argument to check, the configuration updates are determined but not configured on the remote device. Choices:
|
Examples
- dellemc.enterprise_sonic.sonic_config:
lines: ['username {{ user_name }} password {{ user_password }} role {{ user_role }}']
- dellemc.enterprise_sonic.sonic_config:
lines:
- description 'SONiC'
parents: ['interface Eth1/10']
- dellemc.enterprise_sonic.sonic_config:
lines:
- seq 2 permit udp any any
- seq 3 deny icmp any any
parents: ['ip access-list test']
before: ['no ip access-list test']
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The set of commands that is pushed to the remote device. Returned: always Sample: [“username foo password foo role admin”, “router bgp 1”, “router-id 1.1.1.1”] |
|
Returns whether the configuration is saved to the startup configuration or not. Returned: When not check_mode. Sample: true |
|
The set of commands that is pushed to the remote device. Returned: always Sample: [“username foo password foo role admin”, “router bgp 1”, “router-id 1.1.1.1”] |
Authors
Abirami N (@abirami-n)