community.general.nclu (0.1.1) — module

Configure network interfaces using NCLU

Authors: Cumulus Networks (@isharacomix)

preview | supported by community

Install collection

Install with ansible-galaxy collection install community.general:==0.1.1


Add to requirements.yml

  collections:
    - name: community.general
      version: 0.1.1

Description

Interface to the Network Command Line Utility, developed to make it easier to configure operating systems running ifupdown2 and Quagga, such as Cumulus Linux. Command documentation is available at U(https://docs.cumulusnetworks.com/cumulus-linux/System-Configuration/Network-Command-Line-Utility-NCLU/)

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.

- name: Add two interfaces without committing any changes
  nclu:
    commands:
        - add int swp1
        - add int swp2
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Modify hostname to Cumulus-1 and commit the change
  nclu:
    commands:
        - add hostname Cumulus-1
    commit: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add 48 interfaces and commit the change.
  nclu:
    template: |
        {% for iface in range(1,49) %}
        add int swp{{iface}}
        {% endfor %}
    commit: true
    description: "Ansible - add swps1-48"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Fetch Status Of Interface
  nclu:
    commands:
        - show interface swp1
  register: output
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Print Status Of Interface
  debug:
    var: output
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Fetch Details From All Interfaces In JSON Format
  nclu:
    commands:
        - show interface json
  register: output
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Print Interface Details
  debug:
    var: output["msg"]
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Atomically add an interface
  nclu:
    commands:
        - add int swp1
    atomic: true
    description: "Ansible - add swp1"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove IP address from interface swp1
  nclu:
    commands:
        - del int swp1 ip address 1.1.1.1/24
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Configure BGP AS and add 2 EBGP neighbors using BGP Unnumbered
  nclu:
    commands:
        - add bgp autonomous-system 65000
        - add bgp neighbor swp51 interface remote-as external
        - add bgp neighbor swp52 interface remote-as external
    commit: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Configure BGP AS and Add 2 EBGP neighbors Using BGP Unnumbered via Template
  nclu:
    template: |
      {% for neighbor in range(51,53) %}
      add bgp neighbor swp{{neighbor}} interface remote-as external
      add bgp autonomous-system 65000
      {% endfor %}
    atomic: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Check BGP Status
  nclu:
    commands:
        - show bgp summary json
  register: output
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Print BGP Status In JSON
  debug:
    var: output["msg"]

Inputs

    
abort:
    default: false
    description:
    - Boolean. When true, perform a 'net abort' before the block. This cleans out any
      uncommitted changes in the buffer. Mutually exclusive with I(atomic).
    type: bool

atomic:
    default: false
    description:
    - When true, equivalent to both I(commit) and I(abort) being true. Mutually exclusive
      with I(commit) and I(atomic).
    type: bool

commit:
    default: false
    description:
    - When true, performs a 'net commit' at the end of the block. Mutually exclusive with
      I(atomic).
    type: bool

commands:
    description:
    - A list of strings containing the net commands to run. Mutually exclusive with I(template).

template:
    description:
    - A single, multi-line string with jinja2 formatting. This string will be broken by
      lines, and each line will be run through net. Mutually exclusive with I(commands).

description:
    default: Ansible-originated commit
    description:
    - Commit description that will be recorded to the commit log if I(commit) or I(atomic)
      are true.

Outputs

changed:
  description: whether the interface was changed
  returned: changed
  sample: true
  type: bool
msg:
  description: human-readable report of success or failure
  returned: always
  sample: interface bond0 config updated
  type: str