mcgrof.create_partition

create_partition

The create_partition role allows you to easily and safely create and mount a Linux partition.

It has checks to make sure you only create the partition if it doesn't already exist. Device names can change during boot, so initially, we might use one name, but it could change later. This role helps find the partition label on different device names.

The partition label is important and relied upon.

Requirements

You need to have the appropriate partition user-space tools. For example, if you are using xfs, you need xfsprogs. If you choose 'xfs', it will use make.xfs. If you select 'foo' as your filesystem type, you need 'mkfs.foo'.

Role Variables

  • disk_setup_device: the device you want to use
  • disk_setup_fstype: the type of filesystem you want to use
  • disk_setup_mount_opts: additional mount options for /etc/fstab; this should not be empty. If you want the default options, just don't change anything (it defaults to "defaults").
  • disk_setup_label: the label for the filesystem
  • disk_setup_fs_opts: extra filesystem options
  • disk_setup_path: where to mount the filesystem
  • disk_setup_user: the user to own the directory
  • disk_setup_group: the group to own the directory

Dependencies

None.

Example Playbook

Here’s an example playbook task:

- name: Create /media/truncated if needed
  include_role:
    name: create_partition
  vars:
    disk_setup_device: "/dev/nvme2n1"
    disk_setup_fstype: "xfs"
    disk_setup_label: "truncated"
    disk_setup_fs_opts: "-L {{ disk_setup_label }}"
    disk_setup_path: "/media/truncated"
    disk_setup_user: "vagrant"
    disk_setup_group: "vagrant"
  tags: ['oscheck', 'truncated_partition']

For more examples, check out the users of this role, like the https://github.com/mcgrof/kdevops project or the https://github.com/mcgrof/oscheck project where this code came from.

License

GPLv2

Informazioni sul progetto

Create a Linux partition

Installa
ansible-galaxy install mcgrof.create_partition
Licenza
Unknown
Download
326
Proprietario
https://www.do-not-panic.com/p/hacking.html