Skip to content

azure_rm_securitygroup should support diff output #1093

Open
@Nothing4You

Description

@Nothing4You
SUMMARY

https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_checkmode.html#using-diff-mode

Diff mode should be supported to be able to review the changes performed.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

azure_rm_securitygroup

ADDITIONAL INFORMATION

Diff mode allows reviewing the changes performed.
For example, it allows to easily determine which changes had been done outside of the ansible-managed configuration, such as someone manually changing it in Azure directly.
While the module currently returns whether there were changes, it's not possible to see which attributes/rules have changed.
I haven't checked for diff support in other modules but this might be a collection-wide topic.

- name: Update NSG
  diff: true
  azure.azcollection.azure_rm_securitygroup:
    subscription_id: "{{ nsg_subscription_id }}"
    resource_group: "{{ nsg_resource_group }}"
    name: testing-ansible
    purge_rules: yes
    rules:
      ## Inbound
      - name: Managed-rule
        priority: 100
        access: Deny
        source_address_prefix: 192.168.252.251/32
        destination_address_prefix: 192.168.252.251/32
        direction: Inbound
        description: test ansible rule

Example (admittedly much simpler on a simple text diff):

- hosts: localhost
  connection: local
  gather_facts: false

  tasks:
    - ansible.builtin.lineinfile:
        path: ./ansible-diff-demo
        create: true
        regexp: ^diff demo
        line: "diff demo {{ 100 | random }}"
      diff: true

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    holdThe problem holds for a particular reasonmedium_priorityMedium prioritywork inIn trying to solve, or in working with contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions