Skip to content

Commit e8749c1

Browse files
authored
Merge pull request #3 from elan-ev/update-tests
Update tests and formatting
2 parents 4b0c7a1 + bc5104e commit e8749c1

15 files changed

+141
-63
lines changed

.ansible-lint

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
3+
# .ansible-lint
4+
exclude_paths:
5+
- .cache/ # implicit unless exclude_paths is defined in config
6+
- .github/
7+
- venv/

.dev_requirements.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ansible
2+
ansible-lint
3+
yamllint
4+
molecule
5+
molecule-docker
6+
molecule-podman
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
---
22

3-
name: ansible tests
3+
name: molecule
44

55
on: # yamllint disable-line rule:truthy
66
- push
77
- pull_request
88

99
jobs:
10-
lint:
10+
molecule:
1111
runs-on: ubuntu-latest
1212

1313
steps:
1414
- uses: actions/checkout@v2
1515

1616
- name: install dependencies
17-
run: >
18-
pip3 install
19-
ansible
20-
ansible-lint
21-
yamllint
22-
molecule
23-
molecule-docker
24-
molecule-podman
17+
run: pip3 install -r .dev_requirements.txt
2518

2619
- name: test playbook
2720
run: molecule test --driver-name docker
21+
env:
22+
PY_COLORS: '1'

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
venv/

.yamllint

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
3+
extends: default
4+
5+
rules:
6+
line-length: disable
7+
8+
ignore: |
9+
venv/
10+
.roles/
11+
.cache/

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Ansible: Opencast Repository Role
22
=================================
33

