Actions

add_config

main(attributes)[source]

Appends config section to startup-config.

This action is dual-supervisor compatible.

url

path to source config/template

substitution_mode

loose|strict (default: loose)

variables

list of value substitutions

Special_attributes:
NODE: API object - see documentation for details

Example

-
  action: add_config
  attributes:
    url: files/templates/ma1.template
    variables:
      ipaddress: allocate('mgmt_subnet')
  name: "configure ma1"
  onstart: "Starting to configure ma1"
  onsuccess: "SUCCESS: ma1 configure"
  onfailure: "FAIL: IM provisioning@example.com for help"

configure_ansible_client

main(attributes)[source]

Create a user and configure ssh keys (optional) to help deploy an Ansible client automatically. The user that is created will be persistant across reboots. For more details on user creation, see NODE documentation for create_user().

user

username used by Ansible server to SSH into node

passwd

cleartext password for user (default = ansible)

group

group assigned to user above (default = eosadmin)

root

directory assigned to user (default = /persist/local/)

key

(optional) location of public ssh key to be written to authorized_keys

Special_attributes:
NODE: API object - see documentation for details

Example

-
  action: configure_ansible_client
  attributes:
    user: ansible
    passwd: ansible
    group: eosadmin
    root: /persist/local
    key: files/ssh/ansible_server_id_rsa.pub
  name: "Configure Ansible SSH Keys"

copy_file

main(attributes)[source]

Copies file to the switch.

Copies file based on the values of ‘src_url’ and ‘dst_url’ attributes (‘dst_url’ should point to the destination folder).

This action is NOT dual-supervisor compatible.

src_url

path to source file

dst_url

path to destination

mode

octal mode for destination path

overwrite

replace|if-missing|backup (default: replace)

‘overwrite’ values:
  • ‘replace’: the file is copied to the switch regardless of whether there is already a file with the same name at the destination;
  • ‘if-missing’: the file is copied to the switch only if there is not already a file with the same name at the destination; if there is, then the action is a no-op;
  • ‘backup’: the file is copied to the switch; if there is already another file at the destination, that file is renamed by appending the ‘.backup’ suffix
Special_attributes:
NODE: API object - see documentation for details

Example

-
  action: copy_file
  always_execute: true
  attributes:
    dst_url: /mnt/flash/
    mode: 777
    overwrite: if-missing
    src_url: files/automate/bgpautoinf.py
  name: "automate BGP peer interface config"

install_cli_plugin

main(attributes)[source]

Installs CliPlugin.

This action is NOT dual-supervisor compatible.

url

path to the CliPlugin

Special_attributes:
NODE: API object - see documentation for details

Example

-
  action: install_image
  always_execute: true
  attributes:
    url: files/my_cli_plugin
  name: "install cli plugin"

install_extension

main(attributes)[source]

Installs extension.

If ‘force’ is set, then the dependency checks are overridden.

This action is NOT dual-supervisor compatible.

url

path to source extension file

force

ignore validation errors (default: false)

always_execute

perform copy even if file exists

Special_attributes:
NODE: API object - see documentation for details

Example

-
  action: install_extension
  always_execute: true
  attributes:
    url: files/telemetry-1.0-1.rpm
  name: "Install Telemetry"

install_image

main(attributes)[source]

Installs new software image.

If the current software image is the same as the ‘version’ attribute value, then this action is a no-op. Otherwise, the action will replace the existing software image.

For dual supervisor systems, the image on the active supervisor is used as reference.

This action is dual-supervisor compatible.

url

path to source image file

version

EOS version of new image file

downgrade

Boolean - Should EOS images be downgraded to match? (Default: True)

Special_attributes:
NODE: API object - see documentation for details

Example

-
  action: install_image
  always_execute: true
  attributes:
    url: files/images/vEOS.swi
    version: 4.13.5F
    downgrade: true
  name: "validate image"
  onstart: "Starting to install image"
  onsuccess: "SUCCESS: 4.13.5F installed"
  onfailure: "FAIL: IM nick@example.com for help"

replace_config

main(attributes)[source]

Replaces /mnt/flash/startup-config with new file.

This action is dual-supervisor compatible.

url

path to source config/template

Special_attributes:
NODE: API object - see documentation for details

Example

-
  action: replace_config
  attributes:
    url: files/configs/tor-startup-config
  name: "tor config"

run_bash_script

main(attributes)[source]

Runs a script in EOS from bash.

This action is dual-supervisor compatible.

url

path to source script/template

variables

optional – list of value substitutions (for a script template)

Special_attributes:
NODE: API object - see documentation for details

Example

-
  action: run_bash_script
  attributes:
    url: files/scripts/install_script
    variables:
      version: 1.2.3
  name: 'install temp package'

run_cli_commands

main(attributes)[source]

Runs a set of EOS commands, starting from enable mode.

This action is dual-supervisor compatible.

url

path to source command list/template

variables

optional – list of value substitutions (for a template)

Special_attributes:
NODE: API object - see documentation for details

Example

-
  action: run_cli_commands
  attributes:
    url: files/templates/ma1.template
    variables:
      ipaddress: allocate('mgmt_subnet')
  name: 'configure ma1'

send_email

main(attributes)[source]

Sends an email using an SMTP relay host

Generates an email from the bootstrap process and routes it through a smarthost. The parameters value expects a dictionary with the following values in order for this function to work properly.

{
    'smarthost':   <hostname of smarthost>,
    'sender':      <from email address>
    'receivers':   [ <array of recipients to send email to> ],
    'subject':     <subject line of the message>,
    'body':        <the message body>,
    'attachments': [ <array of files to attach> ],
    'commands':    [ <array of commands to run and attach> ]
}

The required fields for this function are smarthost, sender, and receivers. All other fields are optional.

This action is dual-supervisor compatible.

Parameters:
  • attributes (list) – list of attributes; use attributes.get(<ATTRIBUTE_NAME>) to read attribute values
  • node (internal) – attributes.get(‘NODE’) API: see documentation
  • smarthost – hostname of smarthos>,
  • sender – from email addres>
  • receivers – [ <array of recipients to send email to> ]
  • subject – subject line of the message
  • body – the message body
  • attachments – [ <array of files to attach> ]
  • commands – [ <array of commands to run and attach> ]

Example

-
  action: send_mail
  attributes:
      smarthost: smtp.example.com
      from: noreply@example.com
      subject: This is a test message from a switch in ZTP
      receivers:
          bob@exmple.com
          helen@example.com
      body: Please see the attached 'show version'
      commands: show version