From 5e1e20e93e6209afee258a433bf19145036d0adb Mon Sep 17 00:00:00 2001 From: "mac@lowang" Date: Wed, 26 Sep 2018 12:17:44 +0800 Subject: [PATCH 1/2] fix error if no cron job in first deployment --- playbooks/roles/cronjob/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/roles/cronjob/tasks/main.yml b/playbooks/roles/cronjob/tasks/main.yml index 11c40c2..bb21cc0 100644 --- a/playbooks/roles/cronjob/tasks/main.yml +++ b/playbooks/roles/cronjob/tasks/main.yml @@ -1,5 +1,5 @@ - name: backup old crontab - shell: crontab -l > ~/backup.cron + shell: crontab -l > ~/backup.cron 2> /dev/null || true - name: copy image-clean script copy: From d7341f14031539a4a7522b171079a6104ff4cdcf Mon Sep 17 00:00:00 2001 From: "mac@lowang" Date: Tue, 30 Oct 2018 10:59:57 +0800 Subject: [PATCH 2/2] restart swarm-agent on failure --- playbooks/roles/swarm-manage/templates/swarm-agent.service.j2 | 1 + 1 file changed, 1 insertion(+) diff --git a/playbooks/roles/swarm-manage/templates/swarm-agent.service.j2 b/playbooks/roles/swarm-manage/templates/swarm-agent.service.j2 index 953d05e..06ba5a2 100644 --- a/playbooks/roles/swarm-manage/templates/swarm-agent.service.j2 +++ b/playbooks/roles/swarm-manage/templates/swarm-agent.service.j2 @@ -12,6 +12,7 @@ ExecStart=/usr/bin/docker run \ --addr={{ node_ip }}:{{ docker_port }} \ etcd://{{ node_ip }}:{{ etcd_client_port }}/lain/swarm ExecStop=/bin/bash -c '/usr/bin/docker stop %n || true' +Restart=on-failure [Install] WantedBy=multi-user.target