niubiwocao.ne.ne_template (1.0.0) — module

Run arbitrary command on HUAWEI router devices based on VRP.

| "added in version" 2.5 of niubiwocao.ne"

Authors: LiQingKai

preview | supported by community

Install collection

Install with ansible-galaxy collection install niubiwocao.ne:==1.0.0


Add to requirements.yml

  collections:
    - name: niubiwocao.ne
      version: 1.0.0

Description

Sends an arbitrary command to an HUAWEI router node and returns the results read from the device. The ne_config module includes an argument that will cause the module to wait for a specific condition before returning or timing out if the condition is not met.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Note: examples below use the following network_cli 
#       transport and authentication to the node.
#  If there are special characters, need quotation marksn

- name: ne command test
  hosts: ne
  connection: network_cli
  gather_facts: no
  vars:
    step1:
      commands:
        - command: 'display device'
      rollbacks:
        - command: 'display version'
    step2:
      commands:
        - command: 'display version'
      rollbacks:
        - command: 'power off'
          prompt: 'Y'
  tasks:

  - name: "Run display version on remote devices"
    ne_template:
      steps: 
        - "{{step1}}"
        - "{{step2}}"

Inputs

    
match:
    default: all
    description:
    - The I(match) argument is used in conjunction with the I(wait_for) argument to specify
      the match policy.  Valid values are C(all) or C(any).  If the value is set to C(all)
      then all conditionals in the I(wait_for) must be satisfied.  If the value is set
      to C(any) then only one of the values must be satisfied.
    required: false

steps:
    description:
    - The business steps contains commands to send to the remote HUAWEI router device
      over the configured provider;rollback commands to send to the remote HUAWEI router
      device when errors occur; the confirm info when need to send confirm command to
      the remote HUAWEI router device additionally The resulting output from the command
      is returned. If the I(wait_for) argument is provided, the module is not returned
      until the condition is satisfied or the number of I(retries) has been exceeded.
    required: true

retries:
    default: 10
    description:
    - Specifies the number of retries a command should by tried before it is considered
      failed.  The command is run on the target device every retry and evaluated against
      the I(wait_for) conditionals.
    required: false

interval:
    default: 1
    description:
    - Configures the interval in seconds to wait between retries of the command.  If the
      command does not pass the specified conditional, the interval indicates how to long
      to wait before trying the command again.
    required: false

wait_for:
    default: null
    description:
    - Specifies what to evaluate from the output of the command and what conditionals
      to apply.  This argument will cause the task to wait for a particular conditional
      to be true before moving forward.   If the conditional is not true by the configured
      retries, the task fails.  See examples.
    required: false

Outputs

failed_conditions:
  description: the conditionals that failed
  returned: failed
  sample:
  - '...'
  - '...'
  type: list
stdout:
  description: the set of responses from the commands
  returned: always
  sample:
  - '...'
  - '...'
  type: list
stdout_lines:
  description: The value of stdout split into a list
  returned: always
  sample:
  - - '...'
    - '...'
  - - '...'
  - - '...'
  type: list