Skip to content
Snippets Groups Projects
Commit 0fc352e3 authored by Simone Spinelli's avatar Simone Spinelli
Browse files

Merge branch 'fix_chassis_template_for_vmx' into 'main'

Fix chassis template for vmx and other things

See merge request !8
parents 91dd60fd 27cd5ec3
No related branches found
No related tags found
1 merge request!8Fix chassis template for vmx and other things
Showing
with 65 additions and 69 deletions
---
- hosts: all
user: admin
vars_files:
- /opt/ansible_inventory/group_vars/junos/device_access.yaml
tasks:
- name: collect default set of facts
junipernetworks.junos.junos_facts:
gather_subset: hardware
register: router_facts
- name: show facts
debug:
msg: "{{ router_facts }}"
- name: Manage iptrunks checks playbook
hosts: all
remote_user: admin
vars_files:
- /opt/ansible_inventory/group_vars/junos/router_access.yaml
gather_facts: false
roles:
- Juniper.junos
- roles/iptrunks_checks
{% include 'class_of_service.j2' %}
{% include 'chassis.j2' %}
{# #}
{% include 'forwarding_options.j2' %}
{# #}
{% include 'firewall.j2' %}
......
......@@ -70,6 +70,7 @@ replace: chassis {
}
{% endfor %}
{% else %}
{% if 'vmx' not in ansible_net_model %}
{% for net_module in ansible_net_modules %}
{% if 'FPC' in net_module.name %}
{% set fpc_name_as_list = net_module.name.split(" ") %}
......@@ -90,6 +91,7 @@ replace: chassis {
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% if chassis_enhanced_ip is sameas true %}
network-services enhanced-ip;
{% endif %}
......
......@@ -26,7 +26,7 @@ replace: dsc {
}
}
}
{% if is_ias_connected is true %}
lt-0/0/0 {
replace: unit 16 {
......@@ -60,4 +60,5 @@ replace: unit 61 {
}
}
}
{% endif %}
}
localhost
---
- hosts: localhost
remote_user: root
roles:
- base_config
......@@ -13,6 +13,7 @@ si_ipv4_network: "{{ wfo_router.router.router_si_ipv4_network }}"
lt_ipv4_network: "{{ wfo_router.router.router_ias_lt_ipv4_network }}"
lt_ipv6_network: "{{ wfo_router.router.router_ias_lt_ipv6_network }}"
site_country_code: "{{ wfo_router.router.router_site.site_country_code }}"
is_ias_connected: "{{ wfo_router.router.is_ias_connected }}"
mytemplates:
template_name: base_config
......
......@@ -3,7 +3,7 @@
ansible.builtin.set_fact:
ansible_host: localhost
when:
( local_side.router_access_via_ts | ansible.builtin.bool ) is true
( local_side.iptrunk_side_node.router_access_via_ts | ansible.builtin.bool ) is true
- name: Create a folder for all the templates
ansible.builtin.file:
......@@ -14,7 +14,7 @@
- name: Print the template in "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf"
ansible.builtin.template:
src: "{{ local_side.router_vendor }}/{{ config_object }}.j2"
src: "{{ local_side.iptrunk_side_node.router_vendor }}/{{ config_object }}.j2"
dest: "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf"
lstrip_blocks: true
trim_blocks: true
......@@ -23,7 +23,7 @@
- name: Set ansible_host to terminal server when router is offline
ansible.builtin.set_fact:
ansible_host: "{{ local_side.router_site.site_ts_address }}"
ansible_port: "{{ local_side.router_ts_port }}"
ansible_host: "{{ local_side.iptrunk_side_node.router_site.site_ts_address }}"
ansible_port: "{{ local_side.iptrunk_side_node.router_ts_port }}"
when:
( local_side.router_access_via_ts | ansible.builtin.bool ) is true
( local_side.iptrunk_side_node.router_access_via_ts | ansible.builtin.bool ) is true
......@@ -10,7 +10,7 @@
register: response
when: >
verb == "deploy" and
local_side.router_vendor == "juniper" and
local_side.iptrunk_side_node.router_vendor == "juniper" and
dry_run | ansible.builtin.bool
- name: Show DRY diff of "{{ config_object }}"
......@@ -19,7 +19,7 @@
when: >
verb == "deploy"
and dry_run | ansible.builtin.bool and
local_side.router_vendor == "juniper"
local_side.iptrunk_side_node.router_vendor == "juniper"
- name: Deploy "{{ config_object }}" on "{{ inventory_hostname }}" [AND COMMIT][JUNIPER]
juniper_junos_config:
......@@ -32,7 +32,7 @@
register: response
when: >
verb == "deploy" and
local_side.router_vendor == "juniper" and
local_side.iptrunk_side_node.router_vendor == "juniper" and
not (dry_run | ansible.builtin.bool)
- name: Show real diff of "{{ config_object }}"
......@@ -40,31 +40,31 @@
msg: "{{ response }}"
when: >
verb == "deploy" and
local_side.router_vendor == "juniper" and
local_side.iptrunk_side_node.router_vendor == "juniper" and
not (dry_run | ansible.builtin.bool)
- name: Deploy "{{ config_object }}" on "{{ inventory_hostname }}" [CHECK ONLY][NOKIA]
ansible.netcommon.netconf_config:
format: xml
default_operation: merge
content: "{{ lookup('ansible.builtin.template', '{{ local_side.router_vendor }}/{{ config_object }}.j2') }}"
content: "{{ lookup('ansible.builtin.template', '{{ local_side.iptrunk_side_node.router_vendor }}/{{ config_object }}.j2') }}"
commit: true
diff: true
check_mode: true
when: >
verb == "deploy" and
( dry_run | ansible.builtin.bool ) is true and
local_side.router_vendor == "nokia"
local_side.iptrunk_side_node.router_vendor == "nokia"
- name: Deploy base_config on "{{ inventory_hostname }}" [AND COMMIT][NOKIA]
ansible.netcommon.netconf_config:
format: xml
default_operation: merge
content: "{{ lookup('ansible.builtin.template', '{{ local_side.router_vendor }}/{{ config_object }}.j2') }}"
content: "{{ lookup('ansible.builtin.template', '{{ local_side.iptrunk_side_node.router_vendor }}/{{ config_object }}.j2') }}"
commit: true
diff: true
check_mode: false
when: >
verb == "deploy" and
( dry_run | ansible.builtin.bool ) is false and
local_side.router_vendor == "nokia"
local_side.iptrunk_side_node.router_vendor == "nokia"
......@@ -36,8 +36,8 @@
- name: Load netconf connection config
ansible.builtin.set_fact:
ansible_connection: "{{ netconf_access[local_side.router_vendor].ansible_connection }}"
ansible_network_os: "{{ netconf_access[local_side.router_vendor].ansible_network_os }}"
ansible_connection: "{{ netconf_access[local_side.iptrunk_side_node.router_vendor].ansible_connection }}"
ansible_network_os: "{{ netconf_access[local_side.iptrunk_side_node.router_vendor].ansible_network_os }}"
- name: Load remote info
ansible.builtin.set_fact:
......@@ -47,10 +47,10 @@
- name: Set ansible_host to terminal server when router is offline
ansible.builtin.set_fact:
ansible_host: "{{ local_side.router_site.site_ts_address }}"
ansible_port: "{{ local_side.router_ts_port }}"
ansible_host: "{{ local_side.iptrunk_side_node.router_site.site_ts_address }}"
ansible_port: "{{ local_side.iptrunk_side_node.router_ts_port }}"
when:
( local_side.router_access_via_ts | ansible.builtin.bool ) is true
( local_side.iptrunk_side_node.router_access_via_ts | ansible.builtin.bool ) is true
- name: Print the ID
ansible.builtin.debug:
......
localhost
---
- hosts: localhost
remote_user: root
roles:
- iptrunks
- name: Show LACP status
juniper_junos_command:
command: "show lacp interface {{ trunks[0].config.nodeA.ae_name }}"
register: response
- name: Print the LACP status.
ansible.builtin.debug:
var: response.stdout_lines
- name: Ping "{{ trunks[0].config.nodeB.name }} on {{ side_b_ipv4_address.split('/')[0] }}"
juniper_junos_ping:
dest: "{{ side_b_ipv4_address.split('/')[0] }}"
......
......@@ -10,9 +10,21 @@
ansible.builtin.meta: end_play
when: (check is not defined) or (check not in checks)
- name: Gather_facts
junipernetworks.junos.junos_facts:
gather_subset: all
- name: Import routers variables
ansible.builtin.include_vars:
dir: /opt/ansible_inventory/group_vars/routers
- name: Set ansible_host to terminal server when router is offline
ansible.builtin.set_fact:
ansible_host: "{{ wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_site.site_ts_address }}"
ansible_port: "{{ wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_ts_port }}"
when:
( wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_access_via_ts | ansible.builtin.bool ) is true
- name: Load netconf connection config
ansible.builtin.set_fact:
ansible_connection: "{{ netconf_access[wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_vendor].ansible_connection }}"
ansible_network_os: "{{ netconf_access[wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_vendor].ansible_network_os }}"
- name: Check ISIS
ansible.builtin.include_tasks: check_isis.yaml
......
......@@ -19,26 +19,26 @@ trunks:
common:
description: "{{ wfo_trunk.iptrunk.iptrunk_description }}"
speed: "{{ wfo_trunk.iptrunk.iptrunk_speed }}"
is_leased_line: false
is_leased_line: false ## Fix it to use iptrunk_type
isis_metric: "{{ wfo_trunk.iptrunk.iptrunk_isis_metric }}"
minimum_links: 1
minimum_links: "{{ wfo_trunk.iptrunk.iptrunk_minimum_links }}"
nodeA:
name: "{{ wfo_trunk.iptrunk.iptrunk_sideA_node.router_fqdn }}"
router_access_via_ts: "{{ wfo_trunk.iptrunk.iptrunk_sideA_node.router_access_via_ts }}"
loopback: "{{ wfo_trunk.iptrunk.iptrunk_sideA_node.router_lo_ipv4_address }}"
ae_name: "{{ wfo_trunk.iptrunk.iptrunk_sideA_ae_iface }}"
name: "{{ wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn }}"
router_access_via_ts: "{{ wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_access_via_ts }}"
loopback: "{{ wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_lo_ipv4_address }}"
ae_name: "{{ wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_ae_iface }}"
ipv4_address: "{{ side_a_ipv4_address }}"
ipv6_address: "{{ side_a_ipv6_address }}"
members: "{{ wfo_trunk.iptrunk.iptrunk_sideA_ae_members }}"
members_descriptions: "{{ wfo_trunk.iptrunk.iptrunk_sideA_ae_members_description }}"
port_sid: "{{ wfo_trunk.iptrunk.iptrunk_sideA_ae_geant_a_sid }}"
members: "{{ wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_ae_members }}"
members_descriptions: "{{ wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_ae_members_description }}"
port_sid: "{{ wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_ae_geant_a_sid }}"
nodeB:
name: "{{ wfo_trunk.iptrunk.iptrunk_sideB_node.router_fqdn }}"
router_access_via_ts: "{{ wfo_trunk.iptrunk.iptrunk_sideB_node.router_access_via_ts }}"
loopback: "{{ wfo_trunk.iptrunk.iptrunk_sideB_node.router_lo_ipv4_address }}"
ae_name: "{{ wfo_trunk.iptrunk.iptrunk_sideB_ae_iface }}"
name: "{{ wfo_trunk.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn }}"
router_access_via_ts: "{{ wfo_trunk.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_access_via_ts }}"
loopback: "{{ wfo_trunk.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_lo_ipv4_address }}"
ae_name: "{{ wfo_trunk.iptrunk.iptrunk_sides[1].iptrunk_side_ae_iface }}"
ipv4_address: "{{ side_b_ipv4_address }}"
ipv6_address: "{{ side_b_ipv6_address }}"
members: "{{ wfo_trunk.iptrunk.iptrunk_sideB_ae_members }}"
members_descriptions: "{{ wfo_trunk.iptrunk.iptrunk_sideB_ae_members_description }}"
port_sid: "{{ wfo_trunk.iptrunk.iptrunk_sideB_ae_geant_a_sid }}"
members: "{{ wfo_trunk.iptrunk.iptrunk_sides[1].iptrunk_side_ae_members }}"
members_descriptions: "{{ wfo_trunk.iptrunk.iptrunk_sides[1].iptrunk_side_ae_members_description }}"
port_sid: "{{ wfo_trunk.iptrunk.iptrunk_sides[1].iptrunk_side_ae_geant_a_sid }}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment