Skip to content

Commit

Permalink
Fixes and enhancements to build, test and NetBox onboarding (#19)
Browse files Browse the repository at this point in the history
* Updated local build/test logic

* Fixed documentation typos

* Fixes and enhancements to NetBox onboarding
  • Loading branch information
jasonking3 authored Feb 9, 2023
1 parent 74cdac8 commit e2b4dad
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 205 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ ansible_collections/
.cache/
collections/
envvars
*.gz
111 changes: 0 additions & 111 deletions .pylintrc

This file was deleted.

29 changes: 26 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Makefile
PYTHON_EXE = python3
COLLECTION_NAME="ciscops.mdd"
COLLECTION_VERSION := $(shell awk '/^version:/{print $$NF}' galaxy.yml)
TARBALL_NAME=ciscops-mdd-${COLLECTION_VERSION}.tar.gz
PYDIRS="plugins"
VENV = venv
VENV_BIN=$(VENV)/bin

help: ## Display help
@awk -F ':|##' \
Expand All @@ -12,6 +15,12 @@ help: ## Display help

all: test build publish ## Setup python-viptela env and run tests

$(VENV): $(VENV_BIN)/activate ## Build virtual environment

$(VENV_BIN)/activate:
test -d $(VENV) || $(PYTHON_EXE) -m venv $(VENV)
. $(VENV_BIN)/activate

$(TARBALL_NAME): galaxy.yml
@ansible-galaxy collection build

Expand All @@ -23,10 +32,24 @@ publish: $(TARBALL_NAME) ## Publish Collection (set env:GALAXY_TOKEN)
format: ## Format Python code
yapf --style=yapf.ini -i -r *.py $(PYDIRS)

test: ## Run Sanity Tests
ansible-test sanity --docker default -v
test: $(VENV) $(TARBALL_NAME) ## Run Sanity Tests
$(RM) -r ./ansible_collections
ansible-galaxy collection install --force $(TARBALL_NAME) -p ./ansible_collections
cd ./ansible_collections/ciscops/mdd && git init .
$(VENV_BIN)/pip uninstall -y ansible-base
$(VENV_BIN)/pip install https://github.com/ansible/ansible/archive/stable-2.10.tar.gz --disable-pip-version-check
cd ./ansible_collections/ciscops/mdd && ../../../$(VENV_BIN)/ansible-test sanity --docker -v --color
$(VENV_BIN)/pip uninstall -y ansible-base
$(VENV_BIN)/pip install https://github.com/ansible/ansible/archive/stable-2.11.tar.gz --disable-pip-version-check
cd ./ansible_collections/ciscops/mdd && ../../../$(VENV_BIN)/ansible-test sanity --docker -v --color
$(VENV_BIN)/pip uninstall -y ansible-base
$(VENV_BIN)/pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
cd ./ansible_collections/ciscops/mdd && ../../../$(VENV_BIN)/ansible-test sanity --docker -v --color
$(RM) -r ./ansible_collections

clean: ## Clean
$(RM) $(TARBALL_NAME)
$(RM) -r ./ansible_collections
$(RM) -r ./venv

.PHONY: all clean test build publish
.PHONY: all clean build test publish
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ Example:
ansible-playbook nso_init
```

### `ciscops.mdd.nso_update_device`
### `ciscops.mdd.nso_update_devices`

- Update NSO devices from inventory source

Example:
```
ansible-playbook nso_update_netbox
ansible-playbook nso_update_devices
```
12 changes: 11 additions & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,14 @@ issues: https://github.com/model-driven-devops/ansible-mdd/issue/tracker
# artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This
# uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry',
# and '.git' are always filtered
build_ignore: []
build_ignore:
- '*tar.gz'
- '*.DS_Store'
- '*.json'
- 'venv*'
- '.vscode'
- '.gitignore'
- '.env'
- '.github'
- 'tests/output/'
- 'ansible_collections/'
8 changes: 6 additions & 2 deletions playbooks/cml_update_netbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
- ciscops.mdd.netbox
tasks:
- cisco.cml.cml_lab_facts:
tags:
- network
host: "{{ cml_host }}"
user: "{{ cml_username }}"
password: "{{ cml_password }}"
lab: "{{ cml_lab }}"
# tags:
# - network
register: cml_lab_results

- include_role:
Expand Down
Loading

0 comments on commit e2b4dad

Please sign in to comment.