Setup: Restore from backup now determined by file present
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Tobias Manske 2023-09-06 18:30:28 +02:00
parent b9c38e4674
commit f887ca2fae
Signed by: tobias
GPG Key ID: 9164B527694A0709

View File

@ -26,11 +26,15 @@
name: "{{ backup.known_hosts.name }}" name: "{{ backup.known_hosts.name }}"
key: "{{ backup.known_hosts.key }}" key: "{{ backup.known_hosts.key }}"
- name: Restore from Backup - name: Restore from Backup
hosts: unprovisioned hosts: backup
become: true become: true
become_user: root become_user: root
gather_facts: true gather_facts: true
tasks: tasks:
- name: Check if restore is needed
ansible.builtin.stat:
path: "/etc/setup_complete"
register: setup_complete
- block: - block:
- name: Install restore script - name: Install restore script
ansible.builtin.template: ansible.builtin.template:
@ -38,7 +42,8 @@
dest: /root/restore.sh dest: /root/restore.sh
mode: '0700' mode: '0700'
owner: root owner: root
- ansible.builtin.file: - name: Setup ssh directory
ansible.builtin.file:
path: /root/.ssh path: /root/.ssh
owner: root owner: root
state: directory state: directory
@ -64,10 +69,14 @@
ansible.builtin.file: ansible.builtin.file:
path: /root/restore.sh path: /root/restore.sh
state: absent state: absent
- set_fact: - name: Mark setup as complete
provisioned: true ansible.builtin.file:
cacheable: true path: "/etc/setup_complete"
when: ansible_facts.provisioned is undefined state: touch
owner: root
group: root
mode: 0600
when: not setup_complete.stat.exists
- name: Setup Registry credentials - name: Setup Registry credentials
hosts: all hosts: all
tasks: tasks:
@ -81,6 +90,38 @@
dest: /home/core/.docker/config.json dest: /home/core/.docker/config.json
mode: '0600' mode: '0600'
owner: core 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 - name: Setup internal networks
hosts: all hosts: all
tasks: tasks:
@ -159,30 +200,4 @@
enabled: true enabled: true
masked: false masked: false
daemon_reload: true 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