4+
![molecule](https://github.com/elan-ev/opencast_repository/actions/workflows/molecule.yml/badge.svg)
5+
46
This Ansible role enables the package repository for RHEL, CentOS, Debian or Ubuntu.
57

68

@@ -36,3 +38,35 @@ Example of how to configure and use the role:
3638
- role: elan.opencast_repository
3739
opencast_version_major: 9
3840
```
41+
42+
Development
43+
-----------
44+
45+
For development and testing you can use [molecule](https://molecule.readthedocs.io/en/latest/).
46+
With podman as driver you can install it like this – preferably in a virtual environment (if you use docker, substitute `podman` with `docker`):
47+
48+
```bash
49+
pip install -r .dev_requirements.txt
50+
```
51+
52+
Then you can *create* the test instances, apply the ansible config (*converge*) and *destroy* the test instances with these commands:
53+
54+
```bash
55+
molecule create
56+
molecule converge
57+
molecule destroy
58+
```
59+
60+
If you want to inspect a running test instance use `molecule login --host <instance_name>`, where you replace `<instance_name>` with the desired value.
61+
62+
To test the role run `molecule test`.
63+
64+
License
65+
-------
66+
67+
[BSD-3-Clause](LICENSE)
68+
69+
Author Information
70+
------------------
71+
72+
[ELAN e.V](https://elan-ev.de/)

handlers/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
2-
- name: update apt cache
2+
- name: Update apt cache
33
ansible.builtin.apt:
44
update_cache: true

meta/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
32
galaxy_info:
43
author: Lars Kiesow
54
role_name: opencast_repository
@@ -15,6 +14,7 @@ galaxy_info:
1514
versions:
1615
- "7"
1716
- "8"
17+
- "9"
1818
- name: Debian
1919
versions:
2020
- all

molecule/default/Dockerfile.j2

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM {{ item.image }}
2+
3+
# Install dependencies
4+
{% if "centos" in item.name %}
5+
RUN dnf install --refresh -y sudo systemd bash ca-certificates iproute python3 python3-libselinux
6+
{% else %}
7+
RUN apt-get update && apt-get install -y sudo bash ca-certificates iproute2 init python3 && apt-get clean
8+
{% endif %}

molecule/default/converge.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
- name: Converge
33
hosts: all
44
vars:
5-
opencast_version_major: 10
5+
opencast_version_major: 12
66
opencast_repository_enabled_release: true
77
opencast_repository_enabled_testing: true
88
tasks:
9-
- name: include opencast_repository
9+
- name: Include opencast_repository
1010
ansible.builtin.include_role:
1111
name: opencast_repository

molecule/default/molecule.yml

+30-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,40 @@ dependency:
44
driver:
55
name: podman
66
platforms:
7-
- name: opencast-repository-centos-8
8-
image: quay.io/centos/centos:stream8
9-
pre_build_image: true
10-
- name: opencast-repository-centos-7
7+
- name: oc_repository_centos_7
118
image: docker.io/library/centos:7
129
pre_build_image: true
13-
- name: opencast-repository-debian
10+
- name: oc_repository_centos_8
11+
image: quay.io/centos/centos:stream8
12+
pre_build_image: false
13+
command: /sbin/init
14+
tmpfs:
15+
- /run
16+
- /tmp
17+
volumes:
18+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
19+
- name: oc_repository_centos_9
20+
image: quay.io/centos/centos:stream9
21+
pre_build_image: false
22+
command: /sbin/init
23+
tmpfs:
24+
- /run
25+
- /tmp
26+
volumes:
27+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
28+
- name: oc_repository_debian
1429
image: docker.io/library/python:bullseye
1530
pre_build_image: true
31+
- name: oc_repository_ubuntu
32+
image: docker.io/ubuntu:latest
33+
pre_build_image: false
34+
privileged: true
35+
command: /sbin/init
36+
tmpfs:
37+
- /run
38+
- /tmp
39+
volumes:
40+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
1641
lint: |
1742
set -e
1843
yamllint .

molecule/default/verify.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
---
2-
# This is an example playbook to execute Ansible tests.
3-
42
- name: Verify
53
hosts: all
64
gather_facts: true
75
vars:
8-
opencast_version_major: 10
6+
opencast_version_major: 12
97
tasks:
10-
- name: test if opencast is available
8+
- name: Test if opencast is available
119
ansible.builtin.package:
12-
# yamllint disable-line rule:line-length
13-
name: "{{ 'opencast-' + opencast_version_major|string + '-common' if ansible_os_family == 'Debian' else 'opencast' }}"
10+
name: "{{ 'opencast-' + opencast_version_major | string + '-common' if ansible_os_family == 'Debian' else 'opencast' }}"
1411
state: present

tasks/debian.yml

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
11
---
2-
3-
- name: install dependencies
2+
- name: Install dependencies
43
ansible.builtin.apt:
54
name:
65
- ca-certificates
76
- gnupg2
8-
state: present
97
cache_valid_time: 3600
108

11-
- name: install the opencast package repository key
9+
- name: Install the opencast package repository key
1210
ansible.builtin.apt_key:
1311
url: https://pkg.opencast.org/gpgkeys/opencast-deb.key
1412
state: present
1513

16-
- name: remove orphan opencast package repository definition
14+
- name: Remove orphan opencast package repository definition
15+
notify: Update apt cache
1716
ansible.builtin.apt_repository:
1817
repo: >-
1918
deb https://pkg.opencast.org/debian
2019
{{ opencast_version_major }}.x
2120
stable testing
2221
filename: opencast
2322
state: absent
24-
notify: update apt cache
2523

26-
- name: install the opencast package repository
24+
- name: Install the opencast package repository
25+
notify: Update apt cache
2726
ansible.builtin.apt_repository:
2827
repo: >-
29-
deb https://pkg.opencast.org/debian
30-
{{ opencast_version_major }}.x
31-
stable
28+
deb https://pkg.opencast.org/debian
29+
{{ opencast_version_major }}.x
30+
stable
3231
filename: opencast
3332
# yamllint disable-line rule:line-length
3433
state: "{{ 'present' if opencast_repository_enabled_release | bool else 'absent' }}"
35-
notify: update apt cache
3634

37-
- name: install the opencast testing package repository
35+
- name: Install the opencast testing package repository
36+
notify: Update apt cache
3837
ansible.builtin.apt_repository:
3938
repo: >-
4039
deb https://pkg.opencast.org/debian
@@ -43,4 +42,3 @@
4342
filename: opencast
4443
# yamllint disable-line rule:line-length
4544
state: "{{ 'present' if opencast_repository_enabled_testing | bool else 'absent' }}"
46-
notify: update apt cache

tasks/main.yml

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
---
2-
3-
- name: check that the architecture is supported
2+
- name: Check that the architecture is supported
43
ansible.builtin.assert:
5-
that: ansible_architecture == 'x86_64'
4+
that: ansible_architecture == "x86_64"
65

7-
- name: install on debian/ubuntu
6+
- name: Install on debian/ubuntu
87
ansible.builtin.include_tasks: debian.yml
9-
when: ansible_os_family == 'Debian'
8+
when: ansible_os_family == "Debian"
109

11-
- name: install on centos
10+
- name: Install on centos
1211
ansible.builtin.include_tasks: rhel.yml
13-
when: ansible_os_family == 'RedHat'
12+
when: ansible_os_family == "RedHat"

tasks/rhel.yml

+15-18
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
---
2-
3-
# yamllint disable rule:line-length
4-
- name: install opencast repository
2+
- name: Install opencast repository
53
ansible.builtin.yum_repository:
64
file: opencast
7-
name: opencast-{{ item }}
8-
description: Opencast RHEL $releasever Repository - {{ item }}
9-
baseurl: https://pkg.opencast.org/rpms/release/el/$releasever/oc-{{ repository_version }}/{{ item }}
10-
enabled: '{{ opencast_repository_enabled_release }}'
5+
name: "opencast-{{ item }}"
6+
description: "Opencast RHEL $releasever Repository - {{ item }}"
7+
baseurl: "https://pkg.opencast.org/rpms/release/el/$releasever/oc-{{ repository_version }}/{{ item }}"
8+
enabled: "{{ opencast_repository_enabled_release }}"
119
gpgcheck: true
12-
gpgkey: https://pkg.opencast.org/gpgkeys/opencast-{{ repository_version }}-rpm.key
10+
gpgkey: "https://pkg.opencast.org/gpgkeys/opencast-{{ repository_version }}-rpm.key"
1311
vars:
14-
repository_version: '{{ "%02d" % (opencast_version_major|int) }}'
12+
repository_version: '{{ "%02d" % (opencast_version_major | int) }}'
1513
loop:
1614
- x86_64
1715
- noarch
1816

19-
- name: install opencast testing repository
17+
- name: Install opencast testing repository
2018
ansible.builtin.yum_repository:
2119
file: opencast-testing
22-
name: opencast-testing-{{ item }}
23-
description: Opencast RHEL $releasever Testing Repository - {{ item }}
24-
baseurl: https://pkg.opencast.org/rpms/testing/el/$releasever/oc-{{ repository_version }}/{{ item }}
25-
enabled: '{{ opencast_repository_enabled_testing }}'
20+
name: "opencast-testing-{{ item }}"
21+
description: "Opencast RHEL $releasever Testing Repository - {{ item }}"
22+
baseurl: "https://pkg.opencast.org/rpms/testing/el/$releasever/oc-{{ repository_version }}/{{ item }}"
23+
enabled: "{{ opencast_repository_enabled_testing }}"
2624
gpgcheck: true
27-
gpgkey: https://pkg.opencast.org/gpgkeys/opencast-{{ repository_version }}-rpm.key
25+
gpgkey: "https://pkg.opencast.org/gpgkeys/opencast-{{ repository_version }}-rpm.key"
2826
vars:
29-
repository_version: '{{ "%02d" % (opencast_version_major|int) }}'
27+
repository_version: "{{ '%02d' % (opencast_version_major | int) }}"
3028
loop:
3129
- x86_64
3230
- noarch
33-
# yamllint enable rule:line-length
3431

35-
- name: install epel repository
32+
- name: Install epel repository
3633
ansible.builtin.package:
3734
name: epel-release

0 commit comments

Comments
 (0)