dellemc.enterprise_sonic.sonic_config (2.4.0) — module

Manages configuration sections on devices running Enterprise SONiC

| "added in version" 1.0.0 of dellemc.enterprise_sonic"

Authors: Abirami N (@abirami-n)

This plugin has a corresponding action plugin.

Install collection

Install with ansible-galaxy collection install dellemc.enterprise_sonic:==2.4.0


Add to requirements.yml

  collections:
    - name: dellemc.enterprise_sonic
      version: 2.4.0

Description

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.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- dellemc.enterprise_sonic.sonic_config:
    lines: ['username {{ user_name }} password {{ user_password }} role {{ user_role }}']
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- dellemc.enterprise_sonic.sonic_config:
    lines:
      - description 'SONiC'
    parents: ['interface Eth1/10']
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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']

Inputs

    
src:
    description:
    - 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 I(lines).
    type: path

save:
    default: 'no'
    description:
    - The C(save) argument instructs the module to save the running- configuration to
      the startup-configuration at the conclusion of the module running. If check mode
      is specified, this argument is ignored.
    type: bool

after:
    description:
    - The ordered set of commands to append to the end of the command stack if a change
      needs to be made. Just like with I(before), this allows the playbook designer to
      append a set of commands to be executed after the command set.
    elements: str
    type: list

lines:
    aliases:
    - commands
    description:
    - 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 I(src).
    elements: str
    type: list

match:
    choices:
    - line
    - strict
    - exact
    - none
    default: line
    description:
    - 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 I(line), commands are matched
      line by line. If match is set to I(strict), command lines are matched with respect
      to position. If match is set to I(exact), command lines must be an equal match.
      If match is set to I(none), the module does not attempt to compare the source configuration
      with the running-configuration on the remote device.
    type: str

backup:
    default: 'no'
    description:
    - This argument causes the module to create a full backup of the current C(running-configuration)
      from the remote device before any changes are made. If the C(backup_options) value
      is not given, the backup file is written to the C(backup) folder in the playbook
      root directory. If the directory does not exist, it is created.
    type: bool

before:
    description:
    - 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.
    elements: str
    type: list

config:
    description:
    - 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 I(config) argument allows the implementer to pass
      in the configuration to use as the base configuration for comparison.
    type: str

update:
    choices:
    - merge
    - check
    default: merge
    description:
    - The I(update) argument controls how the configuration statements are processed on
      the remote device. Valid choices for the I(update) argument are I(merge) and I(check).
      When you set this argument to I(merge), the configuration changes merge with the
      current device running-configuration. When you set this argument to I(check), the
      configuration updates are determined but not configured on the remote device.
    type: str

parents:
    description:
    - 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.
    elements: str
    type: list

replace:
    choices:
    - line
    - block
    default: line
    description:
    - Instructs the module how to perform a configuration on the device. If the replace
      argument is set to I(line), then the modified lines are pushed to the device in
      configuration mode. If the replace argument is set to I(block), then the entire
      command block is pushed to the device in configuration mode if any line is not correct.
    type: str

backup_options:
    description:
    - This is a dictionary object containing configurable options related to backup file
      path. The value of this option is read only when C(backup) is set to I(yes), if
      C(backup) is set to I(no) this option is ignored.
    suboptions:
      dir_path:
        description:
        - 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 C(filename) or default filename as described
          in C(filename) options description. If the path value is not given, an I(backup)
          directory is created in the current working directory and backup configuration
          is copied in C(filename) within the I(backup) directory.
        type: path
      filename:
        description:
        - 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>.
        type: str
    type: dict

Outputs

commands:
  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
  type: list
saved:
  description: Returns whether the configuration is saved to the startup configuration
    or not.
  returned: When not check_mode.
  sample: true
  type: bool
updates:
  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
  type: list