chore: fix syntax for ansible-lint

This commit is contained in:
Adrien Waksberg 2023-06-29 15:17:06 +02:00
parent a5a31223c0
commit 6361a81fe5
7 changed files with 43 additions and 52 deletions

View file

@ -1,5 +1,5 @@
---
- name: restart mariadb
- name: Restart mariadb
ansible.builtin.service:
name: mysql
state: restarted

View file

@ -6,7 +6,7 @@ galaxy_info:
company: Adrien Waksberg
description: Install and configure mariadb
license: Apache2
min_ansible_version: 2.9
min_ansible_version: "2.9"
platforms:
- name: Debian

View file

@ -11,15 +11,6 @@ platforms:
command: /bin/systemd
capabilities:
- SYS_ADMIN
- name: debian11
image: nishiki/debian11:molecule
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
command: /bin/systemd
capabilities:
- SYS_ADMIN
provisioner:
inventory:
host_vars:

View file

@ -1,5 +1,5 @@
---
- name: create the data directory
- name: Create the data directory
ansible.builtin.file:
path: '{{ mariadb_full_config.mysqld.datadir }}'
owner: '{{ mariadb_full_config.mysqld.user }}'
@ -8,7 +8,7 @@
state: directory
tags: mariadb
- name: initialize database
- name: Initialize database # noqa no-changed-when
ansible.builtin.command:
args:
argv:
@ -17,26 +17,24 @@
- '--user={{ mariadb_full_config.mysqld.user }}'
- '--skip-name-resolve'
- '--no-defaults'
when: True
tags: mariadb
- name: start mariadb
- name: Start mariadb
ansible.builtin.service:
name: mysql
state: started
tags: mariadb
- name: wait mysql start
- name: Wait mysql start
ansible.builtin.pause:
seconds: 5
tags: mariadb
- name: set root password
- name: Set root password # noqa no-changed-when
ansible.builtin.command: 'mysqladmin -u root password {{ mariadb_password }}'
when: True
tags: mariadb
- name: remove anonymous users
- name: Remove anonymous users
community.mysql.mysql_user:
name: ''
host_all: yes
@ -45,7 +43,7 @@
login_password: '{{ mariadb_password }}'
tags: mariadb
- name: remove root user without password
- name: Remove root user without password
community.mysql.mysql_user:
name: root
host: '{{ item }}'

View file

@ -1,5 +1,5 @@
---
- name: install dependencies packages
- name: Install dependencies packages
ansible.builtin.package:
name:
- gpg
@ -9,10 +9,11 @@
until: result is succeeded
tags: mariadb
- import_tasks: repo.yml
- name: Install official repository
ansible.builtin.import_tasks: repo.yml
when: mariadb_use_official_repository|bool
- name: install package
- name: Install package
ansible.builtin.package:
name:
- mariadb-server
@ -21,57 +22,58 @@
until: result is succeeded
tags: mariadb
- name: copy configuration file
- name: Copy configuration file
ansible.builtin.template:
src: my.cnf.j2
dest: /etc/mysql/my.cnf
owner: root
group: root
mode: 0644
notify: restart mariadb
notify: Restart mariadb
tags: mariadb
- name: check if datadir exist
- name: Check if datadir exist
ansible.builtin.stat:
path: '{{ mariadb_full_config.mysqld.datadir }}'
path: "{{ mariadb_full_config.mysqld.datadir }}"
register: st
tags: mariadb
- import_tasks: initdb.yml
- name: Initialize the database
ansible.builtin.import_tasks: initdb.yml
when: not st.stat.exists
- name: enable and start the service
- name: Enable and start the service
ansible.builtin.service:
name: mysql
state: started
enabled: true
tags: mariadb
- name: manage users
- name: Manage users
community.mysql.mysql_user:
name: '{{ item.name }}'
host: '{{ item.host }}'
password: '{{ item.password }}'
priv: '{{ item.privileges|default("")|join("/") }}'
state: '{{ item.state|default("present") }}'
login_user: '{{ mariadb_user }}'
login_password: '{{ mariadb_password }}'
loop: '{{ mariadb_users }}'
name: "{{ item.name }}"
host: "{{ item.host }}"
password: "{{ item.password }}"
priv: "{{ item.privileges | default('') | join('/') }}"
state: "{{ item.state | default('present') }}"
login_user: "{{ mariadb_user }}"
login_password: "{{ mariadb_password }}"
loop: "{{ mariadb_users }}"
loop_control:
label: '{{ item.name }}@{{ item.host }}'
label: "{{ item.name }}@{{ item.host }}"
run_once: true
when: mariadb_master|bool
tags: mariadb
- name: manage databases
- name: Manage databases
community.mysql.mysql_db:
name: '{{ item.name }}'
state: '{{ item.state|default("present") }}'
login_user: '{{ mariadb_user }}'
login_password: '{{ mariadb_password }}'
loop: '{{ mariadb_databases }}'
name: "{{ item.name }}"
state: "{{ item.state | default('present') }}"
login_user: "{{ mariadb_user }}"
login_password: "{{ mariadb_password }}"
loop: "{{ mariadb_databases }}"
loop_control:
label: '{{ item.name }}'
label: "{{ item.name }}"
run_once: true
when: mariadb_master|bool
tags: mariadb

View file

@ -1,14 +1,14 @@
---
- name: add gpg key for mariadb repository
- name: Add gpg key for mariadb repository
ansible.builtin.apt_key:
keyserver: '{{ mariadb_repository_key_server }}'
id: '{{ mariadb_repository_key_id }}'
keyserver: "{{ mariadb_repository_key_server }}"
id: "{{ mariadb_repository_key_id }}"
retries: 2
register: result
until: result is succeeded
tags: mariadb
- name: add official repo
- name: Add official repo
ansible.builtin.apt_repository:
repo: '{{ mariadb_repository }}'
repo: "{{ mariadb_repository }}"
tags: mariadb