Hi all.

I'm having issues with the parted plugin. It works when I run the playbook
for the first time, but if I try to run again, it will fail.

I actually want this task to be run only once, but the run_once parameter
is not working either.

------------------------------------------------

- name: Add new partition "{{ data_volume }}"
run_once: true
parted:
device: "{{ data_volume }}"
number: 2
fs_type: ext4
state: present

Error:
fatal: [localhost]: FAILED! => {"changed": false, "err": "Error:
Partition(s) on /dev/nvme2n1 are being used.\n", "msg": "Error while
running parted script: /usr/sbin/parted -s -m -a optimal /dev/nvme2n1 --
unit KiB mklabel msdos mkpart primary ext4 0% 100%", "out": "", "rc": 1}

If I unmount the partition, it will work. But then it will delete
everything in that partition and I don't want that if I am running the
playbook for the second or third time.

------------------------------------------------


All the tasks relevant are below:

- name: Add new partition "{{ data_volume }}"
run_once: true
parted:
device: "{{ data_volume }}"
number: 2
fs_type: ext4
state: present

- name: Create a ext4 filesystem on "{{ data_volume }}" (/data)
run_once: true
community.general.filesystem:
fstype: ext4
dev: "{{ data_volume }}"

- name: Mount /data
ansible.posix.mount:
path: /data
src: "{{ data_volume }}"
fstype: ext4
state: mounted
opts: defaults

What am I missing?

I'm using Ansible 2.11 and Ubuntu 20.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAE_gQfVZwnbceY%3DsSPu5updRQ8_1ZieJDiwX_a78AD3pndXKpQ%40mail.gmail.com.

Reply via email to