Skip to content

Commit

Permalink
Merge pull request cisco-en-programmability#3 from ajithandrewj/user_…
Browse files Browse the repository at this point in the history
…and_role_workflow_feature

User and role workflow feature
  • Loading branch information
ajithandrewj authored Jul 31, 2024
2 parents b123090 + 9975c9c commit af886fd
Show file tree
Hide file tree
Showing 75 changed files with 17,899 additions and 2,101 deletions.
325 changes: 325 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
version: 2.1

setup: << pipeline.parameters.run-setup >>

orbs:
path-filtering: circleci/[email protected]

parameters:
run-setup:
type: boolean
default: true
run-any:
type: boolean
default: false
run-all:
type: boolean
default: false
run-site:
type: boolean
default: false
run-devicecredential:
type: boolean
default: false
run-discovery:
type: boolean
default: false
run-inventory:
type: boolean
default: false
run-swim:
type: boolean
default: false
run-pnp:
type: boolean
default: false

jobs:

pre:
parameters:
ansible_cisco_dnac_version:
type: string
default: "6.9.0"

#machine: true
docker:
- image: python:3.8.10
resource_class: madhansansel/dnacenter-ansible

steps:
- run:
name: Debug information for pre
command: |
set -x
echo "REPO_URL: $REPO_URL"
echo "CIRCLE_PROJECT_REPONAME: $CIRCLE_PROJECT_REPONAME"
echo "CIRCLE_PROJECT_BRANCHNAME: $CIRCLE_PROJECT_BRANCHNAME"
build:
parameters:
ansible_cisco_dnac_version:
type: string
default: "6.9.0"

