Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure_rm_virtualnetworkpeering: Fix unable to remove non-existing pee… #400

Merged
merged 1 commit into from
Jan 25, 2021

Conversation

mmallet-digipok
Copy link
Contributor

…ring (#399)

SUMMARY

In case the virtual network peering does not exist when the specified state is
'absent', the code was triggering a failure. This patch changes the fail call
into log so that now the module is idempotent with 'state: absent'.

Fixes: #399

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

azure_rm_virtualnetworkpeering

ADDITIONAL INFORMATION

Successfully tested with the following playbook:

- hosts: localhost
  become: no
  gather_facts: no
  tasks:
    - name: Remove Azure vnet peering
      azure_rm_virtualnetworkpeering:
        name: "/VNET_PEERING_{{ azure_resource_group }}"
        virtual_network: "{{ azure_remote_virtual_network_name }}"
        resource_group: "{{ azure_remote_virtual_network_resource_group_name }}"
        client_id: "{{ azure_client_id }}"
        secret: "{{ azure_client_secret }}"
        subscription_id: "{{ azure_remote_virtual_network_subscription_id }}"
        tenant: "{{ azure_tenant_id }}"
        cloud_environment: "{{ azure_cloud_environment }}"
        state: absent
      loop: [1, 2]

Output:

$ ansible-playbook -i inventory remove-vnet-peering.yml
PLAY [localhost] ************************************************************************************************************************************************************************

TASK [Remove Azure vnet peering] ********************************************************************************************************************************************************
ok: [localhost] => (item=1)
ok: [localhost] => (item=2)

PLAY RECAP ******************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

…ring (ansible-collections#399)

In case the virtual network peering does not exist when the specified state is
'absent', the code was triggering a failure. This patch changes the fail call
into log so that now the module is idempotent with 'state: absent'.
@Fred-sun Fred-sun added has_pr PR fixes have been made medium_priority Medium priority ready_for_review The PR has been modified and can be reviewed and merged and removed has_pr PR fixes have been made labels Jan 25, 2021
@haiyuazhang haiyuazhang merged commit 6b38d05 into ansible-collections:dev Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
medium_priority Medium priority ready_for_review The PR has been modified and can be reviewed and merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove non existing peering using module azure_rm_virtualnetworkpeering causes task to fail
3 participants