Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ansible playbook with junos_interfaces module executes but fails to bring up a disabled port on EX3400 #40

Open
debasmitahazra opened this issue Nov 3, 2020 · 0 comments

Comments

@debasmitahazra
Copy link

Issue:

Ansible playbook with junos_interfaces module executes but fails to bring up a disabled port on EX3400.
The playbook executes successfully but has no impact on the port. However, similar playbook to disable a port brings down the port.

ANSIBLE VERSION

ansible-playbook 2.9.13
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.8/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 3.8.5 (default, Aug 12 2020, 00:00:00) [GCC 10.2.1 20200723 (Red Hat 10.2.1-1)]

NON-WORKING PLAYBOOK:juniper_port_up.yml


  • name: "Get Junos OS configuration."
    hosts: "{{ switch }}"
    roles:

    • Juniper.junos
      connection: local
      gather_facts: no

    tasks:

    • name: Enable switch port
      junos_interfaces:
      config:
      • name: "{{ port }}"
        enabled: yes >>>>>>

BEFORE EXECUTION:

ge-0/0/22 is disabled and we want the above playbook to re-enable it.

admin@EX300-CABB-TEMP> show configuration interfaces ge-0/0/22 | display set
set interfaces ge-0/0/22 description "LAB10E-NFX13 - Ge-0/0"
set interfaces ge-0/0/22 disable
set interfaces ge-0/0/22 unit 0 family ethernet-switching interface-mode trunk
set interfaces ge-0/0/22 unit 0 family ethernet-switching vlan members all
set interfaces ge-0/0/22 unit 0 family ethernet-switching storm-control default

admin@EX300-CABB-TEMP> show interfaces terse ge-0/0/22
Interface Admin Link Proto Local Remote
ge-0/0/22 down down

PLAYBOOK EXECUTION: The playbook executes but ge-0/0/22 remains disabled.

Example - Running the playbook with verbose +++

[lab@lab-ansible01 ~]$ ansible-playbook juniper_port_up.yml --extra-vars "switch=EX300-CABB-TEMP port=ge-0/0/22" -vvv
ansible-playbook 2.9.14
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/lab/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
Parsed /etc/ansible/hosts inventory source with ini plugin

PLAYBOOK: juniper_port_up.yml ******************************************************************************************************************************************************************************
1 plays in juniper_port_up.yml

PLAY [ Configuring Junos device] *************************************************************************************************************************************************************************
META: ran handlers

TASK [Enabling switch port] *******************************************************************************************************************************************************************************
task path: /home/lab/juniper_port_up.yml:8
ESTABLISH LOCAL CONNECTION FOR USER: lab
EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /home/lab/.ansible/tmp/ansible-local-30797cyspwcwk"&& mkdir "echo /home/lab/.ansible/tmp/ansible-local-30797cyspwcwk/ansible-tmp-1602683695.5519297-30803-24392853617769" && echo ansible-tmp-1602683695.5519297-30803-24392853617769="echo /home/lab/.ansible/tmp/ansible-local-30797cyspwcwk/ansible-tmp-1602683695.5519297-30803-24392853617769" ) && sleep 0'
Using module file /home/lab/.ansible/collections/ansible_collections/junipernetworks/junos/plugins/modules/junos_interfaces.py
PUT /home/lab/.ansible/tmp/ansible-local-30797cyspwcwk/tmphqptwaxw TO /home/lab/.ansible/tmp/ansible-local-30797cyspwcwk/ansible-tmp-1602683695.5519297-30803-24392853617769/AnsiballZ_junos_interfaces.py
EXEC /bin/sh -c 'chmod u+x /home/lab/.ansible/tmp/ansible-local-30797cyspwcwk/ansible-tmp-1602683695.5519297-30803-24392853617769/ /home/lab/.ansible/tmp/ansible-local-30797cyspwcwk/ansible-tmp-1602683695.5519297-30803-24392853617769/AnsiballZ_junos_interfaces.py && sleep 0'
EXEC /bin/sh -c '/usr/bin/python3 /home/lab/.ansible/tmp/ansible-local-30797cyspwcwk/ansible-tmp-1602683695.5519297-30803-24392853617769/AnsiballZ_junos_interfaces.py && sleep 0'
EXEC /bin/sh -c 'rm -f -r /home/lab/.ansible/tmp/ansible-local-30797cyspwcwk/ansible-tmp-1602683695.5519297-30803-24392853617769/ > /dev/null 2>&1 && sleep 0'
ok: [EX300-CABB-TEMP] => {
"before": [
{
"description": "Vers EX4300 - Ge-7/0/14",
"enabled": true,
"name": "ge-0/0/0"
},
{
"enabled": true,
"name": "ge-0/0/1"
},
{
"description": "LAB10E-NFX7 - Ge-0/9",
"enabled": true,
"name": "ge-0/0/2"
},
{
"description": "LAB10E-NFX7 - Ge-0/8",
"enabled": true,
"name": "ge-0/0/3"
},
{
"description": "LAB10E-NFX7 - Ge-0/0",
"enabled": true,
"name": "ge-0/0/4"
},
{
"description": "LAB10E-NFX8 - Ge-0/9",
"enabled": true,
"name": "ge-0/0/5"
},
{
"description": "LAB10E-NFX8 - Ge-0/8",
"enabled": true,
"name": "ge-0/0/6"
},
{
"description": "LAB10E-NFX8 - Ge-0/0",
"enabled": true,
"name": "ge-0/0/7"
},
{
"description": "LAB10E-NFX9 - Ge-0/9",
"enabled": true,
"name": "ge-0/0/8"
},
{
"description": "LAB10E-NFX9 - Ge-0/8",
"enabled": true,
"name": "ge-0/0/9"
},
{
"description": "LAB10E-NFX9 - Ge-0/0",
"enabled": true,
"name": "ge-0/0/10"
},
{
"description": "LAB10E-NFX10 - Ge-0/9",
"enabled": true,
"name": "ge-0/0/11"
},
{
"description": "LAB10E-NFX10 - Ge-0/8",
"enabled": true,
"name": "ge-0/0/12"
},
{
"description": "LAB10E-NFX10 - Ge-0/0",
"enabled": true,
"name": "ge-0/0/13"
},
{
"description": "LAB10E-NFX11 - Ge-0/9",
"enabled": true,
"name": "ge-0/0/14"
},
{
"description": "LAB10E-NFX11 - Ge-0/8",
"enabled": true,
"name": "ge-0/0/15"
},
{
"description": "LAB10E-NFX11 - Ge-0/0",
"enabled": true,
"name": "ge-0/0/16"
},
{
"description": "LAB10E-NFX12 - Ge-0/9",
"enabled": true,
"name": "ge-0/0/17"
},
{
"description": "LAB10E-NFX12 - Ge-0/8",
"enabled": true,
"name": "ge-0/0/18"
},
{
"description": "LAB10E-NFX12 - Ge-0/0",
"enabled": true,
"name": "ge-0/0/19"
},
{
"description": "LAB10E-NFX13 - Ge-0/9",
"enabled": true,
"name": "ge-0/0/20"
},
{
"description": "LAB10E-NFX13 - Ge-0/8",
"enabled": true,
"name": "ge-0/0/21"
},
{
"description": "LAB10E-NFX13 - Ge-0/0",
"enabled": false,
"name": "ge-0/0/22"
},
{
"description": "LAB10E-NFX14 - Ge-0/9",
"enabled": true,
"name": "ge-0/0/23"
},
{
"description": "LAB10E-NFX14 - Ge-0/8",
"enabled": true,
"name": "ge-0/0/24"
},
{
"description": "LAB10E-NFX14 - Ge-0/0",
"enabled": true,
"name": "ge-0/0/25"
},
{
"enabled": true,
"name": "ge-0/0/26"
},
{
"enabled": true,
"name": "ge-0/0/27"
},
{
"enabled": true,
"name": "ge-0/0/28"
},
{
"enabled": true,
"name": "ge-0/0/29"
},
{
"enabled": true,
"name": "ge-0/0/30"
},
{
"enabled": true,
"name": "ge-0/0/31"
},
{
"enabled": true,
"name": "ge-0/0/32"
},
{
"enabled": true,
"name": "ge-0/0/33"
},
{
"enabled": true,
"name": "ge-0/0/34"
},
{
"enabled": true,
"name": "ge-0/0/35"
},
{
"enabled": true,
"name": "ge-0/0/36"
},
{
"enabled": true,
"name": "ge-0/0/37"
},
{
"enabled": true,
"name": "ge-0/0/38"
},
{
"enabled": true,
"name": "ge-0/0/39"
},
{
"enabled": true,
"name": "ge-0/0/40"
},
{
"enabled": true,
"name": "ge-0/0/41"
},
{
"enabled": true,
"name": "ge-0/0/42"
},
{
"enabled": true,
"name": "ge-0/0/43"
},
{
"enabled": true,
"name": "ge-0/0/44"
},
{
"enabled": true,
"name": "ge-0/0/45"
},
{
"enabled": true,
"name": "ge-0/0/46"
},
{
"enabled": true,
"name": "ge-0/0/47"
},
{
"description": "IPVPN WAN LABOPS-QCMTRL3-R01",
"enabled": true,
"name": "ge-0/2/0"
},
{
"description": "IPVPN WAN LABOPS-QCMTRL4-R01",
"enabled": true,
"name": "ge-0/2/1"
},
{
"enabled": true,
"name": "ge-0/2/2"
},
{
"description": "IPVPN WAN LABOPS-QCMTRL1-R01",
"enabled": true,
"name": "xe-0/2/2"
},
{
"enabled": true,
"name": "ge-0/2/3"
},
{
"description": "IPVPN WAN LABOPS-QCMTRL2-R01",
"enabled": true,
"name": "xe-0/2/3"
},
{
"description": "Vers EX4300 - ae12",
"enabled": true,
"mtu": 9216,
"name": "ae0"
},
{
"enabled": true,
"name": "irb"
},
{
"enabled": true,
"name": "vme"
}
],
"changed": false,
"commands": [
"<nc:interfaces xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">nc:interfacenc:namege-0/0/22</nc:name></nc:interface></nc:interfaces>"
],
"invocation": {
"module_args": {
"config": [
{
"description": null,
"duplex": null,
"enabled": true,
"hold_time": null,
"mtu": null,
"name": "ge-0/0/22",
"speed": null
}
],
"running_config": null,
"state": "merged"
}
}
}
META: ran handlers
META: ran handlers

PLAY RECAP *************************************************************************************************************************************************************************************************
EX300-CABB-TEMP : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

AFTER EXECUTION: The playbook executes successfully but doesn't disable ge-0/0/22.

admin@EX300-CABB-TEMP> show interfaces terse ge-0/0/22
Interface Admin Link Proto Local Remote
ge-0/0/22 down down

Interestingly, the playbook to disable a port successfully disables a port.

WORKING PLAYBOOK:juniper_port_down.yml


  • name: "Get Junos OS configuration."
    hosts: "{{ switch }}"
    roles:

    • Juniper.junos
      connection: local
      gather_facts: no

    tasks:

    • name: Enable switch port
      junos_interfaces:
      config:
      • name: "{{ port }}"
        enabled: no >>>>>>>

WORKAROUND:

junos_interfaces is the newer module. junos_interface( without the s at the end) is the older module.

If we use the older interface module, then the playbook can successfully bring up the disabled port.

WORKAROUND PLAYBOOK:


  • name: "Get Junos OS configuration."

    hosts: junos

    connection: local

    roles:

    • Juniper.junos

    gather_facts: no

    tasks:

    • name: remove interface

      junos_interface: >>>>>>>>>>>>

      name: ge-0/0/1

      enabled: yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant