Skip to content

Commit

Permalink
add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
soer3n committed Oct 25, 2021
1 parent f06e0fe commit b3e723d
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 27 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
name: CI
on:
pull_request:
push:
branches:
- master
# schedule:
# - cron: "0 5 * * 0"

defaults:
run:
working-directory: 't_systems_mms.cniplugins'

jobs:

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 't_systems_mms.cniplugins'

- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install yamllint

- name: Lint code.
run: |
yamllint .
molecule:
name: Molecule
runs-on: ubuntu-latest
strategy:
matrix:
distro:
- centos8
- centos7
- ubuntu2004
- debian10

steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 't_systems_mms.cniplugins'

- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install ansible molecule[docker] docker

- name: Run Molecule tests.
run: molecule test
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DISTRO: ${{ matrix.distro }}
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ All variables are also listed in default values.

## Dependencies

None.
```
ansible-galaxy collection install ansible.posix
```

## License

Expand Down
29 changes: 7 additions & 22 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
---
scenario:
scenario:
name: default

dependency:
enabled: true
name: galaxy
driver:
name: docker

platforms:
- name: docker-ubuntu
image: ubuntu:bionic

image: geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest
privileged: true
provisioner:
name: ansible
lint: |
yamllint .
ansible-lint
flake8

lint: |
yamllint .
ansible-lint
flake8
verifier:
name: testinfra
env:
# get rid of the DeprecationWarning messages of third-party libs,
# see https://docs.pytest.org/en/latest/warnings.html#deprecationwarning-and-pendingdeprecationwarning
PYTHONWARNINGS: "ignore:.*U.*mode is deprecated:DeprecationWarning"
lint: |
yamllint .
ansible-lint
flake8
options:
# show which tests where executed in test output
v: 1
4 changes: 4 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
collections:
- name: ansible.posix
roles: []
7 changes: 4 additions & 3 deletions tasks/linux/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
- name: ensure target directory exists
file:
path: "{{ cni_plugin_dir }}"
path: "/opt/cni/bin"
state: directory
mode: 0755

- name: donwload plugin
get_url:
Expand All @@ -13,11 +12,12 @@

- name: extract file
unarchive:
remote_src: true
src: "{{ cni_plugin_dir }}/cni-plugins-linux-amd64-{{ cni_plugin_release_version }}.tgz"
dest: "{{ cni_plugin_dir }}"

- name: enable container routing through iptables
sysctl:
ansible.posix.sysctl:
name: "{{ item }}"
state: present
value: 1
Expand All @@ -27,6 +27,7 @@
- net.bridge.bridge-nf-call-arptables
- net.bridge.bridge-nf-call-ip6tables
become: true
ignore_errors: true # https://github.com/geerlingguy/docker-debian10-ansible/issues/2

- name: remove downloaded compressed file
file:
Expand Down
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
- name: install consul connect cni plugin
- name: install on linux distribution cni plugin
include_tasks: linux/main.yml

0 comments on commit b3e723d

Please sign in to comment.