first commit - install and upgrade mariaDB on debian system through official mariaDB repo
This commit is contained in:
47
tasks/install.yml
Normal file
47
tasks/install.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
---
|
||||
- name: mariadb | install prerequisite packages
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- curl
|
||||
- ca-certificates
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
||||
- name: mariadb | download and run mariadb repository setup script
|
||||
shell: |
|
||||
curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | bash -s -- --skip-maxscale --mariadb-server-version=mariadb-{{ mariadb_major_version }}.rolling
|
||||
args:
|
||||
creates: /etc/apt/sources.list.d/mariadb.list
|
||||
become: true
|
||||
|
||||
- name: mariadb | update apt cache after adding repository
|
||||
ansible.builtin.apt:
|
||||
update_cache: yes
|
||||
|
||||
- name: mariadb | install mariadb server and client (latest minor version)
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- mariadb-server
|
||||
- mariadb-client
|
||||
state: present
|
||||
notify:
|
||||
- restart mariadb
|
||||
when:
|
||||
- mariadb_minor_version is not defined
|
||||
|
||||
- name: mariadb | install mariadb server and client (specific minor version)
|
||||
apt:
|
||||
name:
|
||||
- "mariadb-server=1:{{ mariadb_major_version }}.{{ mariadb_minor_version }}*"
|
||||
- "mariadb-client=1:{{ mariadb_major_version }}.{{ mariadb_minor_version }}*"
|
||||
state: present
|
||||
notify:
|
||||
- restart mariadb
|
||||
when:
|
||||
- mariadb_minor_version is defined
|
||||
|
||||
- name: mariadb | ensure mariadb service is started and enabled
|
||||
service:
|
||||
name: mariadb
|
||||
state: started
|
||||
enabled: true
|
||||
11
tasks/main.yml
Normal file
11
tasks/main.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
- name: mariadb | requirements
|
||||
include_tasks: requirements.yml
|
||||
|
||||
- name: mariadb | upgrade
|
||||
include_tasks: upgrade.yml
|
||||
when: mariadb_force_upgrade | bool
|
||||
|
||||
- name: mariadb | installation
|
||||
include_tasks: install.yml
|
||||
when: not mariadb_force_upgrade | bool
|
||||
15
tasks/requirements.yml
Normal file
15
tasks/requirements.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: mariadb | apt update cache
|
||||
ansible.builtin.apt:
|
||||
update_cache: yes
|
||||
cache_valid_time: 86400
|
||||
|
||||
- name: mariadb | install requirements
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- apt-transport-https
|
||||
- lsb-release
|
||||
- ca-certificates
|
||||
- curl
|
||||
state: present
|
||||
|
||||
49
tasks/upgrade.yml
Normal file
49
tasks/upgrade.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
---
|
||||
- name: mariadb | stop mariadb service before upgrade
|
||||
service:
|
||||
name: mariadb
|
||||
state: stopped
|
||||
ignore_errors: true
|
||||
|
||||
- name: mariadb | remove existing repository file (force upgrade)
|
||||
file:
|
||||
path: /etc/apt/sources.list.d/mariadb.list
|
||||
state: absent
|
||||
|
||||
- name: mariadb | download and run mariadb repository setup script (force upgrade)
|
||||
shell: |
|
||||
curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | bash -s -- --skip-maxscale --mariadb-server-version=mariadb-{{ mariadb_major_version }}.rolling
|
||||
become: true
|
||||
|
||||
- name: mariadb | update apt cache after repository change
|
||||
ansible.builtin.apt:
|
||||
update_cache: yes
|
||||
|
||||
- name: mariadb | upgrade mariadb server and client (latest minor version)
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- mariadb-server
|
||||
- mariadb-client
|
||||
state: latest
|
||||
notify:
|
||||
- restart mariadb
|
||||
when:
|
||||
mariadb_minor_version is not defined
|
||||
|
||||
- name: mariadb | upgrade mariadb server and client (specific minor version)
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- "mariadb-server=1:{{ mariadb_major_version }}.{{ mariadb_minor_version }}*"
|
||||
- "mariadb-client=1:{{ mariadb_major_version }}.{{ mariadb_minor_version }}*"
|
||||
state: latest
|
||||
force: yes
|
||||
notify:
|
||||
- restart mariadb
|
||||
when:
|
||||
- mariadb_minor_version is defined
|
||||
|
||||
- name: mariadb | run mysql_upgrade after version change
|
||||
shell: mysql_upgrade
|
||||
ignore_errors: true
|
||||
notify:
|
||||
- restart mariadb
|
||||
Reference in New Issue
Block a user