From 48e9a3115a8e4fa39d7b05d6d931c0d0b36dce64 Mon Sep 17 00:00:00 2001 From: Fanch Date: Tue, 13 Oct 2020 20:36:50 +0200 Subject: [PATCH 1/5] add default file from "molecule init scenario -r matrix-coturn" --- roles/matrix-coturn/.yamllint | 33 +++++++++++++++++++ .../molecule/default/INSTALL.rst | 22 +++++++++++++ .../molecule/default/converge.yml | 7 ++++ .../molecule/default/molecule.yml | 13 ++++++++ .../matrix-coturn/molecule/default/verify.yml | 9 +++++ 5 files changed, 84 insertions(+) create mode 100644 roles/matrix-coturn/.yamllint create mode 100644 roles/matrix-coturn/molecule/default/INSTALL.rst create mode 100644 roles/matrix-coturn/molecule/default/converge.yml create mode 100644 roles/matrix-coturn/molecule/default/molecule.yml create mode 100644 roles/matrix-coturn/molecule/default/verify.yml diff --git a/roles/matrix-coturn/.yamllint b/roles/matrix-coturn/.yamllint new file mode 100644 index 000000000..882767605 --- /dev/null +++ b/roles/matrix-coturn/.yamllint @@ -0,0 +1,33 @@ +--- +# Based on ansible-lint config +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + colons: + max-spaces-after: -1 + level: error + commas: + max-spaces-after: -1 + level: error + comments: disable + comments-indentation: disable + document-start: disable + empty-lines: + max: 3 + level: error + hyphens: + level: error + indentation: disable + key-duplicates: enable + line-length: disable + new-line-at-end-of-file: disable + new-lines: + type: unix + trailing-spaces: disable + truthy: disable diff --git a/roles/matrix-coturn/molecule/default/INSTALL.rst b/roles/matrix-coturn/molecule/default/INSTALL.rst new file mode 100644 index 000000000..d926ca252 --- /dev/null +++ b/roles/matrix-coturn/molecule/default/INSTALL.rst @@ -0,0 +1,22 @@ +******* +Docker driver installation guide +******* + +Requirements +============ + +* Docker Engine + +Install +======= + +Please refer to the `Virtual environment`_ documentation for installation best +practices. If not using a virtual environment, please consider passing the +widely recommended `'--user' flag`_ when invoking ``pip``. + +.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ +.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site + +.. code-block:: bash + + $ python3 -m pip install 'molecule[docker]' diff --git a/roles/matrix-coturn/molecule/default/converge.yml b/roles/matrix-coturn/molecule/default/converge.yml new file mode 100644 index 000000000..c076fd99c --- /dev/null +++ b/roles/matrix-coturn/molecule/default/converge.yml @@ -0,0 +1,7 @@ +--- +- name: Converge + hosts: all + tasks: + - name: "Include matrix-coturn" + include_role: + name: "matrix-coturn" diff --git a/roles/matrix-coturn/molecule/default/molecule.yml b/roles/matrix-coturn/molecule/default/molecule.yml new file mode 100644 index 000000000..b5710a8e5 --- /dev/null +++ b/roles/matrix-coturn/molecule/default/molecule.yml @@ -0,0 +1,13 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: instance + image: docker.io/pycontribs/centos:8 + pre_build_image: true +provisioner: + name: ansible +verifier: + name: ansible diff --git a/roles/matrix-coturn/molecule/default/verify.yml b/roles/matrix-coturn/molecule/default/verify.yml new file mode 100644 index 000000000..a82dd6fd0 --- /dev/null +++ b/roles/matrix-coturn/molecule/default/verify.yml @@ -0,0 +1,9 @@ +--- +# This is an example playbook to execute Ansible tests. + +- name: Verify + hosts: all + tasks: + - name: Example assertion + assert: + that: true From a1dcf5e79fc084d4744c97b8ac09609ddf4cc247 Mon Sep 17 00:00:00 2001 From: Fanch Date: Tue, 13 Oct 2020 20:48:10 +0200 Subject: [PATCH 2/5] add missing variable for test --- roles/matrix-coturn/molecule/default/converge.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/roles/matrix-coturn/molecule/default/converge.yml b/roles/matrix-coturn/molecule/default/converge.yml index c076fd99c..4501ba22c 100644 --- a/roles/matrix-coturn/molecule/default/converge.yml +++ b/roles/matrix-coturn/molecule/default/converge.yml @@ -1,6 +1,14 @@ --- - name: Converge hosts: all + vars: + matrix_systemd_services_list: [] # empty init as we only test coturn + run_setup: true + matrix_base_data_path: "/matrix" + # maybe those should be added in role default/main.yml + matrix_coturn_enabled: true + matrix_coturn_turn_external_ip_address: 127.0.0.1 + matrix_coturn_turn_static_auth_secret: "VeryFakeSecret" tasks: - name: "Include matrix-coturn" include_role: From f56db3c2a7158eb83618c17237d8437d573922e7 Mon Sep 17 00:00:00 2001 From: Fanch Date: Wed, 14 Oct 2020 00:53:07 +0200 Subject: [PATCH 3/5] add missing variable per role --- .../molecule/default/converge.yml | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/roles/matrix-coturn/molecule/default/converge.yml b/roles/matrix-coturn/molecule/default/converge.yml index 4501ba22c..a9e41c90f 100644 --- a/roles/matrix-coturn/molecule/default/converge.yml +++ b/roles/matrix-coturn/molecule/default/converge.yml @@ -1,15 +1,29 @@ --- - name: Converge hosts: all - vars: - matrix_systemd_services_list: [] # empty init as we only test coturn - run_setup: true - matrix_base_data_path: "/matrix" - # maybe those should be added in role default/main.yml - matrix_coturn_enabled: true - matrix_coturn_turn_external_ip_address: 127.0.0.1 - matrix_coturn_turn_static_auth_secret: "VeryFakeSecret" tasks: + - name: "Include matrix-base" + include_role: + name: "matrix-base" + vars: + matrix_domain: "example.org" + matrix_vars_yml_snapshotting_enabled: false + run_self_check: false - name: "Include matrix-coturn" include_role: name: "matrix-coturn" + vars: + matrix_systemd_services_list: [] + run_setup: true + matrix_base_data_path: "/matrix" + matrix_user_username: "root" + matrix_user_groupname: "root" + matrix_server_fqn_matrix: "example.org" + matrix_systemd_path: "/etc/systemd/system" + matrix_host_command_docker: "/usr/bin/env docker" + # matrix_user_uid: 0 + # matrix_user_gid: 0 + # maybe those should be added in role default/main.yml + matrix_coturn_enabled: true + matrix_coturn_turn_external_ip_address: 127.0.0.1 + matrix_coturn_turn_static_auth_secret: "VeryFakeSecret" From c9d5f0e378de541905c2699187386dcdc7dd20bd Mon Sep 17 00:00:00 2001 From: Fanch Date: Wed, 14 Oct 2020 00:53:44 +0200 Subject: [PATCH 4/5] try to make docker in docker work --- .../molecule/default/molecule.yml | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/roles/matrix-coturn/molecule/default/molecule.yml b/roles/matrix-coturn/molecule/default/molecule.yml index b5710a8e5..22df460f2 100644 --- a/roles/matrix-coturn/molecule/default/molecule.yml +++ b/roles/matrix-coturn/molecule/default/molecule.yml @@ -4,10 +4,24 @@ dependency: driver: name: docker platforms: - - name: instance - image: docker.io/pycontribs/centos:8 - pre_build_image: true + - name: coturn-test + image: fanchthesystem/ubuntu18-with-systemd:latest #fanchthesystem/centos7-with-systemd:latest # docker.io/pycontribs/centos:7 + override_command: false + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro +# - /var/run/docker.sock:/var/run/docker.sock +# network: +# - name: dind-network +# env: +# DOCKER_HOST: "tcp://dind:2375" +# https://blog.alekc.org/testing-ansible-roles-with-molecule-using-dind/ +# https://github.com/ansible/ansible/issues/71528 provisioner: name: ansible + log: true + config_options: + defaults: + timeout: 60 verifier: name: ansible From 4dee25d0e64ab9f40002318c69154308f85b26f0 Mon Sep 17 00:00:00 2001 From: Fanch Date: Wed, 14 Oct 2020 00:57:10 +0200 Subject: [PATCH 5/5] add travis ci file --- .travis.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..e40bfb0c8 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +--- +language: python +services: docker + +install: + - pip install molecule docker + +script: + - cd roles/matrix-coturn && molecule test