1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/mysql/tasks/main.yml

149 lines
3.9 KiB
YAML
Raw Normal View History

2017-11-08 06:22:50 +00:00
- name: Install MySQL (debuntu)
2017-12-08 11:35:49 +00:00
package:
name: "{{ item }}"
state: present
2017-05-27 18:09:50 +00:00
with_items:
- mariadb-server
- mariadb-client
- python-mysqldb
2017-05-27 23:10:45 +00:00
- php{{ php_version }}
- php{{ php_version }}-mysql
2017-05-27 18:09:50 +00:00
- php-pear
2017-05-27 23:10:45 +00:00
- php{{ php_version }}-gd
- php{{ php_version }}-imap
- php{{ php_version }}-ldap
- php{{ php_version }}-odbc
# - php{{ php_version }}-xml
2017-05-27 23:10:45 +00:00
- php{{ php_version }}-xmlrpc
when: is_debuntu
2017-05-27 18:09:50 +00:00
tags:
- download
2018-07-17 19:07:39 +00:00
- name: php-xml (ubuntu or debian-9)
2017-12-08 11:35:49 +00:00
package:
name: "php{{ php_version }}-xml"
state: present
when: is_ubuntu or is_debian_9
2018-07-17 19:07:39 +00:00
- name: php-xml (debian-8)
2017-12-08 11:35:49 +00:00
package:
name: "php-xml-parser"
state: present
when: is_debian_8
2017-11-08 06:22:50 +00:00
- name: Install MySQL (OS's other than debuntu)
2017-12-08 11:35:49 +00:00
package:
name: "{{ item }}"
state: present
2017-05-27 18:09:50 +00:00
with_items:
- MySQL-python
- mysql
- php
- php-mysql
- php-pear
- php-gd
- php-imap
- php-ldap
- php-odbc
- php-xml
- php-xmlrpc
2017-05-27 23:10:45 +00:00
when: not is_debuntu
2017-05-27 18:09:50 +00:00
tags:
- download
- include_tasks: centos.yml
2017-05-27 18:09:50 +00:00
when: ansible_distribution == "CentOS"
tags:
- download
- include_tasks: fedora.yml
2017-05-27 18:09:50 +00:00
when: ansible_distribution == "Fedora"
tags:
- download
# Name of mysql service varies by OS so softcoded in 1-prep
- name: Start the MySQL service
2017-12-08 11:35:49 +00:00
service:
name: "{{ mysql_service }}"
state: started
2017-05-27 18:09:50 +00:00
- name: Enable the MySQL service
2017-12-08 11:35:49 +00:00
service:
name: "{{ mysql_service }}"
enabled: yes
2017-05-27 18:09:50 +00:00
when: mysql_enabled
# 'localhost' needs to be the last item for idempotency, see
# http://ansible.cc/docs/modules.html#mysql-user
# unfortunately it still doesn't work
2017-10-27 13:37:00 +00:00
- name: Update MySQL root password for localhost root accounts
2017-12-08 11:35:49 +00:00
mysql_user:
name: root
host: "{{ item }}"
password: "{{ mysql_root_password }}"
priv: "*.*:ALL,GRANT"
2017-05-27 18:09:50 +00:00
with_items:
- localhost
when: mysql_enabled
2017-10-27 13:37:00 +00:00
- name: Copy .my.cnf file with root password credentials
2017-12-08 11:35:49 +00:00
template:
src: my.cnf.j2
dest: /root/.my.cnf
owner: root
mode: 0600
2017-05-27 18:09:50 +00:00
when: mysql_enabled
- name: Update MySQL root password for all remaining root accounts
2017-12-08 11:35:49 +00:00
mysql_user:
name: root
host: "{{ item }}"
password: "{{ mysql_root_password }}"
priv: "*.*:ALL,GRANT"
2017-05-27 18:09:50 +00:00
with_items:
# - "{{ iiab_hostname }}.{{ iiab_domain }}"
2017-05-27 18:09:50 +00:00
- 127.0.0.1
- ::1
when: mysql_enabled
2017-10-27 13:37:00 +00:00
- name: Delete anonymous MySQL server user for {{ ansible_hostname }}
2017-12-08 11:35:49 +00:00
mysql_user:
user: ""
host: "{{ ansible_hostname }}"
state: absent
2017-05-27 18:09:50 +00:00
when: mysql_enabled
2017-10-27 13:37:00 +00:00
- name: Delete anonymous MySQL server user for localhost
2017-12-08 11:35:49 +00:00
mysql_user:
user: ""
state: absent
2017-05-27 18:09:50 +00:00
when: mysql_enabled
2017-10-27 13:37:00 +00:00
- name: Remove the MySQL test database
2017-12-08 11:35:49 +00:00
mysql_db:
db: test
state: absent
2017-05-27 18:09:50 +00:00
when: mysql_enabled
# we had to start mysql in order to configure it, now turn if off if not enabled
2017-10-01 22:48:50 +00:00
- name: Provisionally Disable the MySQL service
2017-12-08 11:35:49 +00:00
service:
name: "{{ mysql_service }}"
enabled: no
state: stopped
2017-05-27 18:09:50 +00:00
when: not mysql_enabled
2017-12-08 11:35:49 +00:00
- name: Add 'mysql' to list of services at /etc/iiab/iiab.ini
ini_file:
dest: "{{ service_filelist }}"
section: mysql
option: "{{ item.option }}"
value: "{{ item.value }}"
2017-05-27 18:09:50 +00:00
with_items:
2017-12-08 11:35:49 +00:00
- option: name
value: MySQL
- option: description
value: '"MySQL is a widely used free and open source (GPLv2) database, offered by most web hosting services, on a diversity of platforms."'
- option: enabled
value: "{{ mysql_enabled }}"