Skip to content
Snippets Groups Projects
Commit b3bf40cd authored by Aleksandr Kurbatov's avatar Aleksandr Kurbatov
Browse files

initial work

parent d1265dca
No related branches found
No related tags found
1 merge request!137Fix calculation of Ansible parameters to connect to the nodes
---
###############################################################################################################
# The playbook does the following:
#
#
# - Runs the command 'show interfaces diagnostics optics {{ interface }} | no-more' and gets the json output
# - From json output it retrieves the apporpriate metrics for optical levels
# - Saves the metrics in relevant variable names
###############################################################################################################
- name: Get Junos attributes for optical levels of interface "{{ item }}"
when: local_side.iptrunk_side_node.vendor == "juniper"
block:
- name: Run Juniper Optical info
junipernetworks.junos.junos_command:
commands: "show interfaces diagnostics optics {{ item.interface_name }} | no-more"
commands:
# - show interfaces diagnostics optics {{ item.interface_name }} | no-more
- show interfaces terse {{ item.interface_name }}
# display: json
register: optical_status
......@@ -21,6 +14,13 @@
ansible.builtin.debug:
msg: "{{ optical_status }}"
- name: Write output to the file
ansible.builtin.blockinfile:
path: "{{ opt_checks_file }}"
marker: "# {mark} --- {{ check | uppper }} check on {{ inventory_hostname }} for {{ item.interface_name }} ---"
append_newline: true
block: "{{ optical_status }}"
- name: Get Nokia optical levels on port "{{ item.interface_name }}"
when: local_side.iptrunk_side_node.vendor == "nokia"
block:
......@@ -35,7 +35,7 @@
content: |
<global-operations xmlns="urn:nokia.com:sros:ns:yang:sr:oper-global">
<md-cli-raw-command>
<md-cli-input-line>show port {{ connector }} optical</md-cli-input-line>
<md-cli-input-line>show port {{ connector }} optical | match "Lane ID" pre-lines 1 post-lines 5</md-cli-input-line>
</md-cli-raw-command>
</global-operations>
display: json
......
......@@ -3,7 +3,7 @@
- name: Print the usage
ansible.builtin.debug:
msg:
- "Allowed checks: 'ping', 'isis'"
- "Allowed checks: 'ping', 'isis', 'lacp', 'optical_pre', 'optical_post'"
when: (check is not defined) or (check not in checks)
- name: Fail if arguments are not correct
......@@ -46,7 +46,33 @@
ansible.builtin.include_tasks: check_trunk_interface.yaml
when: check == "ping"
- name: Set the optical checks results directory name
when: check == "optical_pre" or check == "optical_post"
ansible.builtin.set_fact:
opt_checks_dir: "/var/tmp/ansible_trunk_checks_{{ trunks[0].id }}"
- name: Set the optical checks results file name
when: check == "optical_pre" or check == "optical_post"
ansible.builtin.set_fact:
opt_checks_file: "{{ opt_checks_dir }}/checks_{{ process_id }}.txt"
- name: Create a folder for the optical check results
when: check == "optical_pre" or check == "optical_post"
ansible.builtin.file:
path: "{{ opt_checks_dir }}"
state: directory
mode: '0755'
delegate_to: localhost
- name: Create file for the optical check results
when: check == "optical_pre" or check == "optical_post"
ansible.builtin.file:
path: "{{ opt_checks_file }}"
state: touch
mode: '0644'
delegate_to: localhost
- name: Check optical levels
when: check == "optical_pre" or check == "optical_post"
ansible.builtin.include_tasks: check_optical_levels.yaml
when: check == "optical"
loop: "{{ local_side.iptrunk_side_ae_members }}"
......@@ -6,7 +6,8 @@ checks:
- isis
- ping
- lacp
- optical
- optical_pre
- optical_post
ping_count: 3
ping_size: 9000
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment