-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mount: handle labels with spaces correctly, sanitize label input
- Loading branch information
1 parent
a80f199
commit 0357163
Showing
3 changed files
with
22 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
--- | ||
- name: "Check if disk is mounted: {{ item.key }}" | ||
shell: pmount | grep {{ item.key }} | ||
- name: "Check if disk is mounted: {{ item.key|quote }}" | ||
shell: 'pmount | grep {{ item.key|quote }}' | ||
register: grep | ||
failed_when: "grep.rc == 2" | ||
check_mode: no | ||
changed_when: false | ||
|
||
- debug: | ||
msg: "Disk {{ item.key }} is already mounted." | ||
msg: "Disk is already mounted: {{ item.key|quote }}" | ||
when: grep.rc == 0 | ||
|
||
|
||
- block: | ||
|
||
- name: "Ensure mount dir is absent before mounting" | ||
- name: 'Ensure mount dir is absent before mounting: {{ mount_path|quote }}' | ||
file: | ||
path: "/media/{{ item.key }}" | ||
path: '{{ mount_path|quote }}' | ||
state: absent | ||
become: yes | ||
|
||
- name: "Mount disk {{ item.key }} to /media/{{ item.key }}." | ||
shell: pmount /dev/disk/by-label/{{ item.key }} {{ item.key }} | ||
- name: "Mount disk, label: {{ disk_path|quote }}, mount path: {{ mount_path|quote }}." | ||
command: 'pmount {{ disk_path|quote }} {{ item.key|quote }}' | ||
|
||
when: grep.rc == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
disk_path: '/dev/disk/by-label/{{ item.key }}' | ||
mount_path: '/media/{{ item.key }}' |