mirror of
https://github.com/krislamo/vagrant-easyredmine
synced 2024-11-10 06:50:35 +00:00
67 lines
1.9 KiB
YAML
67 lines
1.9 KiB
YAML
- name: install mysql, mariadb packages
|
|
yum:
|
|
name: '{{ item }}'
|
|
become: yes
|
|
with_items:
|
|
- mysql-devel
|
|
- mariadb-server
|
|
- MySQL-python
|
|
|
|
- name: manage MySql/MariaDB database service
|
|
service:
|
|
name: '{{ redmine_db_service_provider }}'
|
|
state: started
|
|
enabled: yes
|
|
become: yes
|
|
|
|
- name: create mysql/mariadb database
|
|
mysql_db:
|
|
name: '{{ redmine_db_name }}'
|
|
state: present
|
|
encoding: utf8
|
|
login_user: '{{ mysql_admin_login }}'
|
|
login_password: '{{ mysql_admin_password }}'
|
|
become: yes
|
|
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
|
|
|
|
- name: check for successful database import file
|
|
stat:
|
|
path: '{{ _redmine_db_import_success }}'
|
|
register: redmine_db_import_done
|
|
when: do_redmine_db_import == True
|
|
|
|
- name: import database
|
|
mysql_db:
|
|
name: '{{ redmine_db_name }}'
|
|
state: import
|
|
target: '{{ _redmine_db_import_file }}'
|
|
login_user: '{{ mysql_admin_login }}'
|
|
login_password: '{{ mysql_admin_password }}'
|
|
register: redmine_db_import
|
|
when: do_redmine_db_import == True and (redmine_db_import_done.stat.exists == False or redmine_db_created|changed)
|
|
|
|
- name: create successful database import file
|
|
file:
|
|
path: '{{ _redmine_db_import_success }}'
|
|
state: touch
|
|
when: do_redmine_db_import == True and redmine_db_import_done.stat.exists == False and redmine_db_import|success
|
|
|
|
- name: create redmine db user
|
|
mysql_user:
|
|
name: '{{ redmine_db_user }}'
|
|
password: '{{ redmine_db_password }}'
|
|
append_privs: yes
|
|
priv: '{{ redmine_db_name }}.*:ALL'
|
|
state: present
|
|
become: yes
|
|
|