From f887ca2fae1d1c6cc5986c546a161800ebf8aea4 Mon Sep 17 00:00:00 2001 From: Tobias Manske Date: Wed, 6 Sep 2023 18:30:28 +0200 Subject: [PATCH] Setup: Restore from backup now determined by file present --- coreos-config/plays/common.yaml | 79 ++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 32 deletions(-) diff --git a/coreos-config/plays/common.yaml b/coreos-config/plays/common.yaml index e73a68e..4311e93 100644 --- a/coreos-config/plays/common.yaml +++ b/coreos-config/plays/common.yaml @@ -26,11 +26,15 @@ name: "{{ backup.known_hosts.name }}" key: "{{ backup.known_hosts.key }}" - name: Restore from Backup - hosts: unprovisioned + hosts: backup become: true become_user: root gather_facts: true tasks: + - name: Check if restore is needed + ansible.builtin.stat: + path: "/etc/setup_complete" + register: setup_complete - block: - name: Install restore script ansible.builtin.template: @@ -38,7 +42,8 @@ dest: /root/restore.sh mode: '0700' owner: root - - ansible.builtin.file: + - name: Setup ssh directory + ansible.builtin.file: path: /root/.ssh owner: root state: directory @@ -64,10 +69,14 @@ ansible.builtin.file: path: /root/restore.sh state: absent - - set_fact: - provisioned: true - cacheable: true - when: ansible_facts.provisioned is undefined + - name: Mark setup as complete + ansible.builtin.file: + path: "/etc/setup_complete" + state: touch + owner: root + group: root + mode: 0600 + when: not setup_complete.stat.exists - name: Setup Registry credentials hosts: all tasks: @@ -81,6 +90,38 @@ dest: /home/core/.docker/config.json mode: '0600' owner: core +- name: Setup Docker Config + hosts: all + become: true + become_user: root + tasks: + - name: Template Config + ansible.builtin.template: + src: "docker-daemon.json.j2" + dest: /etc/docker/daemon.json + owner: root + group: root + mode: '0600' + notify: Restart Docker + - name: Setup default ulimts + ansible.builtin.lineinfile: + path: /etc/sysconfig/docker + search_string: '--default-ulimit nofile=' + line: ' --default-ulimit nofile=4096:4096 \' + notify: Restart Docker + - name: Remove log-driver from sysconfig + ansible.builtin.lineinfile: + path: /etc/sysconfig/docker + search_string: '--log-driver=' + state: absent + notify: Restart Docker + - name: Restart Docker if necessary + meta: flush_handlers + handlers: + - name: Restart Docker + ansible.builtin.systemd: + state: restarted + name: docker.service - name: Setup internal networks hosts: all tasks: @@ -159,30 +200,4 @@ enabled: true masked: false daemon_reload: true -- name: Setup Docker Config - hosts: all - become: true - become_user: root - tasks: - - name: Template Config - ansible.builtin.template: - src: "docker-daemon.json.j2" - dest: /etc/docker/daemon.json - owner: root - group: root - mode: '0600' - notify: Restart Docker - - name: Setup default ulimts - ansible.builtin.lineinfile: - path: /etc/sysconfig/docker - search_string: '--default-ulimit nofile=' - line: ' --default-ulimit nofile=4096:4096 \' - notify: Restart Docker - - name: Restart Docker if necessary - meta: flush_handlers - handlers: - - name: Restart Docker - ansible.builtin.systemd: - state: restarted - name: docker.service