From 1372a7b01e1b4022f486aba01f4010efc724ada8 Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Thu, 3 Jul 2025 12:25:42 +0200 Subject: [PATCH] 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 --- .../inventory/group_vars/all/switches/junos | 19 ------------------- ansible/physical-network.yml | 1 - ansible/roles/junos-switch/README.md | 19 ++++--------------- ansible/roles/junos-switch/defaults/main.yml | 3 --- ansible/roles/junos-switch/tasks/main.yml | 4 +--- .../reference/physical-network.rst | 14 ++------------ .../notes/bug-2111341-706fe5689414a9c1.yaml | 15 +++++++++++++++ 7 files changed, 22 insertions(+), 53 deletions(-) create mode 100644 releasenotes/notes/bug-2111341-706fe5689414a9c1.yaml diff --git a/ansible/inventory/group_vars/all/switches/junos b/ansible/inventory/group_vars/all/switches/junos index d833c2937..df82bb48c 100644 --- a/ansible/inventory/group_vars/all/switches/junos +++ b/ansible/inventory/group_vars/all/switches/junos @@ -1,28 +1,9 @@ --- # Switch configuration. -############################################################################### -# Authentication configuration. - -# For Juniper switches, this defines a 'provider' argument to the junos_* -# modules. -switch_junos_provider: - host: "{{ ansible_host|default(inventory_hostname) }}" - username: "{{ ansible_user }}" - password: "{{ ansible_ssh_pass|default(omit) }}" - ssh_keyfile: "{{ ansible_ssh_private_key_file|default(omit) }}" - timeout: "{{ switch_junos_timeout }}" - ############################################################################### # Configuration format. # Format of configuration in junos_switch_config and # junos_switch_interface_config. May be one of 'set', 'text' or 'json'. switch_junos_config_format: text - -############################################################################### -# Timeout. - -# Timeout in seconds for communicating with the network device either for -# connecting or sending commands. -switch_junos_timeout: 10 diff --git a/ansible/physical-network.yml b/ansible/physical-network.yml index f3bfaf00f..3361301c4 100644 --- a/ansible/physical-network.yml +++ b/ansible/physical-network.yml @@ -173,7 +173,6 @@ - role: junos-switch junos_switch_type: "{{ switch_type }}" - junos_switch_provider: "{{ switch_junos_provider }}" junos_switch_config_format: "{{ switch_junos_config_format }}" junos_switch_config: "{{ switch_config }}" junos_switch_interface_config: "{{ switch_interface_config }}" diff --git a/ansible/roles/junos-switch/README.md b/ansible/roles/junos-switch/README.md index ed0652dfc..fa7604883 100644 --- a/ansible/roles/junos-switch/README.md +++ b/ansible/roles/junos-switch/README.md @@ -1,10 +1,10 @@ JunOS Switch ============ -This role configures Juniper switches using the `junos` Ansible modules. It -provides a fairly minimal abstraction of the configuration interface provided -by the `junos` modules, allowing for application of arbitrary switch -configuration options. +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 ------------ @@ -14,12 +14,6 @@ The switches should be configured to allow access to NETCONF via SSH. Role Variables -------------- -`junos_switch_delegate_to` is the host on which to execute the `junos` Ansible -modules. - -`junos_switch_provider` is authentication provider information passed as the -`provider` argument to the `junos` modules. - `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`. @@ -53,11 +47,6 @@ passwords. It applies global configuration for LLDP, and enables two gather_facts: no roles: - role: junos-switch - junos_switch_delegate_to: localhost - junos_switch_provider: - host: "{{ switch_host }}" - username: "{{ switch_user }}" - password: "{{ switch_password }}" junos_switch_config: - "protocols {" - " lldp {" diff --git a/ansible/roles/junos-switch/defaults/main.yml b/ansible/roles/junos-switch/defaults/main.yml index 09da1a600..8df0d41fb 100644 --- a/ansible/roles/junos-switch/defaults/main.yml +++ b/ansible/roles/junos-switch/defaults/main.yml @@ -1,7 +1,4 @@ --- -# Authentication provider information. -junos_switch_provider: - # Format of configuration in junos_switch_config and # junos_switch_interface_config. May be one of 'set', 'text' or 'json'. junos_switch_config_format: text diff --git a/ansible/roles/junos-switch/tasks/main.yml b/ansible/roles/junos-switch/tasks/main.yml index c06a377a0..d5fea0cce 100644 --- a/ansible/roles/junos-switch/tasks/main.yml +++ b/ansible/roles/junos-switch/tasks/main.yml @@ -15,9 +15,7 @@ run_once: true - name: Ensure Juniper switches are configured - local_action: - module: junos_config - provider: "{{ junos_switch_provider }}" + junos_config: src: "{{ junos_switch_src }}" src_format: "{{ junos_switch_config_format }}" vars: diff --git a/doc/source/configuration/reference/physical-network.rst b/doc/source/configuration/reference/physical-network.rst index e0e69cc18..d1bbf8999 100644 --- a/doc/source/configuration/reference/physical-network.rst +++ b/doc/source/configuration/reference/physical-network.rst @@ -293,24 +293,14 @@ module. configuration. The variable is passed as the ``src_format`` argument to the ``junos_config`` module. The default value is ``text``. -Provider -^^^^^^^^ - * ``ansible_host`` is the hostname or IP address. Optional. - * ``ansible_user`` is the SSH username. - * ``ansible_ssh_pass`` is the SSH password. Mutually exclusive with ``ansible_ssh_private_key_file``. - * ``ansible_ssh_private_key_file`` is the SSH private key file. Mutually exclusive with ``ansible_ssh_pass``. - -* ``switch_junos_timeout`` may be set to a timeout in seconds for communicating - with the device. - -Alternatively, set ``switch_junos_provider`` to the value to be passed as the -``provider`` argument to the ``junos_config`` module. +* ``ansible_connection`` should be ``ansible.netcommon.netconf``. +* ``ansible_network_os`` should be ``junipernetworks.junos.junos``. Mellanox MLNX OS ---------------- diff --git a/releasenotes/notes/bug-2111341-706fe5689414a9c1.yaml b/releasenotes/notes/bug-2111341-706fe5689414a9c1.yaml new file mode 100644 index 000000000..fee46a379 --- /dev/null +++ b/releasenotes/notes/bug-2111341-706fe5689414a9c1.yaml @@ -0,0 +1,15 @@ +--- +upgrade: + - | + Deployments using Juniper Junos OS switches are required to update their + configuration according to `Juniper Junos OS documentation + `_. + This is due to the ``junos_config`` module dropping support for the + ``provider`` parameter. +fixes: + - | + Fixes physical network configuration for Juniper Junos OS switches. + Note that users are required to update their configuration according to + `Juniper Junos OS documentation + `_. + `LP#2111341 `__