Skip to content

Commit

Permalink
Manage mounts in two stages to keep systemd cooperative.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwlehman committed Jun 10, 2020
1 parent 3a94f34 commit 6a74df8
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions tasks/main-blivet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,34 @@
# changed options? (just add w/ new settings?)
# add new mounts
#
- name: manage mounts to match the specified state
# XXX Apparently we have to do the removals, then tell systemd to
# update its view, then set up the new mounts. Otherwise,
# systemd will forcibly prevent mounting a new volume to an
# existing mount point.
- name: remove obsolete mounts
mount:
src: "{{ mount_info['src']|default(omit) }}"
path: "{{ mount_info['path'] }}"
fstype: "{{ mount_info['fstype']|default(omit) }}"
opts: "{{ mount_info['opts']|default(omit) }}"
state: "{{ mount_info['state'] }}"
loop: "{{ blivet_output.mounts }}"
loop: "{{ blivet_output.mounts|json_query('[?state==`absent`]') }}"
loop_control:
loop_var: mount_info

- name: tell systemd to refresh its view of /etc/fstab
systemd:
daemon_reload: yes
when: blivet_output['mounts']

- name: set up new/current mounts
mount:
src: "{{ mount_info['src']|default(omit) }}"
path: "{{ mount_info['path'] }}"
fstype: "{{ mount_info['fstype']|default(omit) }}"
opts: "{{ mount_info['opts']|default(omit) }}"
state: "{{ mount_info['state'] }}"
loop: "{{ blivet_output.mounts|json_query('[?state!=`absent`]') }}"
loop_control:
loop_var: mount_info

Expand Down

0 comments on commit 6a74df8

Please sign in to comment.