diff --git a/playbooks/host_maintenance/systemd_mount.yaml b/playbooks/host_maintenance/systemd_mount.yaml new file mode 100644 index 0000000..640e5d3 --- /dev/null +++ b/playbooks/host_maintenance/systemd_mount.yaml @@ -0,0 +1,7 @@ +- name: mount - data disks + hosts: '{{target|default("all")}}' + become: true + tasks: + - ansible.builtin.include_role: + name: mylimbo.globals.host_maintenance + tasks_from: systemd_mount diff --git a/roles/host_maintenance/tasks/systemd_mount.yaml b/roles/host_maintenance/tasks/systemd_mount.yaml new file mode 100644 index 0000000..7a2987a --- /dev/null +++ b/roles/host_maintenance/tasks/systemd_mount.yaml @@ -0,0 +1,27 @@ +#vars: +# host_maintenance_systemd_mount_target: "" +# host_maintenance_systemd_mount_source: "" + +- name: check target folders + ansible.builtin.file: + path: "{{ item.target }}" + state: directory + mode: '0755' + loop: "{{ host_maintenance_disk_mounts }}" + +- name: set systemd mount + ansible.builtin.template: + src: templates/systemd_mount.j2 + dest: "/etc/systemd/system/{{ item.target | regex_replace('^/', '') | regex_replace('/', '-') }}.mount" + mode: '0644' + loop: "{{ host_maintenance_disk_mounts }}" + register: systemd_mount_files + + +- name: reload systemd + ansible.builtin.systemd_service: + name: "{{ item.target | regex_replace('^/', '') | regex_replace('/', '-') }}.mount" + daemon_reload: "{{ systemd_mount_files.changed }}" + enabled: true + state: started + loop: "{{ host_maintenance_disk_mounts }}" diff --git a/roles/host_maintenance/templates/systemd_mount.j2 b/roles/host_maintenance/templates/systemd_mount.j2 new file mode 100644 index 0000000..d33e640 --- /dev/null +++ b/roles/host_maintenance/templates/systemd_mount.j2 @@ -0,0 +1,14 @@ +[Unit] +Description=Mount {{ item.target }} managed by mylimbo.globals collections, host_maintenance role +#After= +Conflicts={{ item.unit_conflicts }} +Before={{ item.unit_before }} + +[Mount] +What={{ item.source }} +Where={{ item.target }} +Type={{ item.mount_type }} +Options={{ item.mount_options | join(',') }} + +[Install] +WantedBy=multi-user.target \ No newline at end of file