aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-08-04 12:39:53 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-08-04 12:41:21 +0200
commitba72e84010822fd3cc2774db9d77ed2f917a1929 (patch)
treee663a97009a534f583d795fcab2dd90c9a2a0348
parentimport letsencrypt role (diff)
downloadinfra-ansible-ba72e84010822fd3cc2774db9d77ed2f917a1929.tar.gz
infra-ansible-ba72e84010822fd3cc2774db9d77ed2f917a1929.zip
import a couple more roles
-rw-r--r--roles/digitalocean_volume/defaults/main.yml1
-rw-r--r--roles/digitalocean_volume/tasks/main.yml12
-rw-r--r--roles/systemd_requires_mount/tasks/main.yml22
3 files changed, 35 insertions, 0 deletions
diff --git a/roles/digitalocean_volume/defaults/main.yml b/roles/digitalocean_volume/defaults/main.yml
new file mode 100644
index 0000000..dceb85d
--- /dev/null
+++ b/roles/digitalocean_volume/defaults/main.yml
@@ -0,0 +1 @@
+volume_fs: ext4
diff --git a/roles/digitalocean_volume/tasks/main.yml b/roles/digitalocean_volume/tasks/main.yml
new file mode 100644
index 0000000..57ca0e2
--- /dev/null
+++ b/roles/digitalocean_volume/tasks/main.yml
@@ -0,0 +1,12 @@
+- name: Default mount path
+ ansible.builtin.set_fact:
+ volume_dir: "{{ volume_dir | default('/mnt/{{ volume_name }}') }}"
+
+- name: Mount volume
+ become: true
+ ansible.posix.mount:
+ path: '{{ volume_dir }}'
+ src: '/dev/disk/by-id/scsi-0DO_Volume_{{ volume_name }}'
+ state: mounted
+ fstype: '{{ volume_fs }}'
+ opts: defaults,nofail,discard
diff --git a/roles/systemd_requires_mount/tasks/main.yml b/roles/systemd_requires_mount/tasks/main.yml
new file mode 100644
index 0000000..cd4beb3
--- /dev/null
+++ b/roles/systemd_requires_mount/tasks/main.yml
@@ -0,0 +1,22 @@
+- name: Set up systemd service dependency
+ become: true
+ block:
+ - name: 'Create override directory: {{ service_name }}'
+ ansible.builtin.file:
+ path: '/etc/systemd/system/{{ service_name }}.service.d'
+ state: directory
+
+ - name: 'Set up override: {{ service_name }}'
+ community.general.ini_file:
+ dest: '/etc/systemd/system/{{ service_name }}.service.d/override.conf'
+ section: Unit
+ option: RequiresMountsFor
+ value: '{{ mount_dir }}'
+ register: overridden
+
+ - name: 'Restart service: {{ service_name }}'
+ ansible.builtin.systemd_service:
+ daemon_reload: true
+ name: '{{ service_name }}'
+ state: restarted
+ when: overridden.changed