2021-02-24 21:07:55 +00:00
|
|
|
- name: Download MariaDB installation script
|
|
|
|
get_url:
|
|
|
|
url: https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
|
|
|
|
dest: '{{ remote_scratch_path }}/mariadb_repo_setup'
|
|
|
|
mode: '0700'
|
|
|
|
|
|
|
|
- name: Install MariaDB repo via script
|
|
|
|
shell: '{{ remote_scratch_path }}/mariadb_repo_setup'
|
|
|
|
args:
|
|
|
|
creates: /etc/yum.repos.d/mariadb.repo
|
|
|
|
become: yes
|
|
|
|
|
|
|
|
- name: Install MariaDB
|
2017-12-21 03:47:20 +00:00
|
|
|
yum:
|
2021-03-03 19:58:05 +00:00
|
|
|
name: ['mysql-devel', 'MariaDB-server', 'MySQL-python', 'MariaDB-shared']
|
2021-02-24 21:07:55 +00:00
|
|
|
state: present
|
|
|
|
update_cache: yes
|
2016-07-14 03:15:07 +00:00
|
|
|
become: yes
|
2015-11-12 04:14:03 +00:00
|
|
|
|
2018-03-20 17:04:30 +00:00
|
|
|
- name: manage MySql/MariaDB database service
|
|
|
|
service:
|
2017-12-21 03:47:20 +00:00
|
|
|
name: '{{ redmine_db_service_provider }}'
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
2016-07-14 03:15:07 +00:00
|
|
|
become: yes
|
2015-11-12 04:14:03 +00:00
|
|
|
|
2018-03-20 17:04:30 +00:00
|
|
|
- name: create mysql/mariadb database
|
|
|
|
mysql_db:
|
2017-12-21 03:47:20 +00:00
|
|
|
name: '{{ redmine_db_name }}'
|
|
|
|
state: present
|
|
|
|
encoding: utf8
|
|
|
|
login_user: '{{ mysql_admin_login }}'
|
|
|
|
login_password: '{{ mysql_admin_password }}'
|
2016-07-14 03:15:07 +00:00
|
|
|
become: yes
|
2015-11-12 04:14:03 +00:00
|
|
|
register: redmine_db_created
|
|
|
|
|
|
|
|
# source database may not have same name as VM db.
|
|
|
|
# So remove CREATE or USE statements from dump.
|
|
|
|
# while unpacking.
|
|
|
|
- name: unpack mysql dump file
|
|
|
|
shell: "/usr/bin/gunzip -c {{ redmine_db_dump_file }} | /usr/bin/sed '/^CREATE DATABASE \\|^USE /d' > {{ _redmine_db_import_file }}"
|
|
|
|
args:
|
|
|
|
creates: '{{ _redmine_db_import_file }}'
|
|
|
|
when: do_redmine_db_import == True
|
|
|
|
|
2018-03-20 17:04:30 +00:00
|
|
|
- name: check for successful database import file
|
|
|
|
stat:
|
2017-12-21 03:47:20 +00:00
|
|
|
path: '{{ _redmine_db_import_success }}'
|
2015-11-12 04:14:03 +00:00
|
|
|
register: redmine_db_import_done
|
|
|
|
when: do_redmine_db_import == True
|
|
|
|
|
|
|
|
- name: import database
|
2017-12-21 03:47:20 +00:00
|
|
|
mysql_db:
|
|
|
|
name: '{{ redmine_db_name }}'
|
|
|
|
state: import
|
|
|
|
target: '{{ _redmine_db_import_file }}'
|
|
|
|
login_user: '{{ mysql_admin_login }}'
|
|
|
|
login_password: '{{ mysql_admin_password }}'
|
2021-03-03 19:58:05 +00:00
|
|
|
become: yes
|
2015-11-12 04:14:03 +00:00
|
|
|
register: redmine_db_import
|
2018-05-10 14:07:01 +00:00
|
|
|
when: do_redmine_db_import == True and (redmine_db_import_done.stat.exists == False or redmine_db_created is changed)
|
|
|
|
|
2018-03-20 17:04:30 +00:00
|
|
|
- name: create successful database import file
|
|
|
|
file:
|
2017-12-21 03:47:20 +00:00
|
|
|
path: '{{ _redmine_db_import_success }}'
|
|
|
|
state: touch
|
2018-05-10 14:07:01 +00:00
|
|
|
when: do_redmine_db_import == True and redmine_db_import_done.stat.exists == False and redmine_db_import is success
|
2015-11-12 04:14:03 +00:00
|
|
|
|
2015-11-30 15:08:24 +00:00
|
|
|
- name: create redmine db user
|
2017-12-21 03:47:20 +00:00
|
|
|
mysql_user:
|
|
|
|
name: '{{ redmine_db_user }}'
|
|
|
|
password: '{{ redmine_db_password }}'
|
|
|
|
append_privs: yes
|
|
|
|
priv: '{{ redmine_db_name }}.*:ALL'
|
|
|
|
state: present
|
2016-07-14 03:15:07 +00:00
|
|
|
become: yes
|
2020-05-22 16:46:51 +00:00
|
|
|
no_log: yes
|
2015-11-12 04:14:03 +00:00
|
|
|
|