#machine: true
docker:
- image: python:3.8.10
resource_class: madhansansel/dnacenter-ansible
steps:
- run:
name: Debug information
command: |
echo "REPO_URL: $REPO_URL"
echo "CIRCLE_PROJECT_REPONAME: $CIRCLE_PROJECT_REPONAME"
echo "CIRCLE_PROJECT_BRANCHNAME: $CIRCLE_PROJECT_BRANCHNAME"
- restore_cache:
keys:
- collection-<< pipeline.git.revision >>
- run:
name: Skip if already build
command: |
if [ $(ls workspace/*tar.gz) ]; then
ls -alh workspace
circleci-agent step halt
fi
- run:
name: Clone repo to workspace
command: |
git clone --depth=1 https://github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git .
git fetch origin $CIRCLE_BRANCH:work
git checkout work
- restore_cache:
keys:
- pip-cache-{{ checksum "test-requirements.txt" }}
- run:
name: Activate Virtual Environment, Install ansible and Build collection tarball
command: |
# Install ansible, dnacentersdk
pip install --upgrade pip
pip install -r test-requirements.txt
# Build collection and store resulting tarball in directory $HOME/.cache/v<< parameters.ansible_cisco_dnac_version >>/collection-tarballs
ansible-galaxy collection build --force --output-path workspace/
- save_cache:
key: collection-<< pipeline.git.revision >>
paths:
- 'workspace'
- save_cache:
key: pip-cache-{{ checksum "test-requirements.txt" }}
paths:
- ~/.cache/pip

addrole:
#machine: true
docker:
- image: python:3.8.10
resource_class: madhansansel/dnacenter-ansible

steps:
- run:
name: Create Roles File header
command: |
mkdir -p roles-file
echo "---" > roles-file/ccc_roles.yml
echo "- hosts: dnac_servers" >> roles-file/ccc_roles.yml
echo " gather_facts: no" >> roles-file/ccc_roles.yml
echo " connection: local" >> roles-file/ccc_roles.yml
echo " " >> roles-file/ccc_roles.yml
echo " tasks:" >> roles-file/ccc_roles.yml
echo " " >> roles-file/ccc_roles.yml
echo " vars:" >> roles-file/ccc_roles.yml
echo " debug: false" >> roles-file/ccc_roles.yml
echo " " >> roles-file/ccc_roles.yml
echo " roles:" >> roles-file/ccc_roles.yml
- when:
condition:
or: [ << pipeline.parameters.run-site >>, << pipeline.parameters.run-all >> ]
steps:
- run:
command: |
echo " - ccc_site_management" >> roles-file/ccc_roles.yml
- when:
condition:
or: [ << pipeline.parameters.run-devicecredential >>, << pipeline.parameters.run-all >> ]
steps:
- run:
command: |
echo " - ccc_device_credential_management" >> roles-file/ccc_roles.yml
- when:
condition:
or: [ << pipeline.parameters.run-discovery >>, << pipeline.parameters.run-all >> ]
steps:
- run:
command: |
echo " - ccc_discovery_management" >> roles-file/ccc_roles.yml
- when:
condition:
or: [ << pipeline.parameters.run-inventory >>, << pipeline.parameters.run-all >> ]
steps:
- run:
command: |
echo " - ccc_inventory_management" >> roles-file/ccc_roles.yml
- when:
condition:
or: [ << pipeline.parameters.run-swim >>, << pipeline.parameters.run-all >> ]
steps:
- run:
command: |
echo " - ccc_swim_management" >> roles-file/ccc_roles.yml
- when:
condition:
or: [ << pipeline.parameters.run-pnp >>, << pipeline.parameters.run-all >> ]
steps:
- run:
command: |
echo " - ccc_pnp_management" >> roles-file/ccc_roles.yml
- persist_to_workspace:
root: 'roles-file'
paths:
- 'ccc_roles.yml'
sanity-tests:
parameters:
ansible_cisco_dnac_version:
type: string
default: "6.9.0"

#machine: true
docker:
- image: python:3.8.10
resource_class: madhansansel/dnacenter-ansible

steps:
- run:
name: Debug information
command: |
echo "REPO_URL: $REPO_URL"
echo "CIRCLE_PROJECT_REPONAME: $CIRCLE_PROJECT_REPONAME"
echo "CIRCLE_PROJECT_BRANCHNAME: $CIRCLE_PROJECT_BRANCHNAME"
- run:
name: Clone repo to workspace
command: |
git clone --depth=1 https://github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git .
git fetch origin $CIRCLE_BRANCH:work
git checkout work
- attach_workspace:
at: roles-file

- restore_cache:
keys:
- collection-<< pipeline.git.revision >>
- restore_cache:
keys:
- pip-cache-{{ checksum "test-requirements.txt" }}
- run:
name: Activate Virtual Environment, Install ansible and Build collection tarball
command: |
# Install ansible, dnacentersdk
pip install --upgrade pip
pip install -r test-requirements.txt
ansible --version
- run:
name: Install the collection tarball
command: |
python --version
ansible --version
ansible-galaxy collection install --force workspace/*.tar.gz
- run:
name: Copy static files
command: |
mkdir -p group_vars
cp roles-file/ccc_roles.yml ccc_roles.yml
echo ${GROUP_VARS} | base64 -d > group_vars/dnac_servers.yml
echo ${DNAC_HOSTS} | base64 -d > hosts
- run:
name: Run sanity tests
command: |
export ANSIBLE_PERSISTENT_CONNECT_TIMEOUT=1000
export ANSIBLE_PERSISTENT_COMMAND_TIMEOUT=1000
export ANSIBLE_ROLES_PATH=$PWD/tests/integration
ansible-playbook -i hosts ccc_roles.yml
no_output_timeout: 120m

post_pnp_testing:
#machine: true
docker:
- image: python:3.8.10
resource_class: madhansansel/dnacenter-ansible

steps:
- when:
condition: << pipeline.parameters.run-pnp >>
steps:
- run:
command: |
python ${HOME}/static/pnp_script.py #TODO
workflows:

building:
when: << pipeline.parameters.run-setup >>
jobs:
- pre

- build:
matrix:
parameters:
ansible_cisco_dnac_version:
- "6.9.0"
requires:
- pre

- path-filtering/filter:
requires:
- build
base-revision: main
config-path: .circleci/config.yml
mapping: |
.* run-setup false
plugins/.* run-any true
tests/integration/.* run-any true
plugins/module_utils/.* run-all true
plugins/modules/site_workflow_manager.py run-site true
plugins/modules/device_credential_workflow_manager.py run-devicecredential true
plugins/modules/discovery_workflow_manager.py run-discovery true
plugins/modules/inventory_workflow_manager.py run-inventory true
plugins/modules/swim_workflow_manager.py run-swim true
plugins/modules/pnp_workflow_manager.py run-pnp true
tests/integration/ccc_site_management/.* run-site true
tests/integration/ccc_device_credential_management/.* run-devicecredential true
tests/integration/ccc_discovery_management/.* run-discovery true
tests/integration/ccc_inventory_management/.* run-inventory true
tests/integration/ccc_swim_management/.* run-swim true
tests/integration/ccc_pnp_management/.* run-pnp true
testing:
when: << pipeline.parameters.run-any >>
jobs:
- addrole
- sanity-tests:
requires:
- addrole
context:
- dnac-servers
matrix:
parameters:
ansible_cisco_dnac_version:
- "6.9.0"
# - post_pnp_testing:
# requires:
# - sanity-tests

21 changes: 21 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -932,3 +932,24 @@ releases:
- provision_workflow_manager.py - Added attribute 'provisioning'
- template_workflow_manager.py - Added attributes 'choices', 'failure_policy'
- events_and_notifications_workflow_manager.py - Added attributes 'webhook_event_notification', 'email_event_notification', 'syslog_event_notification'
6.17.0:
release_date: "2024-07-30"
changes:
release_summary: Code changes in workflow manager modules.
minor_changes:
- Added Circle CI support for integration testing.
- Adding pyzipper support in device_configs workflow manager module.
- Exporting export_device_details_limit in inventory workflow module.
- Adding run_compliance_batch_size support in network_compliance module.
- Changes in provision workflow manager module.
- Checking the device list in swim workflow manager module.
- UT and IT cases for worflow manager modules.
- discovery_intent.py: Changed attribute name 'desc' to 'description'.
- discovery_workflow_manager.py: Changed attribute name 'desc' to 'description'.
- events_and_notifications_worflow_manager.py: Changed attribute names from 'from_email', 'to_email', 'to send_email' and 'recipient_email'.
- inventory_intent.py: added attribute 'export_device_details_limit'.
- inventory_workflow_manager.py: added attribute 'export_device_details_limit'.
- ise_radius_integration_workflow_manager.py: changed the type of 'authentication_policy_server' from 'dict' to 'list'.
- network_compliance_workflow_manager.py: added attribute 'run_compliance_batch_size'.
- network_settings_workflow_manager.py: changed the type of network_management_details from 'dic' to 'list'.
- template_workflow_manager.py: added project_file and payload.
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: cisco
name: dnac
version: 6.16.0
version: 6.17.0
readme: README.md
authors:
- Rafael Campos <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions playbooks/device_details.template
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ template_details:
template_name: 'DMVPN Spoke for Branch Router - System Default'
import_project:
do_version: false
project_file: 'JSON project file'
payload:
- name: 'Onboarding Configuration2'
import_template:
Expand Down
4 changes: 2 additions & 2 deletions playbooks/events_and_notifications_workflow_manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
method: "{{item.webhook_destination.method}}"
trust_cert: "{{item.webhook_destination.trust_cert}}"
email_destination:
from_email: "{{item.email_destination.from_email}}"
to_email: "{{item.email_destination.to_email}}"
sender_email: "{{item.email_destination.sender_email}}"
recipient_email: "{{item.email_destination.recipient_email}}"
subject: "{{item.email_destination.subject}}"
primary_smtp_config:
server_address: "{{item.email_destination.primary_smtp_config.server_address}}"
Expand Down
Loading

0 comments on commit af886fd

Please sign in to comment.