virt_net and ignore_errors

Hi,
I’ve just started using ansible and I wanted to delete the “default” network created in my KVM install. I’m using the following syntax:

  • name: destroy default network
    virt_net: command=destroy name=default
    ignore_errors: true

  • name: undefine default network
    virt_net: command=undefine name=default
    ignore_errors: true

This works fine, but I had to put in the “ignore_errors: true” flag because if i run this playbook more than once, the second time it will error out as the “default” network does not exist. On most other ansible tasks, for example when creating a linux user account, ansible will skip over it if the user account already exists and does not error out in the middle of the playbook.

Is there a way to do the same for my destroy and undefine commands in virt_net? I’m not sure if what i’m doing is the cleanest method. I know in a perfect world, i would not be running this playbook more than once, but I am running it multiple times testing different additions to the playbook.

Thanks in advance.

Remove command and add state=absent ?

- name: default network
   virt_net: state=absent name=default

Worked like a champ!!! Thanks.