ansible/test/integration/targets/azure_rm_lock/tasks/main.yml
Yuwei Zhou 41778a8e12 Add azure resource lock module (#55700)
* add locks

* rename the module

* add test

* add test

* address comments

* add quote

* can list child scope lock

* minor docs tweaks

* Add files via upload (#62)

* change '\r\n' to '\n' (#63)

* Small changes, just to trigger CI verify.

* trigger CI verify

* remove 's'

* Update according by comments

* change small for trigger CI check
2019-08-28 05:35:12 +08:00

99 lines
No EOL
1.9 KiB
YAML

- name: Create a virtual network
azure_rm_virtualnetwork:
name: mytestvirtualnetworklock
resource_group: "{{ resource_group }}"
address_prefixes_cidr:
- "10.1.0.0/16"
register: vn
- name: Add lock to resource (check_mode)
azure_rm_lock:
name: keep
managed_resource_id: "{{ vn.state.id }}"
level: read_only
register: lock
check_mode: yes
- assert:
that:
- lock.changed
- name: Query lock
azure_rm_lock_facts:
managed_resource_id: "{{ vn.state.id }}"
register: locks
- assert:
that:
- locks.locks | length == 0
- name: Add lock to resource
azure_rm_lock:
name: keep
managed_resource_id: "{{ vn.state.id }}"
level: read_only
register: lock
- assert:
that:
- lock.changed
- lock.id
- name: Query lock
azure_rm_lock_facts:
name: keep
managed_resource_id: "{{ vn.state.id }}"
register: locks
- assert:
that:
- locks.locks | length == 1
- name: Update lock to resource (idempontent)
azure_rm_lock:
name: keep
managed_resource_id: "{{ vn.state.id }}"
level: read_only
register: lock1
- assert:
that:
- not lock1.changed
- lock1.id == lock.id
- name: Update lock level
azure_rm_lock:
name: keep
managed_resource_id: "{{ vn.state.id }}"
level: can_not_delete
register: lock
- assert:
that:
- lock.changed
- lock.level == 'can_not_delete'
- name: Delete lock
azure_rm_lock:
name: keep
managed_resource_id: "{{ vn.state.id }}"
register: lock
- assert:
that:
- lock.changed
- name: Query lock
azure_rm_lock_facts:
managed_resource_id: "{{ vn.state.id }}"
register: locks
- assert:
that:
- locks.locks | length == 0
- name: Clean up
azure_rm_virtualnetwork:
name: mytestvirtualnetworklock
resource_group: "{{ resource_group }}"
state: absent