-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add role for verificcation if vmanage sw version matches requirements
- Loading branch information
Showing
5 changed files
with
142 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace: cisco | ||
name: catalystwan | ||
version: 0.3.1 | ||
version: 0.3.2 | ||
readme: README.md | ||
authors: | ||
- Arkadiusz Cichon <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Ansible Role: vmanage_version | ||
|
||
This Ansible role is checks if vManage version matches requirements. | ||
|
||
## Role Description | ||
|
||
The `vmanage_version` role performs the following tasks: | ||
|
||
1. Get software version from vManage. | ||
2. Verify if version matches requirements. | ||
|
||
## Requirements | ||
|
||
- `cisco.catalystwan` collection installed. | ||
- Access details for the Cisco Manager instance must be provided. | ||
|
||
## Dependencies | ||
|
||
There are no external role dependencies. Only `cisco.catalystwan` collection is required. | ||
|
||
## Role Variables | ||
|
||
Variables expected by this role: | ||
|
||
- `vmanage_instances`: List of vManage instances containing management IP, admin username, admin password and system IP. | ||
- `min_version_required`: A string representing minimum version of vManage this role expects to succeed. | ||
|
||
## Example Playbook | ||
|
||
Including an example of how to use your role (with variables passed in as parameters): | ||
|
||
```yaml | ||
- hosts: all | ||
gather_facts: no | ||
tasks: | ||
- name: Check if vManage version is equal or greater to 20.13.1 | ||
import_role: | ||
name: vmanage_mode | ||
vars: | ||
vmanage_instances: | ||
- mgmt_public_ip: '192.0.2.1' | ||
admin_username: 'admin' | ||
admin_password: 'password' | ||
system_ip: '192.168.101.1' | ||
min_version_required: "20.13.1" | ||
``` | ||
## License | ||
"GPL-3.0-only" | ||
## Author Information | ||
This role was created by Przemyslaw Susko <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
|
||
galaxy_info: | ||
author: Przemyslaw Susko <[email protected]> | ||
description: Check if vManage version matches requirements. | ||
license: GPL-3.0-or-later | ||
min_ansible_version: "0.3.2" | ||
|
||
galaxy_tags: | ||
- cisco | ||
- sdwan | ||
- catalystwan | ||
- networking | ||
|
||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2024 Cisco Systems, Inc. and its affiliates | ||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
--- | ||
|
||
- name: Verify required variables for selected role | ||
ansible.builtin.include_tasks: variables_assertion.yml | ||
|
||
- name: Set facts | ||
ansible.builtin.set_fact: | ||
url: "{{ (vmanage_instances | first).mgmt_public_ip }}" | ||
username: "{{ (vmanage_instances | first).admin_username }}" | ||
password: "{{ (vmanage_instances | first).admin_password }}" | ||
system_ip: "{{ (vmanage_instances | first).system_ip }}" | ||
|
||
- name: Authenticate to vManage | ||
ansible.builtin.uri: | ||
url: "https://{{ url }}/j_security_check" | ||
method: POST | ||
body: "j_username={{ username }}&j_password={{ password }}" | ||
body_format: form-urlencoded | ||
validate_certs: false | ||
return_content: true | ||
register: login_response | ||
|
||
- name: Check if login was successful | ||
ansible.builtin.fail: | ||
msg: "vManage Login failed. Check your credentials." | ||
when: '"JSESSIONID" not in login_response.cookies' | ||
|
||
- name: Get vManage version | ||
ansible.builtin.uri: | ||
url: "https://{{ url }}/dataservice/device/system/info?deviceId={{ system_ip }}" | ||
method: GET | ||
validate_certs: false | ||
headers: | ||
Cookie: "JSESSIONID={{ login_response.cookies.JSESSIONID }}" | ||
return_content: true | ||
status_code: 200 | ||
register: version_response | ||
when: '"JSESSIONID" in login_response.cookies' | ||
|
||
- name: Set vManage version fact | ||
ansible.builtin.set_fact: | ||
vmanage_version: "{{ version_response.json.data[0].version }}" | ||
when: version_response is defined | ||
|
||
- name: Ensure vManage version is greater than or equal to specified version | ||
ansible.builtin.fail: | ||
msg: "vManage software version {{ vmanage_version }} is lower than the required version {{ min_version_required }}." | ||
when: vmanage_version is version(min_version_required, '<') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2024 Cisco Systems, Inc. and its affiliates | ||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
--- | ||
|
||
- name: Assert that required variables are provided | ||
ansible.builtin.assert: | ||
that: | ||
- required_var | ||
- required_var is defined | ||
- required_var != None | ||
- required_var != "None" | ||
- required_var != "" | ||
- required_var | length > 0 | ||
fail_msg: "Your SD-WAN initial config file missing required variable: {{ required_var }}" | ||
quiet: true | ||
loop: | ||
- "{{ vmanage_instances }}" | ||
- "{{ min_version_required }}" | ||
loop_control: | ||
loop_var: required_var |