How to create a new partition with Ansible


When I run this on the command line it works fine:

But in Ansible it does not want to run in shell:

It does not come back with an error, but it does not create the partition either.

I checked that Ansible and LVM will not do what I need.

Any advice?


With Ansible 2.3 and above, you can use parted module to create partitions from a block device.
For example:

To format the partition just use filesystem module as shown below:

To mount the partition to, let’s say, /work folder just use mount module as shown below:

Leave a Reply