Skip to content

Commit 451496a

Browse files
authored
Merge pull request #3 from NUZAT-TABASSUM/dev
Enable automatic linting/molecule tests and Debian support (relates to #1,#2 )
2 parents aca4bf5 + 980d5b0 commit 451496a

File tree

15 files changed

+353
-34
lines changed

15 files changed

+353
-34
lines changed

.ansible-lint

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
# .ansible-lint
3+
exclude_paths:
4+
- .cache/
5+
- .github/
6+
- venv/
7+
- .ansible/

.dev_requirements.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
ansible
2+
ansible-core>=2.11
3+
ansible-lint
4+
dnspython
5+
yamllint
6+
molecule
7+
molecule-plugins
8+
molecule-plugins[docker]
9+
molecule-plugins[podman]

.github/workflows/lint.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: lint
3+
4+
on: # yamllint disable-line rule:truthy
5+
push:
6+
pull_request:
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: install dependencies
16+
run: >
17+
pip install -r .dev_requirements.txt
18+
19+
- run: yamllint --strict -c .yamllint .
20+
21+
- run: ansible-lint

.github/workflows/molecule.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
3+
name: molecule
4+
5+
on: # yamllint disable-line rule:truthy
6+
- push
7+
- pull_request
8+
9+
jobs:
10+
molecule:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install dependencies
17+
run: pip3 install -r .dev_requirements.txt
18+
19+
- name: Test playbook
20+
run: molecule test -- -e opencast_postgresql_password=123
21+
env:
22+
PY_COLORS: '1'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
venv/
2+
.ansible/

.yamllint

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
# Yamllint configuration should be compatible with Ansible,
3+
# see https://ansible.readthedocs.io/projects/lint/rules/yaml/#yamllint-configuration
4+
5+
extends: default
6+
7+
rules:
8+
comments:
9+
# https://github.com/prettier/prettier/issues/6780
10+
min-spaces-from-content: 1
11+
# https://github.com/adrienverge/yamllint/issues/384
12+
comments-indentation: false
13+
document-start: disable
14+
# 160 chars was the default used by old E204 rule, but
15+
# you can easily change it or disable in your .yamllint file.
16+
line-length:
17+
max: 200
18+
# We are adding an extra space inside braces as that's how prettier does it
19+
# and we are trying not to fight other linters.
20+
braces:
21+
min-spaces-inside: 0 # yamllint defaults to 0
22+
max-spaces-inside: 1 # yamllint defaults to 0
23+
# key-duplicates:
24+
# forbid-duplicated-merge-keys: true # not enabled by default
25+
octal-values:
26+
forbid-implicit-octal: true # yamllint defaults to false
27+
forbid-explicit-octal: true # yamllint defaults to false
28+
# quoted-strings:
29+
# quote-type: double
30+
# required: only-when-needed
31+
32+
33+
ignore: |
34+
.cache/
35+
.github/
36+
venv/

defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22

3-
opencast_postgresql_version: 12
3+
opencast_postgresql_version: 16
44
opencast_postgresql_user: opencast
55
opencast_postgresql_database: opencast
66
opencast_postgresql_connection_hosts:

handlers/main.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
---
2-
- name: restart postgresql
3-
service:
4-
name: postgresql
5-
state: restarted
2+
- name: Restart Postgresql On CentOS
3+
ansible.builtin.service:
4+
name: "postgresql-{{ opencast_postgresql_version }}"
5+
state: restarted
6+
when: ansible_os_family == "RedHat"
7+
8+
- name: Restart Postgresql On Debian/Ubuntu
9+
ansible.builtin.service:
10+
name: postgresql
11+
state: restarted
12+
when: ansible_os_family == "Debian"

meta/main.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1+
---
12
galaxy_info:
23
author: Lars Kiesow
34
role_name: opencast_postgresql
45
namespace: elan
56
company: ELAN e.V.
67
description: Install and prepare PostgreSQL for Opencast
78
license: BSD-3-Clause
8-
min_ansible_version: 2.9
9+
min_ansible_version: "2.9"
10+
911
galaxy_tags:
1012
- opencast
13+
1114
platforms:
1215
- name: EL
1316
versions:
14-
- 8
17+
- "8"
18+
- "9"
19+
- name: Debian
20+
versions:
21+
- "bullseye"
22+
- "bookworm"
23+
- name: Ubuntu
24+
versions:
25+
- "focal"
26+
- "jammy"
27+
- "noble"
1528

1629
dependencies: []

molecule/default/Dockerfile.j2

Lines changed: 8 additions & 0 deletions
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 pam passwd shadow-utils python39 python3-libselinux
6+
{% else %}
7+
RUN apt-get update && apt-get install -y sudo init bash ca-certificates iproute2 python3 && apt-get clean
8+
{% endif %}

molecule/default/converge.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
tasks:
5+
- name: "Include opencast_postgresql"
6+
ansible.builtin.include_role:
7+
name: elan.opencast_postgresql

molecule/default/molecule.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
dependency:
2+
name: galaxy
3+
enabled: false
4+
5+
driver:
6+
name: containers
7+
8+
platforms:
9+
- name: opencast-postgresql-centos9
10+
image: quay.io/centos/centos:stream9
11+
pre_build_image: false
12+
command: /sbin/init
13+
tmpfs:
14+
"/tmp": "exec"
15+
"/run": "rw,noexec,nosuid,nodev"
16+
volumes:
17+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
18+
19+
- name: opencast-postgresql-debian
20+
image: docker.io/debian:latest
21+
pre_build_image: false
22+
command: /sbin/init
23+
tmpfs:
24+
"/tmp": "exec"
25+
"/run": "rw,noexec,nosuid,nodev"
26+
volumes:
27+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
28+
29+
- name: opencast-postgresql-ubuntu
30+
image: docker.io/ubuntu:latest
31+
pre_build_image: false
32+
command: /sbin/init
33+
tmpfs:
34+
"/tmp": "exec"
35+
"/run": "rw,noexec,nosuid,nodev"
36+
volumes:
37+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
38+
39+
lint: |
40+
set -e
41+
yamllint -c .yamllint .
42+
ansible-lint
43+
44+
provisioner:
45+
name: ansible
46+
47+
verifier:
48+
name: ansible

molecule/default/verify.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
- name: Verify PostgreSQL Installation
3+
hosts: all
4+
gather_facts: true
5+
vars_files:
6+
- ../../defaults/main.yml
7+
8+
tasks:
9+
- name: Ensure PostgreSQL service is running on RedHat/CentOS
10+
ansible.builtin.systemd:
11+
name: "postgresql-{{ opencast_postgresql_version }}"
12+
state: started
13+
when: ansible_os_family == "RedHat"
14+
15+
- name: Ensure PostgreSQL service is running on Debian/Ubuntu
16+
ansible.builtin.systemd:
17+
name: postgresql
18+
state: started
19+
when: ansible_os_family == "Debian"
20+
21+
- name: Get PostgreSQL version on RedHat/CentOS
22+
ansible.builtin.command: "/usr/pgsql-{{ opencast_postgresql_version }}/bin/psql --version"
23+
register: psql_version_centos
24+
changed_when: false
25+
when: ansible_os_family == "RedHat"
26+
27+
- name: Get PostgreSQL version on Debian/Ubuntu
28+
ansible.builtin.command: psql --version
29+
register: psql_version_debian
30+
changed_when: false
31+
when: ansible_os_family == "Debian"
32+
33+
- name: Show PostgreSQL version on RedHat/CentOS
34+
ansible.builtin.debug:
35+
msg: "PostgreSQL version on {{ inventory_hostname }} (RedHat): {{ psql_version_centos.stdout }}"
36+
when: ansible_os_family == "RedHat"
37+
38+
- name: Show PostgreSQL version on Debian/Ubuntu
39+
ansible.builtin.debug:
40+
msg: "PostgreSQL version on {{ inventory_hostname }} (Debian): {{ psql_version_debian.stdout }}"
41+
when: ansible_os_family == "Debian"

0 commit comments

Comments
 (0)