Skip to content
Draft
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
53 changes: 44 additions & 9 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
image: mtarking/nac-vxlan:24.0.1
image: danischm/nac:0.1.5
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is old PR and need to test and work on the pipeline again, I was performing a few tests and was facing issue with the ansible version download as per requirement.txt. It was working for the nac:0.1.5 image. Please let me know of I can close this and work on a new PR.

stages:
- setup
- validate
- deploy
- test
Expand All @@ -23,42 +24,76 @@ variables:
NDFC_SW_PASSWORD:
description: "Cisco NDFC Switch Password"

cache:
paths:
- .pip_cache/

setup:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a one time action where you're using this for each stage or does each stage need a before_script:?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check this again, I remember adding this as subsequent stages were showing error with missing packages.

stage: setup
rules:
- if: $CI_COMMIT_TAG == null
script:
- echo "Setting up environment..."
- pip install --cache-dir .pip_cache -r requirements.txt --force-reinstall
- ansible-galaxy collection install -U -f -p ./collections/ansible_collections/ -r requirements.yaml
artifacts:
paths:
- collections/ansible_collections/

validate:
stage: validate
dependencies:
- setup
needs:
- setup
rules:
- if: $CI_COMMIT_TAG == null
script:
- set -o pipefail && ansible-playbook -i inventory.yml ndfc_validate.yml |& tee validate_output.txt
- set -o pipefail && ansible-playbook -i inventory.yaml ndfc_validate.yaml |& tee nac_fabric1_validate_output.txt
artifacts:
paths:
- validate_output.txt
- nac_fabric1_validate_output.txt
- collections/ansible_collections/
cache: []

deploy:
stage: deploy
dependencies:
- setup
- validate
needs:
- setup
- validate
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: manual
script:
- set -o pipefail && ansible-playbook -i inventory.yml vxlan.yml |& tee deploy_output.txt
- pip install --cache-dir .pip_cache -r requirements.txt
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe before_script:?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, need to work on this pieline PR again.

- set -o pipefail && ansible-playbook -i inventory.yaml vxlan.yaml |& tee nac_fabric1_deploy_output.txt
artifacts:
when: always
paths:
- nac_fabric1_deploy_output.txt
cache: []

test-integration:
stage: test
dependencies:
- setup
- deploy
needs:
- setup
- deploy
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- set -o pipefail && iac-test -d ./host_vars/nac-ndfc1 -d ./group_vars/ndfc/defaults.yaml -t ./tests/templates -f ./tests/filters -o ./tests/results/ndfc |& tee test_output.txt
- pip uninstall -y nac-test || true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why uninstall?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the Docker image had nac-test included and it was getting called when we run iac-test, which was causing issues with the robot tests as those are not supported yet for nac-test, so I had to remove this.

- pip install --cache-dir .pip_cache -r requirements.txt
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before_script:?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above, need to work on this again.

- set -o pipefail && iac-test -d ./host_vars/nac-fabric1 -d ./group_vars/ndfc/defaults.yaml -t ./tests/templates -o ./tests/results/nac-fabric1 |& tee test_output.txt
artifacts:
when: always
paths:
- tests/results/ndfc/*.html
- tests/results/ndfc/xunit.xml
- tests/results/nac-fabric1/*.html
- tests/results/nac-fabric1/xunit.xml
- test_output.txt
reports:
junit: tests/results/ndfc/xunit.xml
junit: tests/results/nac-fabric1/xunit.xml