diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2019-05-15 09:00:49 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2019-05-15 09:01:30 +0200 |
commit | 4bd33c6a46f57f8a830042795cfaa68ef91963a9 (patch) | |
tree | 50aba86781f2725ddadeeb52cc5d7b4853da6eee /ansible/roles | |
parent | 9846c2636282e1a62b53b34a54854423e7d6dbac (diff) | |
download | infra-4bd33c6a46f57f8a830042795cfaa68ef91963a9.tar.gz infra-4bd33c6a46f57f8a830042795cfaa68ef91963a9.tar.bz2 infra-4bd33c6a46f57f8a830042795cfaa68ef91963a9.tar.xz infra-4bd33c6a46f57f8a830042795cfaa68ef91963a9.zip |
o Removing old borg code.
Diffstat (limited to 'ansible/roles')
-rw-r--r-- | ansible/roles/borg-client/defaults/main.yml | 1 | ||||
-rw-r--r-- | ansible/roles/borg-client/handlers/main.yml | 10 | ||||
-rw-r--r-- | ansible/roles/borg-client/tasks/borg-client.yml | 115 | ||||
-rw-r--r-- | ansible/roles/borg-client/tasks/main.yml | 3 | ||||
-rw-r--r-- | ansible/roles/borg-client/templates/bin/create-backup | 26 | ||||
-rw-r--r-- | ansible/roles/borg-client/templates/bin/create-backup-send-email | 16 | ||||
-rw-r--r-- | ansible/roles/borg-server/defaults/main.yml | 2 | ||||
-rw-r--r-- | ansible/roles/borg-server/tasks/borg-server.yml | 30 | ||||
-rw-r--r-- | ansible/roles/borg-server/tasks/main.yml | 26 |
9 files changed, 0 insertions, 229 deletions
diff --git a/ansible/roles/borg-client/defaults/main.yml b/ansible/roles/borg-client/defaults/main.yml deleted file mode 100644 index b450b4d..0000000 --- a/ansible/roles/borg-client/defaults/main.yml +++ /dev/null @@ -1 +0,0 @@ -ssh_key: /etc/borg/id_ed25519 diff --git a/ansible/roles/borg-client/handlers/main.yml b/ansible/roles/borg-client/handlers/main.yml deleted file mode 100644 index 2b4b222..0000000 --- a/ansible/roles/borg-client/handlers/main.yml +++ /dev/null @@ -1,10 +0,0 @@ -- name: systemctl daemon-reload - become: yes - systemd: - daemon_reload: true - -- name: service start create-backup.timer - become: yes - service: - name: create-backup.timer - state: restarted diff --git a/ansible/roles/borg-client/tasks/borg-client.yml b/ansible/roles/borg-client/tasks/borg-client.yml deleted file mode 100644 index 92aba57..0000000 --- a/ansible/roles/borg-client/tasks/borg-client.yml +++ /dev/null @@ -1,115 +0,0 @@ ---- -- name: packages - tags: packages - apt: - name: "{{ items }}" - install_recommends: no - vars: - items: - - borgbackup - -- name: mkdir /etc/borg - file: - path: /etc/borg - state: directory - mode: u=rwx,go= - -- name: Generate SSH keys - command: ssh-keygen -t ed25519 -N "" -f "{{ ssh_key }}" -C "for borg @ {{ ansible_hostname }}" - args: - creates: "{{ ssh_key }}" - register: ssh_key_generated - -- when: ssh_key_generated.changed - fetch: - src: "{{ ssh_key }}.pub" - dest: "files" - -- name: /etc/borg/env - copy: - dest: /etc/borg/env - mode: u=r,go= - content: | - BORG_REPO="borg@{{ borg_client__server }}:{{ ansible_hostname }}" - BORG_RSH="ssh -i {{ ssh_key}}" - -# " - -- name: /etc/borg/excludes - when: borg_client__state == "absent" - file: - path: /etc/borg/excludes - state: absent - -- name: /etc/borg/excludes - when: borg_client__state == "present" - copy: - dest: /etc/borg/excludes - content: | - /proc - /dev - /sys - /run - -- name: /etc/borg/patterns - copy: - dest: /etc/borg/patterns - content: | - P sh - R / - {% for item in borg_client__patterns %} - {{ item }} - {% endfor %} - -- name: /usr/local/bin/create-backup - template: - dest: "/usr/local/bin/{{ item }}" - src: "bin/{{ item }}" - mode: u=rwx,go=rx - owner: root - group: root - with_items: - - create-backup - - create-backup-send-email - -- name: /etc/systemd/system/create-backup.service - copy: - dest: /etc/systemd/system/create-backup.service - content: | - [Unit] - Description=Create backup - # After=network-online.target - # Wants=network-online.target - - [Service] - Type=oneshot - WorkingDirectory=/ - ExecStart=-/usr/local/bin/create-backup - ExecStartPost=-/usr/local/bin/create-backup-send-email root@trygvis.io - SuccessExitStatus=0 1 - notify: - - systemctl daemon-reload - -- name: /etc/systemd/system/create-backup.timer - copy: - dest: /etc/systemd/system/create-backup.timer - content: | - [Unit] - Description=Create backup timer - - [Timer] - OnCalendar=05:24 - - [Install] - WantedBy=timers.target - notify: - - systemctl daemon-reload - - service start create-backup.timer - -# TODO: remove -- file: - path: /etc/systemd/system/create-backup-send-email.service - state: absent - register: create_backup_send_email_service - notify: - - systemctl daemon-reload diff --git a/ansible/roles/borg-client/tasks/main.yml b/ansible/roles/borg-client/tasks/main.yml deleted file mode 100644 index 1afab33..0000000 --- a/ansible/roles/borg-client/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -- become: yes - tags: borg-client - import_tasks: borg-client.yml diff --git a/ansible/roles/borg-client/templates/bin/create-backup b/ansible/roles/borg-client/templates/bin/create-backup deleted file mode 100644 index 8d842ef..0000000 --- a/ansible/roles/borg-client/templates/bin/create-backup +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -cd / - -. /etc/borg/env -export BORG_REPO -export BORG_RSH - -cmd=() -cmd+=(borg create) -cmd+=(--stats) -#cmd+=(--progress) -#cmd+=(--json) -cmd+=(--exclude-from=/etc/borg/excludes) -cmd+=(--patterns-from=/etc/borg/patterns) -cmd+=(::'{hostname}-{now:%Y-%m-%dT%H:%M:%S}') - -echo BORG_RSH=$BORG_RSH -echo BORG_REPO=$BORG_REPO - -set -x -time "${cmd[@]}" - -borg info --last 1 diff --git a/ansible/roles/borg-client/templates/bin/create-backup-send-email b/ansible/roles/borg-client/templates/bin/create-backup-send-email deleted file mode 100644 index 7665571..0000000 --- a/ansible/roles/borg-client/templates/bin/create-backup-send-email +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -cd / - -/usr/sbin/sendmail -t <<ERRMAIL -To: $1 -From: systemd <root@$HOSTNAME> -Subject: Backup @ $HOSTNAME -Content-Transfer-Encoding: 8bit -Content-Type: text/plain; charset=UTF-8 - -$(systemctl status --full 2>&1) -$(journalctl --since today --unit create-backup 2>&1) -ERRMAIL diff --git a/ansible/roles/borg-server/defaults/main.yml b/ansible/roles/borg-server/defaults/main.yml deleted file mode 100644 index 8d25395..0000000 --- a/ansible/roles/borg-server/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -borg_server__home: /borg -borg_server__shell: /bin/bash diff --git a/ansible/roles/borg-server/tasks/borg-server.yml b/ansible/roles/borg-server/tasks/borg-server.yml deleted file mode 100644 index 253aa4a..0000000 --- a/ansible/roles/borg-server/tasks/borg-server.yml +++ /dev/null @@ -1,30 +0,0 @@ -- debug: var=groups[borg_server__clients_ansible_group] - -- become: yes - become_user: borg - vars: - clients: "{{ groups[borg_server__clients_ansible_group] }}" - block: - - name: mkdir repos - file: - path: "{{ borg_server__home }}/repos" - state: directory - mode: u=rwx,go= - - - name: mkdir repos/{{ item.key }} - with_items: "{{ clients }}" - command: borg init "{{ item }}" -e none - args: - creates: "{{ borg_server__home }}/repos/{{ item }}" - chdir: "{{ borg_server__home }}/repos" - - - name: authorized_keys - with_items: "{{ clients }}" - vars: - client: "{{hostvars[ansible_hostname]['borg_' + item]}}" - authorized_key: - user: borg - state: "{{ client.state }}" - key: "{{ lookup('file', item + '/etc/borg/id_ed25519.pub') }}" - path: "{{ borg_server__home }}/.ssh/authorized_keys" - key_options: "command=\"cd {{ borg_server__home }}/repos; borg serve --append-only --restrict-to-path {{ borg_server__home }}/repos/{{ item }}\",no-port-forwarding,no-X11-forwarding,no-pty,no-agent-forwarding,no-user-rc" diff --git a/ansible/roles/borg-server/tasks/main.yml b/ansible/roles/borg-server/tasks/main.yml deleted file mode 100644 index c975803..0000000 --- a/ansible/roles/borg-server/tasks/main.yml +++ /dev/null @@ -1,26 +0,0 @@ -- name: packages - tags: borg-server - become: yes - apt: - name: "{{ items }}" - install_recommends: no - vars: - items: - - borgbackup - -- name: Create unix group - become: yes - group: - name: borg - system: yes - -- name: Create unix user - become: yes - user: - name: borg - system: yes - group: borg - shell: "{{ borg_server__shell }}" - home: "{{ borg_server__home }}" - -- import_tasks: borg-server.yml |