From fe708539f0c8b773f0e49be16df044864aded13f Mon Sep 17 00:00:00 2001 From: Egon Rijpkema Date: Wed, 18 Oct 2017 17:11:23 +0200 Subject: [PATCH] made environment file for the service. I am unable to reproduce systemctl set-environment to work as advertized. --- roles/mariadb/tasks/main.yml | 15 +++++++++++++-- roles/mariadb/templates/mysql.service | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/roles/mariadb/tasks/main.yml b/roles/mariadb/tasks/main.yml index 9a5c8fe..db96047 100644 --- a/roles/mariadb/tasks/main.yml +++ b/roles/mariadb/tasks/main.yml @@ -41,9 +41,17 @@ - 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 - name: Initialize a new cluster. - command: systemctl set-environment _WSREP_NEW_CLUSTER='--wsrep-new-cluster' + lineinfile: + path: /srv/mariadb/systemd_environment + line: _WSREP_NEW_CLUSTER='--wsrep-new-cluster' when: groups['databases'] | length >= 3 and ansible_hostname == hostname_node0 - name: make sure service is started @@ -52,4 +60,7 @@ state: started - name: Prevent cluster re-initialization - command: systemctl set-environment _WSREP_NEW_CLUSTER='' + lineinfile: + path: /srv/mariadb/systemd_environment + state: absent + line: _WSREP_NEW_CLUSTER='--wsrep-new-cluster' diff --git a/roles/mariadb/templates/mysql.service b/roles/mariadb/templates/mysql.service index 4a5fdca..25f7360 100644 --- a/roles/mariadb/templates/mysql.service +++ b/roles/mariadb/templates/mysql.service @@ -6,6 +6,7 @@ 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