|
11 | 11 |
|
12 | 12 | - name: Ensure vm name is defined
|
13 | 13 | ansible.builtin.fail:
|
14 |
| - msg: "Missing parameter: key 'name' not found in azure_virtual_machine_with_public_ip_operation_vm" |
15 |
| - when: azure_virtual_machine_with_public_ip_operation_vm.name is not defined |
| 14 | + msg: "Missing parameter: key 'name' not found in azure_virtual_machine_with_public_ip_vm" |
| 15 | + when: azure_virtual_machine_with_public_ip_vm.name is not defined |
16 | 16 |
|
17 | 17 | - name: Replace invalid chars in name
|
18 | 18 | ansible.builtin.set_fact:
|
19 |
| - vm_name: "{{ azure_virtual_machine_with_public_ip_operation_vm.name | regex_replace('[^a-zA-Z0-9]', '-') }}" |
| 19 | + vm_name: "{{ azure_virtual_machine_with_public_ip_vm.name | regex_replace('[^a-zA-Z0-9]', '-') }}" |
20 | 20 |
|
21 | 21 | - name: Get resource group info
|
22 | 22 | azure.azcollection.azure_rm_resourcegroup_info:
|
|
28 | 28 | resource_group: "{{ azure_virtual_machine_with_public_ip_resource_group }}"
|
29 | 29 | name: "{{ vm_name }}"
|
30 | 30 | started: false
|
31 |
| - when: operation == 'power_off' |
| 31 | + when: azure_virtual_machine_with_public_ip_operation == 'power_off' |
32 | 32 |
|
33 | 33 | - name: Deallocate VM
|
34 | 34 | azure.azcollection.azure_rm_virtualmachine:
|
35 | 35 | resource_group: "{{ azure_virtual_machine_with_public_ip_resource_group }}"
|
36 | 36 | name: "{{ vm_name }}"
|
37 | 37 | allocated: false
|
38 |
| - when: operation == 'deallocate' |
| 38 | + when: azure_virtual_machine_with_public_ip_operation == 'deallocate' |
39 | 39 |
|
40 | 40 | - name: Power On VM
|
41 | 41 | azure.azcollection.azure_rm_virtualmachine:
|
42 | 42 | resource_group: "{{ azure_virtual_machine_with_public_ip_resource_group }}"
|
43 | 43 | name: "{{ vm_name }}"
|
44 |
| - when: operation == 'power_on' |
| 44 | + when: azure_virtual_machine_with_public_ip_operation == 'power_on' |
45 | 45 |
|
46 | 46 | - name: Restart VM
|
47 | 47 | azure.azcollection.azure_rm_virtualmachine:
|
48 | 48 | resource_group: "{{ azure_virtual_machine_with_public_ip_resource_group }}"
|
49 | 49 | name: "{{ vm_name }}"
|
50 | 50 | restarted: true
|
51 |
| - when: operation == 'restart' |
| 51 | + when: azure_virtual_machine_with_public_ip_operation == 'restart' |
52 | 52 |
|
53 | 53 | - name: Create or delete VM
|
54 | 54 | ansible.builtin.include_tasks: "{{ azure_virtual_machine_with_public_ip_operation }}.yml"
|
55 |
| - when: operation in ['create', 'delete'] |
| 55 | + when: azure_virtual_machine_with_public_ip_operation in ['create', 'delete'] |
0 commit comments