Skip to content

Commit

Permalink
Release v1.0.1 (#32)
Browse files Browse the repository at this point in the history
* added uv project

* added CoC and communication sections

* added changelog

* added contrubuting.md

* update clab and srl version; add local collection deps install

* bump to v1

* change network->networking tag

* bump met runtime req to 2.15

* format golden config yaml file

* fqdn for debug task

* fqcn set_fact

* fix set_fact

* ignore venv

* patch ver added

* jinja spacing

* use named debugs

* truthy values alignment

* more linting

* bump to 1.0.1
  • Loading branch information
hellt authored Jan 11, 2025
1 parent 9c9670f commit d6a39df
Show file tree
Hide file tree
Showing 38 changed files with 1,642 additions and 1,258 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,6 @@ poetry.toml
# ruff
.ruff_cache/

# End of https://www.toptal.com/developers/gitignore/api/ansible,python
# End of https://www.toptal.com/developers/gitignore/api/ansible,python

.envrc
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changelog

* [Changelog](#changelog)
* [v1.0.0](#v100)
* [New modules](#new-modules)

## v1.0.0

### New modules

* nokia.srlinux.get - Retrieve configuration or state element from Nokia SR Linux devices.
* nokia.srlinux.config - Update, replace and delete configuration on SR Linux devices.
* nokia.srlinux.validate - Validating configuration on SR Linux devices.
* nokia.srlinux.cli - Execute CLI commands on SR Linux devices.
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contributing

Refer to the [Ansible community guide](https://docs.ansible.com/ansible/devel/community/index.html).
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,40 @@ Then either run one of the provided test playbooks (defined in [run.sh](run.sh))
```bash
./run.sh test-set-leaves
```

## Contributing to this collection

The content of this collection is made by people like you, a community of individuals collaborating on making the world better through developing automation software.

We are actively accepting new contributors and all types of contributions are very welcome.

Don't know how to start? Refer to the [Ansible community guide](https://docs.ansible.com/ansible/devel/community/index.html)!

Want to submit code changes? Take a look at the [Quick-start development guide](https://docs.ansible.com/ansible/devel/community/create_pr_quick_start.html).

We also use the following guidelines:

* [Collection review checklist](https://docs.ansible.com/ansible/devel/community/collection_contributors/collection_reviewing.html)
* [Ansible development guide](https://docs.ansible.com/ansible/devel/dev_guide/index.html)
* [Ansible collection development guide](https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html#contributing-to-collections)

## Code of Conduct

We follow the [Ansible Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html) in all our interactions within this project.

If you encounter abusive behavior, please refer to the [policy violations](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html#policy-violations) section of the Code for information on how to raise a complaint.

## Communication

Join the Ansible forum:

* [Get Help](https://forum.ansible.com/c/help/6): get help or help others. Please add appropriate tags if you start new discussions.
* [Posts tagged with 'srlinux'](https://forum.ansible.com/tag/srlinux): subscribe to participate in SR Linux Ansible collection/technology-related conversations.
* [Social Spaces](https://forum.ansible.com/c/chat/4): gather and interact with fellow enthusiasts.
* [News & Announcements](https://forum.ansible.com/c/news/5): track project-wide announcements including social events. The [Bullhorn newsletter](https://docs.ansible.com/ansible/devel/community/communication.html#the-bullhorn), which is used to announce releases and important changes, can also be found here.

## Licensing

BSD 3-Clause License

See [LICENSE](LICENSE) to see the full text.
5 changes: 3 additions & 2 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace: nokia
name: srlinux

# The version of the collection. Must be compatible with semantic versioning
version: 0.6.0
version: 1.0.1

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand All @@ -39,7 +39,7 @@ tags:
- srlinux
- jsonrpc
- httpapi
- network
- networking

# Collections that this collection requires to be installed for it to be usable. The key of the dict is the
# collection label 'namespace.name'. The value is a version range
Expand Down Expand Up @@ -68,3 +68,4 @@ build_ignore:
- run.sh
- .github
- .vscode
- .venv
2 changes: 1 addition & 1 deletion meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
requires_ansible: ">=2.11"
requires_ansible: ">=2.15.0"
plugin_routing:
modules:
srl_config:
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[project]
name = "srlinux-ansible-collection"
version = "0.6.0"
description = "SR Linux Ansible Collection"
readme = "README.md"
requires-python = ">=3.11"
dependencies = ["ansible-core==2.16.2"]
20 changes: 18 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SCRIPTS_DIR="scripts"
TESTS_DIR="$(pwd)/tests"

# Containerlab version to use in CI tests
CLAB_VERSION="0.57.5"
CLAB_VERSION="0.61.0"

CHECKPOINT_NAME="clab-initial"

Expand All @@ -32,7 +32,7 @@ function _cdTests() {
fi
}

# transoforms ansible core version by swapping : with /
# transforms ansible core version by swapping : with /
function _transformAnsibleCoreVersion() {
echo "${1}" | sed 's/:/\//g'
}
Expand Down Expand Up @@ -69,6 +69,19 @@ function deploy-lab {
sudo -E containerlab deploy -c
}

# Parse dependencies from galaxy.yml and install each one in the local venv
function install-collection-deps {
python3 -c '
import yaml
with open("galaxy.yml") as f:
deps = yaml.safe_load(f).get("dependencies", {})
for name, version in deps.items():
print(f"'{name}:{version}'")
' | while read dep; do
ansible-galaxy collection install $dep
done
}

# Prepare local dev environment by setting the symlink to the collection.
function prepare-dev-env {
# setup the symlink for ansible to resolve collection paths
Expand All @@ -78,6 +91,9 @@ function prepare-dev-env {

# setup .env file for python to resolve imports
echo "PYTHONPATH=$(realpath ~)/.ansible/collections:/tmp/srl_ansible_dev" > .env

# install collection dependencies
install-collection-deps
}

# revert to initial checkpoint to guarantee the node initial state
Expand Down
2 changes: 1 addition & 1 deletion scripts/topo.clab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ topology:
nodes:
srl:
kind: nokia_srlinux
image: ghcr.io/nokia/srlinux:${SRLINUX_VERSION:=24.7.2}
image: ghcr.io/nokia/srlinux:${SRLINUX_VERSION:=24.10.1}
3 changes: 2 additions & 1 deletion tests/playbooks/auth-fail.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
register: get_return
failed_when: not get_return.failed or "AuthenticationFailed" not in get_return.msg

- debug:
- name: Print debug
ansible.builtin.debug:
var: get_return
18 changes: 9 additions & 9 deletions tests/playbooks/backup-cfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
tasks:
- name: Delete old config files
ansible.builtin.file:
path: "{{item}}"
path: "{{ item }}"
state: absent
with_fileglob:
- "/tmp/{{inventory_hostname}}.cfg.*"
- "/tmp/{{ inventory_hostname }}.cfg.*"

- name: Get entire running config
nokia.srlinux.get:
Expand All @@ -22,16 +22,16 @@

- name: Save fetched config in JSON
ansible.builtin.copy:
content: "{{response.result[0] | to_nice_json}}"
dest: "/tmp/{{inventory_hostname}}.cfg.json"
content: "{{ response.result[0] | to_nice_json }}"
dest: "/tmp/{{ inventory_hostname }}.cfg.json"

- name: Save fetched config in YAML
ansible.builtin.copy:
content: "{{response.result[0] | to_nice_yaml}}"
dest: "/tmp/{{inventory_hostname}}.cfg.yml"
content: "{{ response.result[0] | to_nice_yaml }}"
dest: "/tmp/{{ inventory_hostname }}.cfg.yml"

- name: check if saved file contains "srl_nokia"
- name: Check if saved file contains "srl_nokia"
ansible.builtin.shell:
cmd: "grep srl_nokia {{item}}"
cmd: "grep srl_nokia {{ item }}"
with_fileglob:
- "/tmp/{{inventory_hostname}}.cfg.*"
- "/tmp/{{ inventory_hostname }}.cfg.*"
6 changes: 3 additions & 3 deletions tests/playbooks/cli-put-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
ansible_connection: ssh
ansible_password:
tasks:
- name: template config
- name: Template config
ansible.builtin.template:
src: "{{playbook_dir}}/golden/{{inventory_hostname}}-golden.cfg.json.j2"
src: "{{ playbook_dir }}/golden/{{ inventory_hostname }}-golden.cfg.json.j2"
dest: /tmp/config.json
# - name: Run "show version" CLI command with text output format
# hosts: clab
Expand All @@ -26,5 +26,5 @@
# register: response
# failed_when: '"Serial Number : Sim Serial No" not in response.result[0]'

# - debug:
# - ansible.builtin.debug:
# var: response
6 changes: 4 additions & 2 deletions tests/playbooks/cli-show-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
register: response
failed_when: response.result[0]["basic system info"].Architecture != "x86_64"

- debug:
- name: Print debug
ansible.builtin.debug:
var: response

- name: Run "show version" CLI command with text output format
Expand All @@ -28,5 +29,6 @@
register: response
failed_when: '"Serial Number : Sim Serial No" not in response.result[0]'

- debug:
- name: Print debug
ansible.builtin.debug:
var: response
3 changes: 2 additions & 1 deletion tests/playbooks/cli-wrong-cmd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
register: response
failed_when: '("Parsing error: Unknown token" not in response.msg) or (response.failed is not true)'

- debug:
- name: Print debug
ansible.builtin.debug:
var: response
6 changes: 4 additions & 2 deletions tests/playbooks/delete-leaves.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
- path: /system/information/contact
register: delete_response

- debug:
- name: Print debug
ansible.builtin.debug:
var: delete_response

- name: Ensure leaves were deleted
Expand All @@ -33,5 +34,6 @@
register: get_response
failed_when: get_response.result[0].location is defined or get_response.result[0].contact is defined

- debug:
- name: Print debug
ansible.builtin.debug:
var: get_response
3 changes: 2 additions & 1 deletion tests/playbooks/get-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
register: response
failed_when: '"SRLinux" not in response.result[0].description'

- debug:
- name: Print debug
ansible.builtin.debug:
var: response
3 changes: 2 additions & 1 deletion tests/playbooks/get-multiple-paths.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
register: response
failed_when: '("SRLinux" not in response.result[0]) or ("mgmt" not in response.result[1]["network-instance"][0].name)'

- debug:
- name: Print debug
ansible.builtin.debug:
var: response
3 changes: 2 additions & 1 deletion tests/playbooks/get-oc-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
register: response
failed_when: '("SRLinux" not in response.result[1].description) or ("srl" not in response.result[0])'

- debug:
- name: Print debug
ansible.builtin.debug:
var: response
3 changes: 2 additions & 1 deletion tests/playbooks/get-wrong-path.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
register: response
failed_when: (not response.failed) or ("Path not valid" not in response.msg)

- debug:
- name: Print debug
ansible.builtin.debug:
var: response
4 changes: 2 additions & 2 deletions tests/playbooks/golden/clab-ansible-srl-golden.cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -1587,12 +1587,12 @@
"srl_nokia-interfaces:interface": [
{
"admin-state": "enable",
"description": "ethernet-1/1 interface on {{inventory_hostname}}",
"description": "ethernet-1/1 interface on {{ inventory_hostname }}",
"name": "ethernet-1/1"
},
{
"admin-state": "enable",
"description": "{{inventory_hostname}} management interface",
"description": "{{ inventory_hostname }} management interface",
"name": "mgmt0",
"subinterface": [
{
Expand Down
Loading

0 comments on commit d6a39df

Please sign in to comment.