85 lines
2.0 KiB
YAML
85 lines
2.0 KiB
YAML
---
|
|
|
|
- name: Install python packages needed for Mariadb
|
|
ansible.builtin.apt:
|
|
pkg:
|
|
- python3-mysqldb
|
|
|
|
- name: Install Mariadb server
|
|
ansible.builtin.apt:
|
|
pkg:
|
|
- mariadb-server
|
|
|
|
- name: Restart Mariadb server
|
|
ansible.builtin.service:
|
|
name: mysql
|
|
state: restarted
|
|
|
|
- name: Set Mariadb root password
|
|
community.mysql.mysql_user:
|
|
name: "root"
|
|
password: "{{ mariadb_root_password }}"
|
|
state: present
|
|
|
|
- name: Update Mariadb root password
|
|
community.mysql.mysql_user:
|
|
login_user: "root"
|
|
login_password: "{{ mariadb_root_password }}"
|
|
name: "root"
|
|
host: "{{ item }}"
|
|
password: "{{ mariadb_root_password }}"
|
|
with_items:
|
|
- 127.0.0.1
|
|
- ::1
|
|
- localhost
|
|
|
|
- name: Delete Mariadb anonymous user account for localhost
|
|
community.mysql.mysql_user:
|
|
login_user: "root"
|
|
login_password: "{{ mariadb_root_password }}"
|
|
name: ""
|
|
host: localhost
|
|
state: absent
|
|
|
|
- name: Delete Mariadb anonymous user
|
|
community.mysql.mysql_user:
|
|
login_user: "root"
|
|
login_password: "{{ mariadb_root_password }}"
|
|
name: ""
|
|
host: "{{ item }}"
|
|
state: absent
|
|
with_items:
|
|
- localhost
|
|
- "{{ ansible_nodename }}"
|
|
|
|
- name: Delete Mariadb hostname-based user
|
|
community.mysql.mysql_user:
|
|
login_user: "root"
|
|
login_password: "{{ mariadb_root_password }}"
|
|
name: "root"
|
|
host: "{{ ansible_nodename }}"
|
|
state: absent
|
|
|
|
- name: Delete Mariadb test database
|
|
community.mysql.mysql_db:
|
|
login_user: "root"
|
|
login_password: "{{ mariadb_root_password }}"
|
|
name: "test"
|
|
state: absent
|
|
|
|
- name: Create NextCloud database
|
|
community.mysql.mysql_db:
|
|
login_user: "root"
|
|
login_password: "{{ mariadb_root_password }}"
|
|
name: "{{ package }}"
|
|
state: present
|
|
|
|
- name: Create NextCloud user
|
|
community.mysql.mysql_user:
|
|
login_user: "root"
|
|
login_password: "{{ mariadb_root_password }}"
|
|
name: "{{ package }}"
|
|
password: "{{ mariadb_database_password }}"
|
|
priv: "{{ package }}.*:ALL"
|
|
state: present
|