From b3e723d7f3ce7a8d707cda52e14cfcdef0246c63 Mon Sep 17 00:00:00 2001 From: soer3n Date: Mon, 25 Oct 2021 16:24:56 +0200 Subject: [PATCH] add ci --- .github/workflows/ci.yaml | 68 +++++++++++++++++++++++++++++++++++ README.md | 6 +++- molecule/default/molecule.yml | 29 ++++----------- requirements.yml | 4 +++ tasks/linux/main.yml | 7 ++-- tasks/main.yml | 2 +- 6 files changed, 89 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 requirements.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..ef87be1 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -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 }} diff --git a/README.md b/README.md index 5afe833..ed20a70 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,11 @@ All variables are also listed in default values. ## Dependencies -None. +``` + +ansible-galaxy collection install ansible.posix + +``` ## License diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index dd87d2b..c9c029b 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -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 diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..ad0afd8 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,4 @@ +--- +collections: + - name: ansible.posix +roles: [] diff --git a/tasks/linux/main.yml b/tasks/linux/main.yml index a5c8984..b26b4be 100644 --- a/tasks/linux/main.yml +++ b/tasks/linux/main.yml @@ -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: @@ -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 @@ -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: diff --git a/tasks/main.yml b/tasks/main.yml index 6176696..6f7dcf2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,3 +1,3 @@ --- -- name: install consul connect cni plugin +- name: install on linux distribution cni plugin include_tasks: linux/main.yml