Skip to content

Commit

Permalink
Merge pull request #24 from mjourdan/wip_nopart
Browse files Browse the repository at this point in the history
allow to use the role without partitioning
  • Loading branch information
christopherobin authored Jan 12, 2022
2 parents b2362d5 + e06997e commit d282612
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ disk_additional_disks:
```
* `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.
* `part` is the first partition name. If not specified and partitioning is enabled, `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 All @@ -47,6 +47,7 @@ disk_additional_disks:

You can add:
* `disk_package_use` is the required package manager module to use (yum, apt, etc). The default 'auto' will use existing facts or try to autodetect it.
* `disk_enable_partioning: false` to disable partitioning

The following filesystems are currently supported:
- [ext2](http://en.wikipedia.org/wiki/Ext2)
Expand All @@ -69,4 +70,4 @@ How it works

It uses `sfdisk` to partition the disk with a single primary partition spanning the entire disk.
The specified filesystem will then be created with `mkfs`.
Finally the new partition will be mounted to the specified mount path.
Finally the new filesystem will be mounted to the specified mount path.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
# See README for syntax and usage.
disk_additional_disks: []
disk_package_use: auto
disk_enable_partitioning: true
additional_fs_utils: []
14 changes: 8 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
name: parted
state: present
use: '{{ disk_package_use }}'
when: disk_additional_disks
when: disk_additional_disks and disk_enable_partitioning
tags: ['disk', 'pkgs']

- name: "Install additional fs progs"
Expand All @@ -47,6 +47,7 @@
creates: '{{ item.part | default(item.disk + "1") }}'
executable: '/bin/bash'
with_items: '{{ disk_additional_disks }}'
when: disk_enable_partitioning
register: disk_offset
tags: ['disk']

Expand All @@ -61,19 +62,20 @@
creates: '{{ item.part | default(item.disk + "1") }}'
executable: '/bin/bash'
with_items: '{{ disk_additional_disks }}'
when: disk_enable_partitioning
tags: ['disk']

- name: "Create filesystem on the first partition"
- name: "Create filesystem on the volume"
filesystem:
dev: '{{ item.part | default(item.disk + "1") }}'
dev: '{{ (disk_enable_partitioning == true) | ternary(item.part | default(item.disk + "1"), item.disk) }}'
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.part | default(item.disk + "1") }}
shell: 'tune2fs -c0 -i0 {{ (disk_enable_partitioning == true) | ternary(item.part | default(item.disk + "1"), item.disk) }}'
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 @@ -87,8 +89,8 @@
with_items: '{{ disk_additional_disks }}'
tags: ['disk']

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

0 comments on commit d282612

Please sign in to comment.