On Mon, 6 Dec 2021 at 22:21, dulhaver via Ansible Project <
ansible-project@googlegroups.com> wrote:

> I have seen something similar with re-running LVM operations and remember
> they mentioned to add a *force: yes* option (I don't recall the exact
> wording though) in oder the not fail on re-execution. Wondering whether
> something alike would help here too.
>

Hmm that didn't help.

This is working for me, but I think that's ugly.. there must be another way
to achieve this:

- name: Check if {{ data_volume }} is already mounted
shell: df | grep {{ data_volume }} | wc -l
with_items: "{{ data_volume }}"
register: ebs_checked

- name: Create a new ext4 primary partition for /data
run_once: true
community.general.parted:
name: pg_data
device: "{{ data_volume }}"
number: 2
state: present
fs_type: ext4
when: "{{item.stdout}} == 0"
with_items: "{{ ebs_checked.results }}"

- name: Create a ext4 filesystem on "{{ data_volume }}" (/data)
run_once: true
community.general.filesystem:
fstype: ext4
dev: "{{ data_volume }}"
when: "{{item.stdout}} == 0"
with_items: "{{ ebs_checked.results }}"

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

-- 
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_gQfUMJgDFKv0-x5Nyn109X7ZtS6qbwaO64VdadJBVx-2Q%2BQ%40mail.gmail.com.

Reply via email to