Skip to content

Commit

Permalink
Merge pull request #289 from aristanetworks/devel
Browse files Browse the repository at this point in the history
  • Loading branch information
titom73 authored Dec 1, 2020
2 parents dcecb1c + 3eb5f37 commit 261d75c
Show file tree
Hide file tree
Showing 68 changed files with 4,798 additions and 862 deletions.
45 changes: 45 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"module: cv_configlet":
- ansible_collections/arista/cvp/plugins/modules/cv_configlet.py

"module: cv_container":
- ansible_collections/arista/cvp/plugins/modules/cv_container.py

"module: cv_device":
- ansible_collections/arista/cvp/plugins/modules/cv_device.py

"module: cv_facts":
- ansible_collections/arista/cvp/plugins/modules/cv_facts.py

"module: cv_task":
- ansible_collections/arista/cvp/plugins/modules/cv_task.py

"module_utils: cv_client":
- ansible_collections/arista/cvp/plugins/module_utils/*
- ansible_collections/arista/cvp/plugins/module_utils/**/*

"role: ztp_configuration":
- ansible_collections/arista/cvp/roles/dhcp_configuration/*
- ansible_collections/arista/cvp/roles/dhcp_configuration/**/*

"role: configlets_sync":
- ansible_collections/arista/cvp/roles/configlets_sync/*
- ansible_collections/arista/cvp/roles/configlets_sync/**/*

"type: documentation":
- README.md
- contributing.md
- ansible_collections/arista/cvp/README.md
- ansible_collections/arista/cvp/docs/*
- ansible_collections/arista/cvp/docs/**/*

"type: code quality":
- .github/labeler.yml
- .github/*
- .github/**/*
- development/docker-compose.yml
- development/Makefile

"type: dependencies":
- development/requirements-dev.txt
- development/requirements.txt
- ansible_collections/arista/cvp/docs/requirements.txt
12 changes: 8 additions & 4 deletions .github/workflows/ansible_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ jobs:
env:
PY_COLORS: 1 # allows molecule colors to be passed to GitHub Actions
ANSIBLE_FORCE_COLOR: 1 # allows ansible colors to be passed to GitHub Actions
strategy:
fail-fast: true
matrix:
python_version: [ 3.6 ]
steps:
- uses: actions/checkout@master
- name: Setup Python 3 on runner
uses: actions/setup-python@v1.2.0
- uses: actions/checkout@v2
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'
python-version: ${{ matrix.python_version }}

- name: update packages
run: apt-get update
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/documentation-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- 'devel'
paths:
- 'mkdocs.yml'
- '.github/workflows/documentation-build.yml'
- 'ansible_collections/arista/cvp/README.md'
- 'ansible_collections/arista/cvp/docs/**'
- 'ansible_collections/arista/cvp/roles/**/README.md'
Expand All @@ -13,9 +14,9 @@ jobs:
name: 'Update Public documentation'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2
- name: 'Setup Python 3 on runner'
uses: actions/setup-python@v1.2.0
uses: actions/setup-python@v2.1.4
with:
python-version: '3.x'
- name: 'Build mkdocs content to site folder'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: 'Validate mkdoc content'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2
- name: 'start docker-compose stack'
run: |
cp development/docker-compose.yml .
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
container: avdteam/base:3.6
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2
- name: test pre-commit
run: |
pip --no-cache-dir install -r development/requirements-dev.txt
Expand Down
56 changes: 42 additions & 14 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,56 @@ on:
push:
pull_request:
paths:
- 'ansible_collections/arista/cvp/roles/**'
- 'ansible_collections/arista/cvp/molecules/**'
- 'ansible_collections/arista/cvp/roles/**/*'
- 'ansible_collections/arista/cvp/plugins/**/*'
- 'ansible_collections/arista/cvp/molecules/**/*'
- 'requirements.txt'
- '.github/workflows/molecule.yml'
jobs:
molecule:
runs-on: ubuntu-latest
env:
PY_COLORS: 1 # allows molecule colors to be passed to GitHub Actions
ANSIBLE_FORCE_COLOR: 1 # allows ansible colors to be passed to GitHub Actions
strategy:
fail-fast: true
matrix:
python_version: [ 3.6 ]
avd_scenario:
- dhcp_configuration
- dhcp_management_mac
- dhcp_management_offline
- dhcp_system_mac
- cv_configlet
- cv_device
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: 'set environment variables'
run: |
echo "PY_COLORS=1" >> $GITHUB_ENV
echo "ANSIBLE_FORCE_COLOR=1" >> $GITHUB_ENV
- name: Run molecule action
uses: inetsix/molecule-collection-actions@master
- uses: actions/checkout@v2

- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python_version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r development/requirements.txt
pip install -r development/requirements-dev.txt
- name: Execute molecule
run: |
cd ansible_collections/arista/cvp
molecule test --destroy=never --scenario-name ${{ matrix.avd_scenario }}
ls -alR molecule
- name: Test molecule results
run: |
pwd
cd ansible_collections/arista/cvp/
ls -alR
- uses: actions/upload-artifact@v1
with:
molecule_parentdir: 'ansible_collections/arista/cvp'
molecule_command: 'test'
molecule_args: '-s ${{ matrix.avd_scenario }}'
pip_file: 'requirements.txt'
name: molecule-results-${{ matrix.avd_scenario }}
path: ansible_collections/arista/cvp/molecule/${{ matrix.avd_scenario }}
23 changes: 23 additions & 0 deletions .github/workflows/pr_conflict.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "PR Conflicts checker"
on:
# So that PRs touching the same files as the push are updated
push:
# So that the `dirtyLabel` is removed if conflicts are resolve
# We recommend `pull_request_target` so that github secrets are available.
# In `pull_request` we wouldn't be able to change labels of fork PRs
pull_request_target:
types: [synchronize]

jobs:
Conflict_Check:
name: 'Check PR status: conflicts and resolution'
runs-on: ubuntu-latest
steps:
- name: check if PRs are dirty
uses: eps1lon/actions-label-merge-conflict@releases/2.x
with:
dirtyLabel: "state: conflict"
removeOnDirtyLabel: "state: conflict resolved"
repoToken: "${{ secrets.GITHUB_TOKEN }}"
commentOnDirty: "This pull request has conflicts, please resolve those before we can evaluate the pull request."
commentOnClean: "Conflicts have been resolved. A maintainer will review the pull request shortly."
15 changes: 15 additions & 0 deletions .github/workflows/pr_labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Pull Request Labeler"
on:
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review, locked]

jobs:
triage:
name: "PR Triage"
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: '.github/labeler.yml'
sync-labels: true
2 changes: 1 addition & 1 deletion .github/workflows/version_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
container: avdteam/base:centos-8
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2

- name: 'Ansible Galaxy build'
run: |
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ This collection requires the following to be installed on the Ansible control ma
- ansible >= `2.9.0`
- [cvprac](https://github.com/aristanetworks/cvprac) version `1.0.4`
- requests >= `2.22.0`
- treelib version `1.5.5`
- treelib `1.5.5`
- jsonschema `3.2.0`

### Installation from ansible-galaxy

Expand Down
5 changes: 4 additions & 1 deletion ansible_collections/arista/cvp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ __Python:__

__Additional Python Libraries required:__

- python `3.6` and higher
- ansible >= `2.9.0`
- [cvprac](https://github.com/aristanetworks/cvprac) version `1.0.4`
- requests >= `2.22.0`
- treelib version `1.5.5` or later
- treelib `1.5.5`
- jsonschema `3.2.0`

__Supported Ansible Versions:__ ansible 2.9 or later

Expand Down
38 changes: 38 additions & 0 deletions ansible_collections/arista/cvp/docs/faq/errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Common Error messages

> All Ansible error messages should be read from bottom to top.
## cv_facts error messages

### Unsupported CV version

Prior version __2.0.0__ `arista.cvp` collection ran test to determine Cloudvision version. If version is not supported, following error should happen:

```shell
\"/var/folders/q0/92fg6g7s1bv6kgfdcgfjwt0c0000gp/T/ansible_arista.cvp.cv_facts_payload_2ld7vf9v/ansible_arista.cvp.\
cv_facts_payload.zip/ansible_collections/arista/cvp/plugins/modules/cv_facts.py\", line 359, in facts_builder\n\
AttributeError: 'NoneType' object has no attribute 'get_cvp_info'\n", "module_stdout": "", "msg": "MODULE \
FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
```
## cv_container
### Missing Treelib requirement
[Treelib](https://treelib.readthedocs.io/en/latest/) is a python library used to build container topology. When missing, Ansible raise following error message
```shell
\"/tmp/ansible_arista.cvp.cv_container_payload_YG2p15/ansible_arista.cvp.cv_container_payload.zip/ansible_collections\
/arista/cvp/plugins/modules/cv_container.py\", line 254, in tree_build_from_dict\n\
NameError: global name 'Tree' is not defined\n",
```

With newer version of the collection, module should fails with an specific message like below:

```shell
TASK [running cv_container in merge on cv_server] *****************************
Wednesday 07 October 2020 08:21:50 +0200 (0:00:20.050) 0:00:20.114 *****
Wednesday 07 October 2020 08:21:50 +0200 (0:00:20.050) 0:00:20.114 *****
fatal: [cv_server]: FAILED! => changed=false
msg: treelib required for this module
```
4 changes: 2 additions & 2 deletions ansible_collections/arista/cvp/docs/how-to/cv_device.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ CVP_DEVICES:
- name: "Configure devices on {{inventory_hostname}}"
arista.cvp.cv_device:
devices: "{{CVP_DEVICES}}"
cvp_facts: '{{CVP_FACTS.ansible_facts}}
device_filter: ['TEAM]
cvp_facts: '{{CVP_FACTS.ansible_facts}}'
device_filter: ['TEAM']
state: present
register: CVP_DEVICES_RESULTS
```
Expand Down
Loading

0 comments on commit 261d75c

Please sign in to comment.