diff --git a/roles/backupscript/files/backup-script.service b/roles/backupscript/files/backup-script.service new file mode 100644 index 0000000..c792c91 --- /dev/null +++ b/roles/backupscript/files/backup-script.service @@ -0,0 +1,9 @@ +[Unit] +Description=Backup application data + +[Service] +Type=simple +ExecStart=/usr/bin/bash /opt/backupscript.sh + +[Install] +WantedBy=backup.target \ No newline at end of file diff --git a/roles/backupscript/files/backup.target b/roles/backupscript/files/backup.target new file mode 100644 index 0000000..7d6e903 --- /dev/null +++ b/roles/backupscript/files/backup.target @@ -0,0 +1,5 @@ +[Unit] +Description=Script based backup for VMs + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/roles/backupscript/files/backup.timer b/roles/backupscript/files/backup.timer new file mode 100644 index 0000000..689a800 --- /dev/null +++ b/roles/backupscript/files/backup.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Backup VMs + +[Timer] +OnBootSec=10min +OnCalendar=Sun *-*-* 00:00:00 +Unit=backup.target + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/roles/backupscript/tasks/backupscript.yaml b/roles/backupscript/tasks/backupscript.yaml new file mode 100644 index 0000000..fa8b1b9 --- /dev/null +++ b/roles/backupscript/tasks/backupscript.yaml @@ -0,0 +1,47 @@ +--- +- name: Copy backupscript to target + copy: + src: "{{ backupscript_name }}" + dest: /opt/backupscript.sh + mode: 700 + owner: service-user + +- name: Copy backup-script.service to target + copy: + src: backup-script.service + dest: /usr/lib/systemd/system/backup-script.service + mode: 644 + owner: service-user + +- name: Copy backup.target to target + copy: + src: backup.target + dest: /usr/lib/systemd/system/backup.target + mode: 644 + owner: service-user + +- name: Copy backup.timer to target + copy: + src: backup.timer + dest: /usr/lib/systemd/system/backup.timer + mode: 644 + owner: service-user + +- name: Enable backup-script.service and reload systemd daemon + when: ansible_service_mgr == "systemd" + ansible.builtin.systemd: + enabled: yes + daemon_reload: yes + name: backup-script.service + +- name: Enable backup.target + when: ansible_service_mgr == "systemd" + ansible.builtin.systemd: + enabled: yes + name: backup.target + +- name: Enable backup.timer + when: ansible_service_mgr == "systemd" + ansible.builtin.systemd: + enabled: yes + name: backup.timer diff --git a/roles/docker/tasks/docker.yaml b/roles/docker/tasks/docker.yaml index 135ff5c..b4c69af 100644 --- a/roles/docker/tasks/docker.yaml +++ b/roles/docker/tasks/docker.yaml @@ -19,3 +19,10 @@ name: docker state: restarted enabled: yes + +- name: Copy docker-compose.yml to target + copy: + src: "{{ dockercompose_yml_name }}" + dest: /home/service-user/docker-compose.yml + mode: 600 + owner: service-user diff --git a/roles/mountpoint/tasks/mountpoint.yaml b/roles/mountpoint/tasks/mountpoint.yaml new file mode 100644 index 0000000..bef27ae --- /dev/null +++ b/roles/mountpoint/tasks/mountpoint.yaml @@ -0,0 +1,8 @@ +--- +- name: Mount up device by UUID + ansible.posix.mount: + path: "{{ mountpoint_path }}" + src: "UUID={{ mountpoint_uuid }}" + fstype: "{{ mountpoint_fstype }}" + opts: "{{ mountpoint_opts }}" + state: mounted