mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 19:52:06 +00:00
187 lines
5.7 KiB
YAML
187 lines
5.7 KiB
YAML
- name: 'Install MySQL packages: mariadb-server, mariadb-client, python-mysqldb and 8 php packages (debuntu)'
|
|
package:
|
|
name:
|
|
- mariadb-server
|
|
- mariadb-client
|
|
- python-mysqldb
|
|
- php{{ php_version }}
|
|
- php{{ php_version }}-mysql
|
|
- php-pear
|
|
- php{{ php_version }}-gd
|
|
- php{{ php_version }}-imap
|
|
- php{{ php_version }}-ldap
|
|
- php{{ php_version }}-odbc
|
|
#- php{{ php_version }}-xml
|
|
- php{{ php_version }}-xmlrpc
|
|
state: present
|
|
when: is_debuntu | bool
|
|
tags:
|
|
- download
|
|
|
|
- name: Install php{{ php_version }}-xml (ubuntu or debian 9+)
|
|
package:
|
|
name: "php{{ php_version }}-xml"
|
|
state: present
|
|
when: is_ubuntu or (is_debian and not is_debian_8)
|
|
|
|
- name: Install php-xml-parser (debian-8)
|
|
package:
|
|
name: php-xml-parser
|
|
state: present
|
|
when: is_debian_8 | bool
|
|
|
|
- name: "Install packages: mysql, MySQL-python and 9 php packages (OS's other than debuntu)"
|
|
package:
|
|
name:
|
|
- MySQL-python
|
|
- mysql
|
|
- php
|
|
- php-mysql
|
|
- php-pear
|
|
- php-gd
|
|
- php-imap
|
|
- php-ldap
|
|
- php-odbc
|
|
- php-xml
|
|
- php-xmlrpc
|
|
state: present
|
|
when: not is_debuntu
|
|
tags:
|
|
- download
|
|
|
|
- include_tasks: centos.yml
|
|
when: ansible_distribution == "CentOS"
|
|
tags:
|
|
- download
|
|
|
|
- include_tasks: fedora.yml
|
|
when: ansible_distribution == "Fedora"
|
|
tags:
|
|
- download
|
|
|
|
# 2019-07-03: @jvonau @holta doubled the default boot timeout from 90s to 180s
|
|
# for slow machines like this Ubuntu 18.04.2 VM:
|
|
# https://github.com/iiab/iiab/issues/1802
|
|
# https://mariadb.com/kb/en/library/what-to-do-if-mariadb-doesnt-start/#systemd
|
|
|
|
- name: Check if /lib/systemd/system/mariadb.service exists
|
|
stat:
|
|
path: /lib/systemd/system/mariadb.service
|
|
register: mariadb_unit_file
|
|
|
|
- name: Copy pkg's /lib/systemd/system/mariadb.service to /etc/systemd/system/ to be customized
|
|
copy:
|
|
force: yes
|
|
src: /lib/systemd/system/mariadb.service
|
|
dest: /etc/systemd/system/
|
|
when: mariadb_unit_file.stat.exists
|
|
|
|
- name: Symlink /etc/systemd/system/mysql.service -> /etc/systemd/system/mariadb.service
|
|
file:
|
|
state: link
|
|
force: yes
|
|
src: /etc/systemd/system/mariadb.service
|
|
path: /etc/systemd/system/mysql.service
|
|
when: mariadb_unit_file.stat.exists
|
|
|
|
- name: Symlink /etc/systemd/system/mysqld.service -> /etc/systemd/system/mariadb.service
|
|
file:
|
|
state: link
|
|
force: yes
|
|
src: /etc/systemd/system/mariadb.service
|
|
path: /etc/systemd/system/mysqld.service
|
|
when: mariadb_unit_file.stat.exists
|
|
|
|
- name: Set systemd boot timeout to 180 seconds for slow machines, in /etc/systemd/system/mariadb.service
|
|
lineinfile:
|
|
backup: yes
|
|
path: /etc/systemd/system/mariadb.service
|
|
insertafter: '^\[Service\]$'
|
|
regexp: '^TimeoutStartSec='
|
|
line: "TimeoutStartSec=180"
|
|
# LINE BELOW WOULD BE NICE...BUT ANSIBLE POLLUTES EACH TIME :(
|
|
# Hence Ansible's 'blockinfile', but this pollutes config files in its own
|
|
# way. Still, it might be nec in future, so config files are *READABLE* !
|
|
#line: "\n# 2019-07-03: @jvonau @holta doubled the default boot timeout from 90s to 180s\n# for slow machines like this Ubuntu 18.04.2 VM:\n# https://github.com/iiab/iiab/issues/1802\n# https://mariadb.com/kb/en/library/what-to-do-if-mariadb-doesnt-start/#systemd\nTimeoutStartSec=180"
|
|
when: mariadb_unit_file.stat.exists
|
|
|
|
# Name of MySQL service varies by OS, so hardcoded in /opt/iiab/iiab/vars/<OS>.yml (formerly in roles/0-init/tasks/main.yml)
|
|
- name: Enable & Start MySQL systemd service ({{ mysql_service }}) if mysql_enabled
|
|
systemd:
|
|
name: "{{ mysql_service }}"
|
|
daemon_reload: yes
|
|
state: restarted
|
|
enabled: yes
|
|
when: mysql_enabled | bool
|
|
|
|
# 'localhost' needs to be the last item for idempotency, see
|
|
# http://ansible.cc/docs/modules.html#mysql-user
|
|
# unfortunately it still doesn't work
|
|
- name: Update MySQL root password for localhost root accounts, if mysql_enabled
|
|
mysql_user:
|
|
name: root
|
|
host: localhost
|
|
password: "{{ mysql_root_password }}"
|
|
priv: "*.*:ALL,GRANT"
|
|
when: mysql_enabled | bool
|
|
|
|
- name: Install .my.cnf file from template, with root password credentials, if mysql_enabled
|
|
template:
|
|
src: my.cnf.j2
|
|
dest: /root/.my.cnf
|
|
owner: root
|
|
mode: 0600
|
|
when: mysql_enabled | bool
|
|
|
|
- name: Update MySQL root password for all remaining root accounts (127.0.0.1, ::1) if mysql_enabled
|
|
mysql_user:
|
|
name: root
|
|
host: "{{ item }}"
|
|
password: "{{ mysql_root_password }}"
|
|
priv: "*.*:ALL,GRANT"
|
|
with_items:
|
|
#- "{{ iiab_hostname }}.{{ iiab_domain }}"
|
|
- 127.0.0.1
|
|
- ::1
|
|
when: mysql_enabled | bool
|
|
|
|
- name: Delete anonymous MySQL server user for {{ ansible_hostname }}, if mysql_enabled
|
|
mysql_user:
|
|
user: ""
|
|
host: "{{ ansible_hostname }}"
|
|
state: absent
|
|
when: mysql_enabled | bool
|
|
|
|
- name: Delete anonymous MySQL server user for localhost, if mysql_enabled
|
|
mysql_user:
|
|
user: ""
|
|
state: absent
|
|
when: mysql_enabled | bool
|
|
|
|
- name: Remove the MySQL 'test' database, if mysql_enabled
|
|
mysql_db:
|
|
db: test
|
|
state: absent
|
|
when: mysql_enabled | bool
|
|
|
|
# we had to start mysql in order to configure it, now turn if off if not enabled
|
|
- name: Config is done but now DISABLE MySQL service, if not mysql_enabled
|
|
systemd:
|
|
name: "{{ mysql_service }}"
|
|
enabled: no
|
|
state: stopped
|
|
when: not mysql_enabled
|
|
|
|
- name: Add 'mysql' variable values to {{ iiab_ini_file }}
|
|
ini_file:
|
|
path: "{{ iiab_ini_file }}"
|
|
section: mysql
|
|
option: "{{ item.option }}"
|
|
value: "{{ item.value }}"
|
|
with_items:
|
|
- 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 }}"
|