Skip to content

Commit

Permalink
Merge pull request #16 from MiLk/nvme
Browse files Browse the repository at this point in the history
Allow to specify custom partition names
  • Loading branch information
MiLk authored Dec 6, 2017
2 parents 90c4b79 + daf548c commit e303c7f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ disk_additional_disks:
user: www-data
group: www-data
disable_periodic_fsck: false
- disk: /dev/nvme0n1
part: /dev/nvme0n1p1
fstype: xfs
mount_options: defaults,noatime
mount: /data2
```
* `disk` is the device, you want to mount.
* `part` is the first partition name. If not specified, `1` will be appended to the disk name.
* `fstype` allows you to choose the filesystem to use with the new disk.
* `mount_options` allows you to specify custom mount options.
* `mount` is the directory where the new disk should be mounted.
Expand Down
12 changes: 6 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
echo 2048;
fi
args:
creates: '{{ item.disk }}1'
creates: '{{ item.part | default(item.disk + "1") }}'
executable: '/bin/bash'
with_items: '{{ disk_additional_disks }}'
register: disk_offset
Expand All @@ -35,25 +35,25 @@
if
[ -b {{ item.disk }} ]
then
[ -b {{ item.disk }}1 ] || parted -a optimal --script "{{ item.disk }}" mklabel gpt mkpart primary {{ disk_offset.stdout|default("2048") }}s 100% && sleep 5 && partprobe {{ item.disk }}; sleep 5
[ -b {{ item.part | default(item.disk + "1") }} ] || parted -a optimal --script "{{ item.disk }}" mklabel gpt mkpart primary {{ disk_offset.stdout|default("2048") }}s 100% && sleep 5 && partprobe {{ item.disk }}; sleep 5
fi
args:
creates: '{{ item.disk }}1'
creates: '{{ item.part | default(item.disk + "1") }}'
executable: '/bin/bash'
with_items: '{{ disk_additional_disks }}'
tags: ['disk']

- name: "Create filesystem on the first partition"
filesystem:
dev: '{{ item.disk }}1'
dev: '{{ item.part | default(item.disk + "1") }}'
force: '{{ item.force|d(omit) }}'
fstype: '{{ item.fstype }}'
opts: '{{ item.fsopts|d(omit) }}'
with_items: '{{ disk_additional_disks }}'
tags: ['disk']

- name: "Disable periodic fsck on ext3 or ext4 formatted disks"
shell: tune2fs -c0 -i0 {{ item.disk }}1
shell: tune2fs -c0 -i0 {{ item.part | default(item.disk + "1") }}
with_items: '{{ disk_additional_disks }}'
when: "disk_additional_disks and ( item.fstype == 'ext4' or item.fstype == 'ext3' ) and item.disable_periodic_fsck|default(false)|bool"
tags: ['disk']
Expand All @@ -68,7 +68,7 @@
tags: ['disk']

- name: "Get UUID for partition"
command: blkid -s UUID -o value "{{ item.disk }}1"
command: blkid -s UUID -o value {{ item.part | default(item.disk + "1") }}
register: disk_blkid
with_items: '{{ disk_additional_disks }}'
changed_when: False
Expand Down

0 comments on commit e303c7f

Please sign in to comment.