62 lines
1.5 KiB
YAML
62 lines
1.5 KiB
YAML
---
|
|
- name: Install MySQL server (Mariadb segfaults in Jammy LXD on Bionic host)
|
|
apt:
|
|
name: '{{ mysql_packages }}'
|
|
state: present
|
|
vars:
|
|
mysql_packages:
|
|
- 'default-mysql-server'
|
|
- 'php-mysql'
|
|
- 'python3-pymysql'
|
|
|
|
- name: Generate a random MySQL root password
|
|
set_fact:
|
|
nextcloud_mysql_root_pwd: "{{ lookup('password', 'passwords/mysql_root.pwd') }}"
|
|
|
|
- name: Save root password in config file
|
|
ini_file:
|
|
path: '/etc/mysql/debian.cnf'
|
|
section: client
|
|
option: password
|
|
value: '{{ nextcloud_mysql_root_pwd }}'
|
|
mode: 0600
|
|
no_log: true
|
|
|
|
- name: Update MySQL root password
|
|
mysql_user:
|
|
name: root
|
|
password: '{{ nextcloud_mysql_root_pwd }}'
|
|
config_file: '/etc/mysql/debian.cnf'
|
|
check_implicit_admin: yes
|
|
priv: '*.*:ALL,GRANT'
|
|
host_all: yes
|
|
|
|
- name: Set mysql options for nextcloud
|
|
copy:
|
|
src: mysql_nextcloud.cnf
|
|
dest: /etc/mysql/conf.d/nextcloud.cnf
|
|
notify: restart mysql
|
|
|
|
- name: Generate database user Password
|
|
set_fact:
|
|
nextcloud_db_pwd: "{{ lookup('password', 'passwords/db_admin.pwd') }}"
|
|
|
|
- name: Create nextcloud database
|
|
mysql_db:
|
|
name: 'nextcloud'
|
|
login_user: root
|
|
login_password: '{{ nextcloud_mysql_root_pwd }}'
|
|
config_file: '/etc/mysql/debian.cnf'
|
|
state: present
|
|
|
|
- name: Configure the database user
|
|
mysql_user:
|
|
name: 'ncadmin'
|
|
password: '{{ nextcloud_db_pwd }}'
|
|
priv: 'nextcloud.*:ALL'
|
|
login_user: root
|
|
login_password: '{{ nextcloud_mysql_root_pwd }}'
|
|
config_file: '/etc/mysql/debian.cnf'
|
|
state: present
|
|
|