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

Fr: Feature & Device templates #17

Merged
merged 20 commits into from
Jul 25, 2024
Merged
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: 6 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,22 @@ mock_modules:
- cisco.catalystwan.active_sessions_info
- cisco.catalystwan.administration_settings
- cisco.catalystwan.alarms
- cisco.catalystwan.cli_templates
- cisco.catalystwan.device_templates
- cisco.catalystwan.devices_certificates
- cisco.catalystwan.devices_controllers
- cisco.catalystwan.devices_info
- cisco.catalystwan.devices_wan_edges
- cisco.catalystwan.device_templates_recovery
- cisco.catalystwan.feature_templates
- cisco.catalystwan.feature_templates_info
- cisco.catalystwan.health_checks
- cisco.catalystwan.server_info
- cisco.catalystwan.software_repository
- cisco.catalystwan.software_repository_info
- cisco.catalystwan.software_upgrade
- cisco.catalystwan.software_upgrade_info
- cisco.catalystwan.device_templates_info
- cisco.catalystwan.users
- cisco.catalystwan.vmanage_mode
- cisco.catalystwan.wait_for_api_server
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
poetry.lock
.vscode*
.venv*
run*
.dev_dir/playground.yml
.dev_dir/dev_vars.yml
.dev_dir/ansible_catalystwan_module.log
Expand All @@ -16,3 +17,7 @@ playbooks/tests/configuration_file_dev_vars.yml
playbooks/tests/ansible_catalystwan.log
playbooks/tests/ansible_catalystwan_module.log
playbooks/tests/catalystwan.log
playbooks/tests/payload*
playbooks/tests/response*
playbooks/tests/backup
playbooks/tests/templates
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Ansible Collection - cisco.catalystwan

Initial repository for Ansible Collection using catalystwan library.
## Overview

Reusable Ansible modules and roles that will help to automate Cisco
SD-WAN management (post bringup operations, day0, day1).

