Skip to content

Commit 32fa7b0

Browse files
committed
various fixes
1 parent ba550ed commit 32fa7b0

File tree

6 files changed

+56
-11
lines changed

6 files changed

+56
-11
lines changed

.github/workflows/lint.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ jobs:
1313
- uses: actions/checkout@v4
1414

1515
- name: install dependencies
16-
run: >
17-
pip install -r .dev_requirements.txt
16+
run: pip install -r .dev_requirements.txt
17+
18+
- name: install Ansbile dependencies
19+
run: ansible-galaxy install -r requirements.yml
1820

1921
- run: yamllint --strict -c .yamllint .
2022

.github/workflows/molecule.yml

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jobs:
1515
- name: install dependencies
1616
run: pip install -r .dev_requirements.txt
1717

18+
- name: install Ansbile dependencies
19+
run: ansible-galaxy install -r requirements.yml
20+
1821
- name: test playbook
1922
run: molecule test
2023
env:

molecule/default/molecule.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ platforms:
2626
volumes:
2727
- /sys/fs/cgroup:/sys/fs/cgroup:ro
2828
published_ports:
29-
- 3306/tcp
29+
- 3306/tcp
3030
- name: opencast_mariadb_ubuntu
3131
image: docker.io/ubuntu:latest
3232
pre_build_image: false

molecule/default/verify.yml

+40-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,44 @@
11
---
22
- name: Verify
33
hosts: all
4-
gather_facts: false
4+
vars:
5+
database_password: "1234"
56
tasks:
6-
- name: Check if MariaDB is active
7-
ansible.builtin.command:
8-
cmd: systemctl is-active mariadb
9-
changed_when: false
7+
- name: Check MariaDB socket exists
8+
ansible.builtin.wait_for:
9+
path: "{{ '/run/mysqld/mysqld.sock' if ansible_os_family == 'Debian' else '/var/lib/mysql/mysql.sock' }}"
10+
delay: 1
11+
timeout: 10
12+
13+
- name: Check MariaDB port listening
14+
ansible.builtin.wait_for:
15+
port: 3306
16+
timeout: 10
17+
18+
- name: Check current user
19+
community.mysql.mysql_query:
20+
login_host: localhost
21+
login_user: opencast
22+
login_password: "{{ database_password }}"
23+
query: >-
24+
SELECT CURRENT_USER() as USER;
25+
register: query_current_user
26+
27+
- name: Fail on invalid user
28+
ansible.builtin.fail:
29+
msg: User should be "opencast@%" but is {{ query_current_user.query_result.0.0.USER }}
30+
when: "'opencast@%' != query_current_user.query_result.0.0.USER"
31+
32+
- name: Check Opencast table exists
33+
community.mysql.mysql_query:
34+
login_host: localhost
35+
login_user: opencast
36+
login_password: "{{ database_password }}"
37+
query: >-
38+
SHOW DATABASES LIKE "opencast";
39+
register: query_databases
40+
41+
- name: Fail on not existing opencast database
42+
ansible.builtin.fail:
43+
msg: Opencast database does not exist
44+
when: "query_databases.rowcount.0 != 1"

requirements.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
collections:
3+
- community.general
4+
- community.mysql

tasks/main.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
- name: Configure mariadb
4040
notify: Restart MariaDB
41-
ansible.builtin.ini_file:
41+
community.general.ini_file:
4242
dest: "{{ '/etc/mysql/mariadb.conf.d/50-server.cnf' if ansible_os_family == 'Debian' else '/etc/my.cnf.d/opencast.cnf' }}"
4343
section: mysqld
4444
option: "{{ item.key }}"
@@ -63,10 +63,11 @@
6363
state: started
6464
enabled: true
6565

66-
- name: Start MariaDB
66+
- name: Wait for MariaDB start
6767
ansible.builtin.wait_for:
68-
path: /var/lib/mysql/mysql.sock
68+
path: "{{ '/run/mysqld/mysqld.sock' if ansible_os_family == 'Debian' else '/var/lib/mysql/mysql.sock' }}"
6969
delay: 1
70+
timeout: 30
7071

7172
- name: Set MariaDB root user password (RedHat)
7273
when: ansible_os_family == 'RedHat'

0 commit comments

Comments
 (0)