Reverted to updating init file by ansible.
entrypoint.sh of the mariadb container seems unable to cope when a blank variable is passed by systemd.
This commit is contained in:
parent
fe708539f0
commit
cc9d780fbc
@ -5,14 +5,6 @@
|
||||
file: ../../secrets.yml
|
||||
name: secrets
|
||||
|
||||
- name: install service file.
|
||||
template:
|
||||
src: templates/mysql.service
|
||||
dest: /etc/systemd/system/mysql.service
|
||||
mode: 644
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: make mariadb settings volume
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
@ -36,31 +28,44 @@
|
||||
mode: 660
|
||||
when: groups['databases'] | length >= 3
|
||||
|
||||
- command: systemctl daemon-reload
|
||||
|
||||
- name: start service at boot.
|
||||
command: systemctl reenable mysql.service
|
||||
|
||||
- name: create environment file for systemd
|
||||
copy:
|
||||
content: ""
|
||||
dest: /srv/mariadb/systemd_environment
|
||||
mode: 0644
|
||||
|
||||
# This mimics galera_new_cluster.sh
|
||||
# This mimics galera_new_cluster.sh
|
||||
- name: Initialize a new cluster.
|
||||
lineinfile:
|
||||
path: /srv/mariadb/systemd_environment
|
||||
line: _WSREP_NEW_CLUSTER='--wsrep-new-cluster'
|
||||
block:
|
||||
- set_fact:
|
||||
mariadb_args: "--wsrep-new-cluster"
|
||||
|
||||
- template:
|
||||
src: templates/mysql.service
|
||||
dest: /etc/systemd/system/mysql.service
|
||||
mode: 644
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- command: systemctl daemon-reload
|
||||
|
||||
- systemd:
|
||||
name: mysql.service
|
||||
state: started
|
||||
|
||||
when: groups['databases'] | length >= 3 and ansible_hostname == hostname_node0
|
||||
|
||||
- name: install service file.
|
||||
block:
|
||||
- set_fact:
|
||||
mariadb_args: ""
|
||||
- template:
|
||||
src: templates/mysql.service
|
||||
dest: /etc/systemd/system/mysql.service
|
||||
mode: 644
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- command: systemctl daemon-reload
|
||||
|
||||
- name: make sure service is started
|
||||
systemd:
|
||||
name: mysql.service
|
||||
state: started
|
||||
|
||||
- name: Prevent cluster re-initialization
|
||||
lineinfile:
|
||||
path: /srv/mariadb/systemd_environment
|
||||
state: absent
|
||||
line: _WSREP_NEW_CLUSTER='--wsrep-new-cluster'
|
||||
- name: start service at boot.
|
||||
command: systemctl reenable mysql.service
|
||||
|
@ -6,7 +6,6 @@ Requires=docker.service
|
||||
[Service]
|
||||
TimeoutStartSec=0
|
||||
Restart=always
|
||||
EnvironmentFile=/srv/mariadb/systemd_environment
|
||||
ExecStartPre=-/usr/bin/docker kill %n || /bin/true
|
||||
ExecStartPre=-/usr/bin/docker rm %n
|
||||
ExecStartPre=/usr/bin/docker pull mariadb:10.2
|
||||
@ -14,8 +13,7 @@ ExecStart=/usr/bin/docker run --name %n \
|
||||
-p 3306:3306 -p 4567:4567 -p 4568:4568 -p 4444:4444 \
|
||||
-v /srv/mariadb/lib/mysql:/var/lib/mysql \
|
||||
-v /srv/mariadb/etc/mysql/conf.d:/etc/mysql/conf.d \
|
||||
-e MYSQL_ROOT_PASSWORD={{ secrets['MYSQL_ROOT_PASSWORD'] }} mariadb:10.2 \
|
||||
${MYSQLD_OPTS} ${_WSREP_NEW_CLUSTER} ${_WSREP_START_POSITION}
|
||||
-e MYSQL_ROOT_PASSWORD={{ secrets['MYSQL_ROOT_PASSWORD'] }} mariadb:10.2 {{ mariadb_args }}
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
Loading…
Reference in New Issue
Block a user