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 code bot recommendations #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions execution-environment/execution-environment.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
version: 1

ansible_config: 'ansible.cfg'
ansible_config: ansible.cfg

dependencies:
galaxy: requirements.yml
python: requirements.txt

additional_build_steps:
prepend: |
RUN pip3 install --upgrade pip setuptools
prepend: |-
RUN pip3 install --upgrade pip setuptools
2 changes: 1 addition & 1 deletion playbooks/get_incident_id.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

tasks:
- name: print incident id
set_stats:
ansible.builtin.set_stats:
data:
incident_id: "{{ incident_id }}"
2 changes: 1 addition & 1 deletion playbooks/inventory/hosts.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
all:
children:
now_dev:
hosts:
dev87069.service-now.com:

branch:
hosts:
rtr_branch1:
Expand Down
14 changes: 7 additions & 7 deletions playbooks/test-ospf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# when: "'error' in ospf_neighbors"
rescue:
- name: print which device has errors on show ip ospf neighbors
debug:
ansible.builtin.debug:
msg: "{{ inventory_hostname }} did not return ospf neighbors"

- name: parse show ip ospf interface brief
Expand All @@ -31,7 +31,7 @@
name: ansible.netcommon.pyats
set_fact: ospf_interface
- name: print ospf interface
debug:
ansible.builtin.debug:
msg: "{{ ospf_interface['instance'] }}"

- name: validate ospf interface
Expand All @@ -44,10 +44,10 @@
register: result

- name: print validate results
debug:
msg: "{{ inventory_hostname }}: {{ item['data_path'].split('.')[7] }} is not in DR or BDR state"
loop: "{{ result['errors'] }}"
when: "'errors' in result"
ansible.builtin.debug:
msg: "{{ inventory_hostname }}: {{ item['data_path'].split('.')[7] }} is not in DR or BDR state"

- name: validate interfaces
ansible.utils.cli_parse:
Expand All @@ -59,13 +59,13 @@

- name: show int status
# include_tasks: test-int.yml
debug:
msg: "{{ item.key }} {{ item.value.enabled }} {{item.value.line_protocol }}"
loop: "{{ (iosxe_show_interface | dict2items) }}"
tags: interface
ansible.builtin.debug:
msg: "{{ item.key }} {{ item.value.enabled }} {{item.value.line_protocol }}"

- name: set stats
set_stats:
ansible.builtin.set_stats:
data:
interface_report: "{{ iosxe_show_interface }}"

Expand Down
8 changes: 4 additions & 4 deletions playbooks/test_branch_ping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
set_fact: ios_ping_core

- name: print ping info
debug:
ansible.builtin.debug:
msg: "{{ ios_ping_core }}"

- name: evaluate if ping is responsive
Expand All @@ -33,12 +33,10 @@


- name: add dict keys for router names
set_fact:
ansible.builtin.set_fact:
hostname_ping_result_data: "{{ ping_result_data | default ({}) | combine({inventory_hostname: ios_ping_result }) }}"

- name: create one dictionary of default route data
set_fact:
ping_result_data: "{{ ping_result_data | default ({}) | combine(item) }}"
loop: >-
{{
groups['branch']
Expand All @@ -47,6 +45,8 @@
| list
}}
run_once: true
ansible.builtin.set_fact:
ping_result_data: "{{ ping_result_data | default ({}) | combine(item) }}"

- name: set fact for use in workflow
ansible.builtin.set_stats:
Expand Down
6 changes: 3 additions & 3 deletions playbooks/test_def_route.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@
ospf_def_route: { default_route: false }

- name: add dict keys for router names
set_fact:
ansible.builtin.set_fact:
hostname_def_route_data: "{{ def_route_data | default ({}) | combine({inventory_hostname: ospf_def_route }) }}"

- name: create one dictionary of default route data
set_fact:
def_route_data: "{{ def_route_data | default ({}) | combine(item) }}"
loop: >-
{{
groups['branch']
Expand All @@ -41,6 +39,8 @@
| list
}}
run_once: true
ansible.builtin.set_fact:
def_route_data: "{{ def_route_data | default ({}) | combine(item) }}"

- name: set fact for use in workflow
ansible.builtin.set_stats:
Expand Down
8 changes: 4 additions & 4 deletions playbooks/test_interface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
set_fact: iosxe_show_interface

- name: combine
set_fact:
ansible.builtin.set_fact:
hostname_interface_data: "{{ interface_data | combine({inventory_hostname: iosxe_show_interface.interface }) }}"

- name: data
set_fact:
interface_data: "{{ interface_data | combine(item) }}"
loop: >-
{{
groups['routers']
Expand All @@ -27,8 +25,10 @@
| list
}}
run_once: true
ansible.builtin.set_fact:
interface_data: "{{ interface_data | combine(item) }}"

- name: set dictionary as stats for use in workflow
set_stats:
ansible.builtin.set_stats:
data:
interface_data: "{{ interface_data }}"
13 changes: 7 additions & 6 deletions playbooks/test_ospf_int.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,18 @@

rescue:
- name: print which device has errors on show ip ospf neighbors
debug:
ansible.builtin.debug:
msg: "{{ inventory_hostname }} did not return ospf neighbors"

- name: print result
set_fact:
ansible.builtin.set_fact:
ospf_int_result: "{{ result }}"

- name: add dict keys for router names
set_fact:
ansible.builtin.set_fact:
ospf_int_error_data: "{{ ospf_error_data | default ({}) | combine({inventory_hostname: ospf_int_result }) }}"

- name: create one dictionary of ospf neighbor data
set_fact:
ospf_error_data: "{{ ospf_error_data | combine(item) }}"
loop: >-
{{
groups['routers']
Expand All @@ -50,8 +49,10 @@
| list
}}
run_once: true
ansible.builtin.set_fact:
ospf_error_data: "{{ ospf_error_data | combine(item) }}"

- name: set stats for ospf int data to use in workflow
set_stats:
ansible.builtin.set_stats:
data:
ospf_error_data: "{{ ospf_error_data }}"
10 changes: 5 additions & 5 deletions playbooks/test_ospf_nei.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@
ospf_neighbors: "{{ ospf_neighbors }}"
rescue:
- name: if router has no neighbors create custom error dict
set_fact:
ansible.builtin.set_fact:
ospf_neighbors: "{{ ospf_neighbors | default ({}) | combine(no_ospf_nei_dict) }}"

- name: add dict keys for router names
set_fact:
ansible.builtin.set_fact:
hostname_ospf_data: "{{ ospf_nei_data | combine({inventory_hostname: ospf_neighbors.interfaces }) }}"

- name: create one dictionary of ospf neighbor data
set_fact:
ospf_nei_data: "{{ ospf_nei_data | combine(item) }}"
loop: >-
{{
groups['routers']
Expand All @@ -39,8 +37,10 @@
| list
}}
run_once: true
ansible.builtin.set_fact:
ospf_nei_data: "{{ ospf_nei_data | combine(item) }}"

- name: set stats to send ospf nei info to workflow
set_stats:
ansible.builtin.set_stats:
data:
ospf_nei_data: "{{ ospf_nei_data }}"