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>
This commit is contained in:
Pierre Riteau
2025-07-03 12:25:42 +02:00
parent b67587ef6f
commit 1372a7b01e
7 changed files with 22 additions and 53 deletions

View File

@@ -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

View File

@@ -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 }}"

View File

@@ -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 {"

View File

@@ -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

View File

@@ -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:

View File

@@ -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
----------------

View File

@@ -0,0 +1,15 @@
---
upgrade:
- |
Deployments using Juniper Junos OS switches are required to update their
configuration according to `Juniper Junos OS documentation
<https://docs.openstack.org/kayobe/latest/configuration/reference/physical-network.html#juniper-junos-os>`_.
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
<https://docs.openstack.org/kayobe/latest/configuration/reference/physical-network.html#juniper-junos-os>`_.
`LP#2111341 <https://bugs.launchpad.net/kayobe/+bug/2111341>`__