Skip to content

Commit

Permalink
major: used full qualified collection names
Browse files Browse the repository at this point in the history
  • Loading branch information
tboerger committed Feb 6, 2024
1 parent 1727d7f commit a67a856
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v4

- name: Role linting
uses: actionhippie/ansible-later@v2
uses: actionhippie/ansible-later@v3

testing:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ mariadb_username:

## Dependencies

- None
- [rolehippie.docker](https://github.com/rolehippie/docker)

## License

Expand Down
4 changes: 2 additions & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
- name: Restart mariadb
systemd:
ansible.builtin.systemd:
name: mariadb
state: restarted
daemon_reload: True

- name: Restart mariadb-exporter
systemd:
ansible.builtin.systemd:
name: mariadb-exporter
state: restarted
daemon_reload: True
Expand Down
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Building and improving this Ansible role have been sponsored by my current and previous employers like **[Cloudpunks GmbH](https://cloudpunks.de)** and **[Proact Deutschland GmbH](https://www.proact.eu)**.
# @end
# @meta dependencies:value: >
# None
# [rolehippie.docker](https://github.com/rolehippie/docker)
# @end
galaxy_info:
role_name: mariadb
Expand Down
8 changes: 8 additions & 0 deletions meta/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
collections:
- community.mysql
- community.docker

roles: []

...
44 changes: 35 additions & 9 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,48 @@
gather_facts: False

tasks:
- name: Stat apt dir
register: aptdir
ansible.builtin.stat:
path: /var/lib/apt

- name: Wait for aptlock
shell: while fuser /var/lib/apt/lists/lock >/dev/null 2>&1; do echo 'Waiting for apt list lock.' && sleep 10; done
when: aptdir.stat.exists
changed_when: False
ansible.builtin.shell:
cmd: while fuser /var/lib/apt/lists/lock >/dev/null 2>&1; do echo 'Waiting for apt list lock.' && sleep 10; done

- name: Update package cache
apt:
when: aptdir.stat.exists
ansible.builtin.apt:
update_cache: True

- name: Install gpg dependency
apt:
name: python3-gpg
- name: Install test dependencies
when: aptdir.stat.exists
loop:
- python3-gpg
- curl
ansible.builtin.apt:
name: "{{ item }}"
state: present

- name: Install curl dependency
apt:
name: curl
state: present
- name: Create man dirs
changed_when: False
loop:
- /usr/share/man/man1
- /usr/share/man/man2
- /usr/share/man/man3
- /usr/share/man/man4
- /usr/share/man/man5
- /usr/share/man/man6
- /usr/share/man/man7
- /usr/share/man/man8
- /usr/share/man/man9
ansible.builtin.file:
path: "{{ item }}"
owner: root
group: root
mode: u=rwx,g=rx,o=rx
state: directory

...
5 changes: 4 additions & 1 deletion molecule/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
collections: []
collections:
- community.mysql
- community.docker

roles: []

...
20 changes: 10 additions & 10 deletions tasks/exporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
failed_when: False
changed_when: False
check_mode: False
shell: /usr/bin/mariadb-exporter --version 2>&1
ansible.builtin.shell: /usr/bin/mariadb-exporter --version 2>&1
tags:
- mariadb-exporter

- name: Fact version change
when:
- mariadb_installation == 'native'
set_fact:
ansible.builtin.set_fact:
mariadb_exporter_version_changed: "{{ mariadb_exporter_version_check.rc != 0 or (mariadb_exporter_version_check.stdout_lines is defined and mariadb_exporter_version not in mariadb_exporter_version_check.stdout_lines[0]) | bool }}"
tags:
- mariadb-exporter
Expand All @@ -22,7 +22,7 @@
when:
- mariadb_installation == 'native'
- mariadb_exporter_version_changed
unarchive:
ansible.builtin.unarchive:
src: "{{ mariadb_exporter_download }}"
dest: /usr/local/src
remote_src: True
Expand All @@ -38,7 +38,7 @@
- not ansible_check_mode
notify:
- Restart mariadb-exporter
copy:
ansible.builtin.copy:
src: "/usr/local/src/mysqld_exporter-{{ mariadb_exporter_version }}.linux-amd64/mysqld_exporter"
dest: /usr/bin/mariadb-exporter
remote_src: True
Expand All @@ -51,7 +51,7 @@
- name: Write default config
notify:
- Restart mariadb-exporter
template:
ansible.builtin.template:
src: exporter/default.j2
dest: /etc/default/mariadb-exporter
owner: root
Expand All @@ -63,7 +63,7 @@
- name: Write service file
notify:
- Restart mariadb-exporter
template:
ansible.builtin.template:
src: exporter/service.j2
dest: /etc/systemd/system/mariadb-exporter.service
owner: root
Expand All @@ -76,7 +76,7 @@
when:
- mariadb_installation == 'docker'
- mariadb_exporter_pull_image
docker_image:
community.docker.docker_image:
name: "{{ mariadb_exporter_image }}"
source: pull
tags:
Expand All @@ -86,14 +86,14 @@
when:
- mariadb_installation == 'docker'
- mariadb_exporter_network | default(False)
docker_network:
community.docker.docker_network:
name: '{{ mariadb_exporter_network }}'
tags:
- mariadb-exporter

- name: Start mariadb-exporter service
ignore_errors: "{{ ansible_check_mode }}"
systemd:
ansible.builtin.systemd:
name: mariadb-exporter
state: started
daemon_reload: True
Expand All @@ -105,7 +105,7 @@
- name: Remove install directory
when:
- mariadb_installation == 'native'
file:
ansible.builtin.file:
path: "/usr/local/src/mysqld_exporter-{{ mariadb_exporter_version }}.linux-amd64"
state: absent
tags:
Expand Down
12 changes: 6 additions & 6 deletions tasks/galera.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
register: mariadb_galera_status
delegate_to: "{{ mariadb_galera_primary | default('dummy') }}"
run_once: True
mysql_info:
community.mysql.mysql_info:
filter: settings
login_unix_socket: /var/run/mysqld/mysqld.sock
login_user: "{{ mariadb_root_username }}"
Expand All @@ -14,7 +14,7 @@
- name: Stop mariadb services
when:
- mariadb_galera_status.settings.wsrep_on == 'OFF'
systemd:
ansible.builtin.systemd:
name: mariadb
state: stopped
daemon_reload: True
Expand All @@ -29,7 +29,7 @@
- inventory_hostname == mariadb_galera_primary
vars:
mariadb_galera_nodes: []
template:
ansible.builtin.template:
src: galera.j2
dest: /etc/mysql/mariadb.conf.d/60-galera.cnf
owner: root
Expand All @@ -42,15 +42,15 @@
when:
- mariadb_galera_status.settings.wsrep_on == 'OFF'
- inventory_hostname == mariadb_galera_primary
command: galera_new_cluster
ansible.builtin.command: galera_new_cluster
tags:
- mariadb

- name: Restore galera config
when:
- mariadb_galera_status.settings.wsrep_on == 'OFF'
- inventory_hostname == mariadb_galera_primary
template:
ansible.builtin.template:
src: galera.j2
dest: /etc/mysql/mariadb.conf.d/60-galera.cnf
owner: root
Expand All @@ -62,7 +62,7 @@
- name: Start galera cluster
when:
- mariadb_galera_status.settings.wsrep_on == 'OFF'
systemd:
ansible.builtin.systemd:
name: mariadb
state: started
daemon_reload: True
Expand Down
Loading

0 comments on commit a67a856

Please sign in to comment.