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

Merge branch 'add_post_checks_to_base_config' into 'develop'

Add a role to perform checks after base config

See merge request !64
parents 767d19a5 5a57880c
No related branches found
No related tags found
1 merge request!64Add a role to perform checks after base config
Pipeline #85234 passed
variables:
release_branch: "release"
target_branche: "main"
stages: # List of stages for jobs, and their order of execution
- setup
- test
- build
- publish
#publish-job: # This job runs in the build stage, which runs first.
# stage: publish
# script:
# - cd geant
# - ansible-galaxy collection publish ops_ansible --api-key $ANSIBLE_VARIABLE_API_KEY
# tags:
# - ansible
# - lab
# rules:
# - if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /^feature/ && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
#build-job: # This job runs in the build stage, which runs first.
# stage: build
# script:
# - cd geant
# - ansible-galaxy collection build ops_ansible
# tags:
# - ansible
# - lab
# artifacts:
# paths:
# - ./*.tar.gz
# only:
# - main
lint-test-job: # This job also runs in the test stage.
stage: test # It can run at the same time as unit-test-job (in parallel).
script:
- /home/gitlab-runner/.local/bin/ansible-lint --exclude .gitlab-ci.yml
tags:
- ansible
- lab
install-dependencies:
stage: setup
stages:
- linting
ansible-lint:
stage: linting
image: registry.gitlab.com/pipeline-components/ansible-lint:latest
before_script:
- python -m pip install jmespath
- ansible-galaxy role install Juniper.junos
script:
- pip install jmespath
- ansible-galaxy role install Juniper.junos
- ansible-lint --exclude *.py -f codeclimate | python -m json.tool | tee "${CI_PROJECT_DIR}/codeclimate-results.json"
artifacts:
name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"
reports:
codequality:
- "${CI_PROJECT_DIR}/codeclimate-results.json"
paths:
- "${CI_PROJECT_DIR}/codeclimate-results.json"
tags:
- ansible
- lab
- docker-executor
---
# Collections must specify a minimum required ansible version to upload
# to galaxy
requires_ansible: '>=2.9.10'
requires_ansible: '>=2.15.0'
# Content that Ansible needs to load from another location or that has
# been deprecated/removed
......
- name: Run checks against a newly installed router
hosts: all
connection: netconf
gather_facts: false
remote_user: admin
roles:
- ../roles/base_config_checks
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
- name: "Execute {{ item.command }}"
ansible.netcommon.netconf_rpc:
rpc: action
xmlns: "urn:ietf:params:xml:ns:yang:1"
content: "{{ lookup('ansible.builtin.template', './base_config_single_command.j2') }}"
display: json
register: out
- name: "Results of {{ item.command }}"
ansible.builtin.debug:
msg: "{{out.output['rpc-reply']['nokiaoper:results']['nokiaoper:md-cli-output-block'].split('\n')}}"
---
- name: Execute post-check command
ansible.builtin.include_tasks: base_config_single_command.yaml
with_items: "{{ commands }}"
<global-operations xmlns="urn:nokia.com:sros:ns:yang:sr:oper-global">
<md-cli-raw-command>
<md-cli-input-line>{{item.command}}</md-cli-input-line>
</md-cli-raw-command>
</global-operations>
---
# vars file for base_config_checks
commands:
- command: show version
description: "Shows the version of SROS"
- command: show chassis
description: "Shows the status of the chassis"
- command: show card
description: "Shows the status of the cards"
- command: show port
description: "Shows the status of the ports"
- command: show mda
description: "Shows the status of the mdas"
- command: show sfm
description: "Shows the status of Switching Fabric Modules"
- command: show redundancy synchronization
description: "Shows the status of the syncronization"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment