Files
kayobe/ansible/roles/junos-switch
Pierre Riteau 1372a7b01e junos-switch: Fix junos_config call
The junos_config module dropped support for the provider parameter and
for connection: local [1]. Apply a similar to fix to the Arista one [2].

[1] https://github.com/ansible-collections/junipernetworks.junos/pull/333
[2] https://review.opendev.org/c/openstack/kayobe/+/922631

Closes-Bug: #2111341
Change-Id: I531862fa9bebb8ef8ee900457278e0959dbe66cc
Signed-off-by: Pierre Riteau <pierre@stackhpc.com>
2025-07-03 12:25:42 +02:00
..
2025-07-03 12:25:42 +02:00
2025-07-03 12:25:42 +02:00

JunOS Switch

This role configures Juniper switches using the junipernetworks.junos Ansible collection. It provides a fairly minimal abstraction of the configuration interface provided by the collection, allowing for application of arbitrary switch configuration options.

Requirements

The switches should be configured to allow access to NETCONF via SSH.

Role Variables

junos_switch_config_format is the format of configuration in junos_switch_config and junos_switch_interface_config. May be one of set, text or json.

junos_switch_config is a list of configuration lines to apply to the switch, and defaults to an empty list.

junos_switch_interface_config contains interface configuration. It is a dict mapping switch interface names to configuration dicts. Each dict may contain the following items:

  • description - a description to apply to the interface.
  • config - a list of per-interface configuration.

Dependencies

None

Example Playbook

The following playbook configures hosts in the junos-switches group. It assumes host variables for each switch holding the host, username and passwords. It applies global configuration for LLDP, and enables two 10G ethernet interfaces.

---
- name: Ensure Junos switches are configured
  hosts: junos-switches
  gather_facts: no
  roles:
    - role: junos-switch
      junos_switch_config:
        - "protocols {"
        - "    lldp {"
        - "        interface all;"
        - "    }"
        - "}"
      junos_switch_interface_config:
        xe-1/1/1:
          description: server-1
          config:
            - "enable"
        xe-1/1/2:
          description: server-2
          config:
            - "enable"

Author Information