Skip to content

Commit

Permalink
various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmirnow committed Jul 30, 2024
1 parent ba550ed commit 32fa7b0
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 11 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ jobs:
- uses: actions/checkout@v4

- name: install dependencies
run: >
pip install -r .dev_requirements.txt
run: pip install -r .dev_requirements.txt

- name: install Ansbile dependencies
run: ansible-galaxy install -r requirements.yml

- run: yamllint --strict -c .yamllint .

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
- name: install dependencies
run: pip install -r .dev_requirements.txt

- name: install Ansbile dependencies
run: ansible-galaxy install -r requirements.yml

- name: test playbook
run: molecule test
env:
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ platforms:
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
published_ports:
- 3306/tcp
- 3306/tcp
- name: opencast_mariadb_ubuntu
image: docker.io/ubuntu:latest
pre_build_image: false
Expand Down
45 changes: 40 additions & 5 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,44 @@
---
- name: Verify
hosts: all
gather_facts: false
vars:
database_password: "1234"
tasks:
- name: Check if MariaDB is active
ansible.builtin.command:
cmd: systemctl is-active mariadb
changed_when: false
- name: Check MariaDB socket exists
ansible.builtin.wait_for:
path: "{{ '/run/mysqld/mysqld.sock' if ansible_os_family == 'Debian' else '/var/lib/mysql/mysql.sock' }}"
delay: 1
timeout: 10

- name: Check MariaDB port listening
ansible.builtin.wait_for:
port: 3306
timeout: 10

- name: Check current user
community.mysql.mysql_query:
login_host: localhost
login_user: opencast
login_password: "{{ database_password }}"
query: >-
SELECT CURRENT_USER() as USER;
register: query_current_user

- name: Fail on invalid user
ansible.builtin.fail:
msg: User should be "opencast@%" but is {{ query_current_user.query_result.0.0.USER }}
when: "'opencast@%' != query_current_user.query_result.0.0.USER"

- name: Check Opencast table exists
community.mysql.mysql_query:
login_host: localhost
login_user: opencast
login_password: "{{ database_password }}"
query: >-
SHOW DATABASES LIKE "opencast";
register: query_databases

- name: Fail on not existing opencast database
ansible.builtin.fail:
msg: Opencast database does not exist
when: "query_databases.rowcount.0 != 1"
4 changes: 4 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
collections:
- community.general
- community.mysql
7 changes: 4 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

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

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

- name: Set MariaDB root user password (RedHat)
when: ansible_os_family == 'RedHat'
Expand Down

0 comments on commit 32fa7b0

Please sign in to comment.