generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e22433b
commit 5ccf047
Showing
8 changed files
with
229 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
--- | ||
name: execution environment | ||
on: | ||
# Run CI against all pushes (direct commits, also merged PRs), Pull Requests | ||
push: | ||
branches: | ||
- main | ||
- stable-* | ||
pull_request: | ||
# Run CI once per day (at 05:15 UTC) | ||
# This ensures that even if there haven't been commits that we are still testing against latest version of ansible-builder | ||
schedule: | ||
- cron: '15 5 * * *' | ||
|
||
env: | ||
NAMESPACE: community | ||
COLLECTION_NAME: routeros | ||
|
||
jobs: | ||
build: | ||
name: Build and test EE (Ⓐ${{ matrix.runner_tag }}) | ||
strategy: | ||
matrix: | ||
runner_tag: | ||
- devel | ||
- stable-2.12-latest | ||
- stable-2.11-latest | ||
- stable-2.9-latest | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
with: | ||
path: ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }} | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install ansible-builder and ansible-navigator | ||
run: pip install ansible-builder ansible-navigator | ||
|
||
- name: Verify requirements | ||
run: ansible-builder introspect --sanitize . | ||
|
||
- name: Make sure galaxy.yml has version entry | ||
run: >- | ||
python -c | ||
'import yaml ; | ||
f = open("galaxy.yml", "rb") ; | ||
data = yaml.safe_load(f) ; | ||
f.close() ; | ||
data["version"] = data.get("version") or "0.0.1" ; | ||
f = open("galaxy.yml", "wb") ; | ||
f.write(yaml.dump(data).encode("utf-8")) ; | ||
f.close() ; | ||
' | ||
working-directory: ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }} | ||
|
||
- name: Install collection dependencies | ||
run: git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.netcommon.git ansible_collections/ansible/netcommon | ||
# NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429) | ||
# run: ansible-galaxy collection install ansible.netcommon -p . | ||
|
||
- name: Build collection | ||
run: | | ||
ansible-galaxy collection build --output-path ../../../ | ||
working-directory: ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }} | ||
|
||
- name: Create files for building execution environment | ||
run: | | ||
COLLECTION_FILENAME="$(ls "${{ env.NAMESPACE }}-${{ env.COLLECTION_NAME }}"-*.tar.gz)" | ||
# EE config | ||
cat > execution-environment.yml <<EOF | ||
--- | ||
version: 1 | ||
build_arg_defaults: | ||
EE_BASE_IMAGE: 'quay.io/ansible/ansible-runner:${{ matrix.runner_tag }}' | ||
dependencies: | ||
galaxy: requirements.yml | ||
EOF | ||
echo "::group::execution-environment.yml" | ||
cat execution-environment.yml | ||
echo "::endgroup::" | ||
# Requirements | ||
cat > requirements.yml <<EOF | ||
--- | ||
collections: | ||
- name: ${COLLECTION_FILENAME} | ||
type: file | ||
EOF | ||
echo "::group::requirements.yml" | ||
cat requirements.yml | ||
echo "::endgroup::" | ||
- name: Build image based on ${{ matrix.runner_tag }} | ||
run: | | ||
mkdir -p context/_build/ | ||
cp "${{ env.NAMESPACE }}-${{ env.COLLECTION_NAME }}"-*.tar.gz context/_build/ | ||
ansible-builder build -v 3 -t test-ee:latest --container-runtime=podman | ||
- name: Run basic tests | ||
run: > | ||
ansible-navigator run | ||
--mode stdout | ||
--pull-policy never | ||
--set-environment-variable ANSIBLE_PRIVATE_ROLE_VARS=true | ||
--execution-environment-image test-ee:latest | ||
all.yml | ||
working-directory: ansible_collections/${{ env.NAMESPACE }}/${{ env.COLLECTION_NAME }}/tests/ee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- "Prepare collection for inclusion in an Execution Environment by declaring its dependencies (https://github.com/ansible-collections/community.routeros/pull/83)." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
librouteros |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
version: 1 | ||
dependencies: | ||
python: meta/ee-requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
- hosts: localhost | ||
tasks: | ||
- name: Find all roles | ||
find: | ||
paths: | ||
- "{{ playbook_dir ~ '/roles/' }}" | ||
file_type: directory | ||
depth: 1 | ||
register: result | ||
- name: Include all roles | ||
include_role: | ||
name: "{{ item }}" | ||
loop: "{{ result.files | map(attribute='path') | map('regex_replace', '.*/', '') | sort }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
shippable/posix/group1 | ||
skip/python2.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
- name: "Test split filter" | ||
assert: | ||
that: | ||
- "'' | community.routeros.split == []" | ||
- "'foo bar' | community.routeros.split == ['foo', 'bar']" | ||
- > | ||
'foo bar="a b c"' | community.routeros.split == ['foo', 'bar=a b c'] | ||
- name: "Test split filter error handling" | ||
set_fact: | ||
test: >- | ||
{{ 'a="' | community.routeros.split }} | ||
ignore_errors: true | ||
register: result | ||
|
||
- name: "Verify split filter error handling" | ||
assert: | ||
that: | ||
- >- | ||
result.msg == "Unexpected end of string during escaped parameter" | ||
- name: "Test quote_argument filter" | ||
assert: | ||
that: | ||
- > | ||
'a=' | community.routeros.quote_argument == 'a=""' | ||
- > | ||
'a=b' | community.routeros.quote_argument == 'a=b' | ||
- > | ||
'a=b c' | community.routeros.quote_argument == 'a="b c"' | ||
- > | ||
'a=""' | community.routeros.quote_argument == 'a="\\"\\""' | ||
- name: "Test quote_argument_value filter" | ||
assert: | ||
that: | ||
- > | ||
'' | community.routeros.quote_argument_value == '""' | ||
- > | ||
'foo' | community.routeros.quote_argument_value == 'foo' | ||
- > | ||
'"foo bar"' | community.routeros.quote_argument_value == '"\\"foo bar\\""' | ||
- name: "Test join filter" | ||
assert: | ||
that: | ||
- > | ||
['a=', 'b=c d'] | community.routeros.join == 'a="" b="c d"' | ||
- name: "Test list_to_dict filter" | ||
assert: | ||
that: | ||
- > | ||
['a=', 'b=c'] | community.routeros.list_to_dict == {'a': '', 'b': 'c'} | ||
- > | ||
['a=', 'b=c'] | community.routeros.list_to_dict(skip_empty_values=True) == {'b': 'c'} | ||
- > | ||
['a', 'b=c'] | community.routeros.list_to_dict(require_assignment=False) == {'a': none, 'b': 'c'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
- name: Run api module | ||
community.routeros.api: | ||
username: foo | ||
password: bar | ||
hostname: localhost | ||
path: ip address | ||
ignore_errors: true | ||
register: result | ||
|
||
- name: Validate result | ||
assert: | ||
that: | ||
- result is failed | ||
- "'error: [Errno 111] Connection refused' in result.msg" | ||
|
||
- name: Run command module | ||
community.routeros.command: | ||
commands: | ||
- /ip address print | ||
vars: | ||
ansible_host: localhost | ||
ansible_connection: ansible.netcommon.network_cli | ||
ansible_network_os: community.routeros.routeros | ||
ansible_user: foo | ||
ansible_ssh_pass: bar | ||
ansible_ssh_port: 12349 | ||
ignore_errors: true | ||
register: result | ||
|
||
- name: Validate result | ||
assert: | ||
that: | ||
- result is failed | ||
- "'Unable to connect to port 12349 ' in result.msg" |