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

@ -47,4 +47,4 @@ mariadb_default_config:
max_binlog_size: 100M max_binlog_size: 100M
character-set-server: utf8mb4 character-set-server: utf8mb4
collation-server: utf8mb4_general_ci collation-server: utf8mb4_general_ci
mariadb_full_config: '{{ mariadb_default_config|combine(mariadb_config, recursive=True) }}' mariadb_full_config: '{{ mariadb_default_config | combine(mariadb_config, recursive=True) }}'

View file

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

View file

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

View file

@ -11,15 +11,6 @@ platforms:
command: /bin/systemd command: /bin/systemd
capabilities: capabilities:
- SYS_ADMIN - 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: provisioner:
inventory: inventory:
host_vars: host_vars:

View file

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

View file

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