All modules are based on [catalystwan](https://github.com/CiscoDevNet/catalystwan).

***NOTE: this repository is still in pre-release dev version**
Collection available on Ansible Galaxy: [cisco.catalystwan](https://galaxy.ansible.com/ui/repo/published/cisco/catalystwan/)

## Table of Contents

- [Overview](#overview)
- [Roadmap](#roadmap)
- [Requirements](#requirements)
- [Installing this collection](#installing-this-collection)
Expand All @@ -17,18 +21,6 @@ Initial repository for Ansible Collection using catalystwan library.

---

## Overview

Reusable Ansible modules and roles that will help to automate Cisco
SD-WAN management (post bringup operations, day0, day1).

All modules are based on [catalystwan](https://github.com/CiscoDevNet/catalystwan). Current installation available
via local Ansible Galaxy collection.

Once finished, repository will be migrated to Cisco Open, and modules will be available via Ansible Galaxy.

---

## Roadmap

Support for the following workflows in vManage client and as Ansible modules:
Expand Down Expand Up @@ -73,7 +65,7 @@ Currently development of the tool was set with:

- Python = 3.10.0
- Ansible = 2.16.6
- catalystwan = "^0.33.3"
- catalystwan = "^0.33.6post0"

## Installing this collection

Expand Down Expand Up @@ -168,6 +160,14 @@ These playbooks offer initial config, onboarding and health checks.
If you want to run example playbook, supply your variables in `.dev_dir/dev_vars.yml`
and execute playbooks from `.dev_dir/` directory.

### Feature Templates

Feature Templates operations (`add` and `delete`) are supported via `cisco.catalystwan.feature_templates` module.

Available models are dependent on Catalystwan SDK, and they can be seen [here](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/api/templates/models/supported.py).

For more information about adding new models see [Feature Templates generation](./plugins/README.md#feature-templates).

---

## Useful links and Getting Started
Expand Down
8 changes: 8 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,11 @@ Preferred way to setup environment for development:

You can also refer to [Ansible modules dev guide](https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html#verifying-your-module-code) to look for more convenient way of
testing your code.

### Dependencies in requirements.txt

Dependencies defined for development are later used to generate `requirements.txt` file with command:

```bash
poetry export --without-hashes --format=requirements.txt > requirements.txt
```
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace: cisco
name: catalystwan
version: 0.1.1
version: 0.2.0
readme: README.md
authors:
- Arkadiusz Cichon <[email protected]>
Expand Down
76 changes: 76 additions & 0 deletions playbooks/tests/test_backup_and_restore_running_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# 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)

---

# Helper playbooks to test modules and flows while developing them

# Tested operations:

# --- Backup & Restore --- #

# 1. Backup running-config for all c8000V devices with default backup dir
# 2. Using backup files, create CLI templates for each Edge device
# 3. Attach backup templates to the Edge devices
# 4. Post-test - Set vManage mode for cEdge devices - in order to use previous templates


- name: Testing playbook to verify backup & restore operations
hosts: localhost
gather_facts: false
vars_files:
- configuration_file_dev_vars.yml
vars:
manager_authentication: &manager_authentication
url: "{{ (vmanage_instances | first).mgmt_public_ip }}"
username: "{{ (vmanage_instances | first).admin_username }}"
password: "{{ (vmanage_instances | first).admin_password }}"
tasks:
- name: 1. Backup running-config for all c8000V devices with default backup dir (in CWD)
cisco.catalystwan.devices_info:
backup: true
filters:
personality: "vedge"
manager_credentials:
<<: *manager_authentication
register: backup_info

- name: 2. Using backup files, create CLI templates for each Edge device
cisco.catalystwan.cli_templates:
state: present
template_name: "backup-template-{{ device_item.filename }}"
template_description: "Template for {{ device_item.hostname }} created from backup file."
config_file: "{{ device_item.backup_path }}"
device_model: vedge-C8000V
manager_credentials:
<<: *manager_authentication
loop: "{{ backup_info.backup_paths }}"
loop_control:
loop_var: device_item
when: backup_info.backup_paths | length > 0

- name: 3. Attach backup templates to the Edge devices
cisco.catalystwan.device_templates:
state: attached
template_name: "backup-template-{{ device_item.filename }}"
hostname: "{{ device_item.hostname }}"
manager_credentials:
<<: *manager_authentication
loop: "{{ backup_info.backup_paths }}"
loop_control:
loop_var: device_item
when: backup_info.backup_paths | length > 0

- name: 4. Post-test - Set vManage mode for cEdge devices - in order to use previous templates
cisco.catalystwan.vmanage_mode:
state: present
hostnames:
- "{{ device_item.hostname }}"
manager_credentials:
<<: *manager_authentication
loop: "{{ backup_info.backup_paths }}"
loop_control:
loop_var: device_item
when: backup_info.backup_paths | length > 0

# Add task to remove all unused templates (not attached)
50 changes: 50 additions & 0 deletions playbooks/tests/test_device_templates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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)

---

# Helper playbooks to test modules and flows while developing them

# --- Device Templates --- #


- name: Testing playbook to verify cisco.catalystwan.device_templates module operations
hosts: localhost
gather_facts: false
vars_files:
- configuration_file_dev_vars.yml
vars:
manager_authentication: &manager_authentication
url: "{{ (vmanage_instances | first).mgmt_public_ip }}"
username: "{{ (vmanage_instances | first).admin_username }}"
password: "{{ (vmanage_instances | first).admin_password }}"
tasks:
- name: 1. Get all Non-Default Device Templates available
cisco.catalystwan.device_templates_info:
filters:
factory_default: false
manager_credentials:
<<: *manager_authentication
register: device_templates

- name: 2. Delete selected Device Template from vManage
cisco.catalystwan.device_templates:
state: absent
template_name: "vc8000-device-template"
manager_credentials:
<<: *manager_authentication

- name: 3. Create example Device Template with default templates
cisco.catalystwan.device_templates:
state: present
template_name: "vc8000-device-template"
template_description: "vc8000-device-template"
device_type: vedge-C8000V
device_role: sdwan-edge
general_templates:
- name: "Factory_Default_Cisco_BFD_Template"
subtemplates: "Factory_Default_Cisco_Logging_Template"
- name: "Factory_Default_Cisco_OMP_ipv46_Template"
- name: "Factory_Default_Cisco_Security_Template"
manager_credentials:
<<: *manager_authentication
41 changes: 41 additions & 0 deletions playbooks/tests/test_device_templates_info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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)

---

# Helper playbooks to test modules and flows while developing them

# --- Device Templates Info --- #


- name: Testing playbook to verify cisco.catalystwan.device_templates_info module operations
hosts: localhost
gather_facts: false
vars_files:
- configuration_file_dev_vars.yml
vars:
manager_authentication: &manager_authentication
url: "{{ (vmanage_instances | first).mgmt_public_ip }}"
username: "{{ (vmanage_instances | first).admin_username }}"
password: "{{ (vmanage_instances | first).admin_password }}"
tasks:
- name: 1. Get all Non-Default Device Templates available
cisco.catalystwan.device_templates_info:
filters:
factory_default: false
manager_credentials:
<<: *manager_authentication
register: device_templates

- name: 2. Debug Templates Info
ansible.builtin.debug:
msg: "{{ device_templates }}"

- name: 3. Backup all Non-Default Device Templates available
cisco.catalystwan.device_templates_info:
filters:
factory_default: false
backup: true
manager_credentials:
<<: *manager_authentication
register: device_templates
Loading
Loading