Miantian
Miantian

Reputation: 1075

How to mount volumes with size by ansible?

First, do a partition as

- name: Create a new partition
  community.general.parted:
    device: /dev/sda1
    number: 3
    state: present
    part_end: 20GiB
    fs_type: xfs

Then, mount different volumes with this partition

# It should set to 15GB
- name: Mount root
  mount:
    path: /
    src: ...
    fstype: xfs
    state: present

# It should set to 5GB
- name: Mount swap
  mount:
    path: swapfile
    src: ...
    fstype: xfs
    state: present

But how to set the src value? Since just did a partition for the whole /dev/sda1. If set /dev/sda1 to it maybe the entire space will be given.

On ansible's mount module document, I didn't find a size item to use.

Upvotes: 1

Views: 756

Answers (1)

Akshay Hegde
Akshay Hegde

Reputation: 16997

On ansible's mount module document, I didn't find a size item to use.

In current context it seems like you made entire disk to one partition.

So It is not possible to specify size during mount, you have to create partition size of your interest while creating partition itself for separate swap, and other partitions.

If you're looking for other options then you can use opts: in mount module.

Upvotes: 1

Related Questions