Compare commits
No commits in common. "f4b32e516b8214af77c377e907b1a0d136195521" and "dec2d50fbc017f6dff2c1a9ef879cc8e0c3b713c" have entirely different histories.
f4b32e516b
...
dec2d50fbc
@ -2,19 +2,6 @@
|
|||||||
|
|
||||||
- name: Configure Debian packages
|
- name: Configure Debian packages
|
||||||
block:
|
block:
|
||||||
# Create directory for third-party package signing keys. Required on distros
|
|
||||||
# older than Debian 12 / Ubuntu 22.04.
|
|
||||||
#
|
|
||||||
# See: https://wiki.debian.org/DebianRepository/UseThirdParty
|
|
||||||
- name: Create /etc/apt/keyrings
|
|
||||||
file:
|
|
||||||
path: /etc/apt/keyrings
|
|
||||||
mode: 0755
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
state: directory
|
|
||||||
when: ansible_distribution_major_version is version('12', '<')
|
|
||||||
|
|
||||||
- name: Configure apt mirror
|
- name: Configure apt mirror
|
||||||
ansible.builtin.template: src=sources.list.j2 dest=/etc/apt/sources.list owner=root group=root mode=0644
|
ansible.builtin.template: src=sources.list.j2 dest=/etc/apt/sources.list owner=root group=root mode=0644
|
||||||
when: ansible_architecture != 'armv7l'
|
when: ansible_architecture != 'armv7l'
|
||||||
|
@ -2,19 +2,6 @@
|
|||||||
|
|
||||||
- name: Configure Ubuntu packages
|
- name: Configure Ubuntu packages
|
||||||
block:
|
block:
|
||||||
# Create directory for third-party package signing keys. Required on distros
|
|
||||||
# older than Debian 12 / Ubuntu 22.04.
|
|
||||||
#
|
|
||||||
# See: https://wiki.debian.org/DebianRepository/UseThirdParty
|
|
||||||
- name: Create /etc/apt/keyrings
|
|
||||||
file:
|
|
||||||
path: /etc/apt/keyrings
|
|
||||||
mode: 0755
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
state: directory
|
|
||||||
when: ansible_distribution_major_version is version('22.04', '<')
|
|
||||||
|
|
||||||
- name: Configure apt mirror
|
- name: Configure apt mirror
|
||||||
ansible.builtin.template: src=sources.list.j2 dest=/etc/apt/sources.list owner=root group=root mode=0644
|
ansible.builtin.template: src=sources.list.j2 dest=/etc/apt/sources.list owner=root group=root mode=0644
|
||||||
when: ansible_architecture != 'armv7l'
|
when: ansible_architecture != 'armv7l'
|
||||||
|
@ -1,110 +1,55 @@
|
|||||||
---
|
---
|
||||||
- name: Remove MariaDB key from apt-key
|
- name: Add GPG key for MariaDB repo
|
||||||
ansible.builtin.apt_key:
|
ansible.builtin.apt_key: id=0x177F4010FE56CA3336300305F1656F24C74CD1D8 url=https://mariadb.org/mariadb_release_signing_key.asc
|
||||||
id: 0x177F4010FE56CA3336300305F1656F24C74CD1D8
|
register: add_mariadb_apt_key
|
||||||
state: absent
|
tags: mariadb, packages
|
||||||
tags:
|
|
||||||
- packages
|
|
||||||
- mariadb
|
|
||||||
|
|
||||||
- name: Check MariaDB package signing key
|
- name: Add MariaDB 10.5 repo
|
||||||
ansible.builtin.stat:
|
ansible.builtin.template: src=mariadb.list.j2 dest=/etc/apt/sources.list.d/mariadb.list owner=root group=root mode=0644
|
||||||
path: /etc/apt/keyrings/mariadb_release_signing_key.asc
|
|
||||||
register: mariadb_signing_key_stat
|
|
||||||
tags:
|
|
||||||
- packages
|
|
||||||
- mariadb
|
|
||||||
|
|
||||||
- name: Download MariaDB package signing key
|
|
||||||
ansible.builtin.get_url:
|
|
||||||
url: https://mariadb.org/mariadb_release_signing_key.asc
|
|
||||||
dest: /etc/apt/keyrings/mariadb_release_signing_key.asc
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
register: download_mariadb_signing_key
|
|
||||||
when: not mariadb_signing_key_stat.stat.exists
|
|
||||||
tags:
|
|
||||||
- packages
|
|
||||||
- mariadb
|
|
||||||
|
|
||||||
- name: Add MariaDB 10.6 repo
|
|
||||||
ansible.builtin.apt_repository:
|
|
||||||
repo: 'deb [arch=amd64 signed-by=/etc/apt/keyrings/mariadb_release_signing_key.asc] https://dlm.mariadb.com/repo/mariadb-server/10.6/repo/debian {{ ansible_distribution_release }} main'
|
|
||||||
filename: mariadb
|
|
||||||
state: present
|
|
||||||
register: add_mariadb_apt_repository
|
register: add_mariadb_apt_repository
|
||||||
tags:
|
tags: mariadb, packages
|
||||||
- packages
|
|
||||||
- mariadb
|
|
||||||
|
|
||||||
- name: Update apt cache
|
- name: Update apt cache
|
||||||
ansible.builtin.apt: # noqa no-handler
|
ansible.builtin.apt:
|
||||||
update_cache: true
|
update_cache: true
|
||||||
when:
|
when:
|
||||||
(download_mariadb_signing_key.status_code is defined and download_mariadb_signing_key.status_code == 200) or
|
add_mariadb_apt_key is changed or
|
||||||
add_mariadb_apt_repository is changed
|
add_mariadb_apt_repository is changed
|
||||||
tags:
|
|
||||||
- packages
|
|
||||||
- mariadb
|
|
||||||
|
|
||||||
- name: Install mariadb-server
|
- name: Install mariadb-server
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt: name={{ item }} state=present cache_valid_time=3600
|
||||||
name: ['mariadb-server', 'python3-pymysql']
|
loop:
|
||||||
state: present
|
- mariadb-server
|
||||||
cache_valid_time: 3600
|
- python3-pymysql # for ansible
|
||||||
tags: mariadb, packages
|
tags: mariadb, packages
|
||||||
|
|
||||||
- name: Create system my.cnf
|
- name: Create system my.cnf
|
||||||
ansible.builtin.template:
|
ansible.builtin.template: src=my.cnf.j2 dest=/etc/mysql/my.cnf owner=root group=root mode=0644
|
||||||
src: my.cnf.j2
|
|
||||||
dest: /etc/mysql/my.cnf
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
notify:
|
notify:
|
||||||
- restart mariadb
|
- restart mariadb
|
||||||
tags: mariadb
|
tags: mariadb
|
||||||
|
|
||||||
# See: https://docs.ansible.com/ansible/latest/collections/community/mysql/mysql_user_module.html
|
# See: https://docs.ansible.com/ansible/latest/collections/community/mysql/mysql_user_module.html
|
||||||
- name: Update MariaDB root password for all root accounts
|
- name: Update MariaDB root password for all root accounts
|
||||||
community.mysql.mysql_user:
|
community.mysql.mysql_user: name=root host={{ item }} password={{ mariadb_root_password }} login_unix_socket={{ mariadb_login_unix_socket }}
|
||||||
name: root
|
|
||||||
host: "{{ item }}"
|
|
||||||
password: "{{ mariadb_root_password }}"
|
|
||||||
login_unix_socket: "{{ mariadb_login_unix_socket }}"
|
|
||||||
loop:
|
loop:
|
||||||
- 127.0.0.1
|
- 127.0.0.1
|
||||||
- ::1
|
- ::1
|
||||||
tags: mariadb
|
tags: mariadb
|
||||||
|
|
||||||
- name: Create .my.conf file with root credentials
|
- name: Create .my.conf file with root credentials
|
||||||
ansible.builtin.template:
|
ansible.builtin.template: src=.my.cnf.j2 dest=/root/.my.cnf owner=root mode=0600
|
||||||
src: .my.cnf.j2
|
|
||||||
dest: /root/.my.cnf
|
|
||||||
owner: root
|
|
||||||
mode: 0600
|
|
||||||
tags: mariadb
|
tags: mariadb
|
||||||
|
|
||||||
# See: https://docs.ansible.com/ansible/latest/collections/community/mysql/mysql_db_module.html
|
# See: https://docs.ansible.com/ansible/latest/collections/community/mysql/mysql_db_module.html
|
||||||
- name: Create MariaDB database(s)
|
- name: Create MariaDB database(s)
|
||||||
community.mysql.mysql_db:
|
community.mysql.mysql_db: db={{ item.name }} state=present encoding=utf8mb4 login_unix_socket={{ mariadb_login_unix_socket }}
|
||||||
db: "{{ item.name }}"
|
|
||||||
state: present
|
|
||||||
encoding: utf8mb4
|
|
||||||
login_unix_socket: "{{ mariadb_login_unix_socket }}"
|
|
||||||
loop: "{{ mariadb_databases }}"
|
loop: "{{ mariadb_databases }}"
|
||||||
when: mariadb_databases is defined
|
when: mariadb_databases is defined
|
||||||
tags: mariadb
|
tags: mariadb
|
||||||
|
|
||||||
- name: Create MariaDB user(s)
|
- name: Create MariaDB user(s)
|
||||||
community.mysql.mysql_user:
|
community.mysql.mysql_user: name={{ item.user }} password={{ item.pass }} priv={{ item.name }}.*:ALL host=127.0.0.1 state=present login_unix_socket={{ mariadb_login_unix_socket }}
|
||||||
name: "{{ item.user }}"
|
|
||||||
password: "{{ item.pass }}"
|
|
||||||
priv: "{{ item.name }}.*:ALL"
|
|
||||||
host: 127.0.0.1
|
|
||||||
state: present
|
|
||||||
login_unix_socket: "{{ mariadb_login_unix_socket }}"
|
|
||||||
loop: "{{ mariadb_databases }}"
|
loop: "{{ mariadb_databases }}"
|
||||||
when: mariadb_databases is defined
|
when: mariadb_databases is defined
|
||||||
tags: mariadb
|
tags: mariadb
|
||||||
|
3
roles/mariadb/templates/mariadb.list.j2
Normal file
3
roles/mariadb/templates/mariadb.list.j2
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{{ ansible_managed | comment }}
|
||||||
|
|
||||||
|
deb [arch=amd64] https://dlm.mariadb.com/repo/mariadb-server/10.5/repo/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} main
|
Loading…
Reference in New Issue
Block a user