mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-06-30 07:50:43 +00:00
azure_rm_image module's source can accept dict value (#48864)
This commit is contained in:
parent
ee0df72e49
commit
c0d95a73ff
2 changed files with 73 additions and 49 deletions
|
|
@ -1,19 +1,10 @@
|
|||
- name: Create storage account name
|
||||
set_fact:
|
||||
vm_name: "vm{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}x"
|
||||
storage_name: "st{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||
storage_container_name: "sc{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||
public_ip_name: "pip{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||
security_group_name: "sg{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||
blob_name: "blob{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||
empty_disk_name: "emptydisk{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||
|
||||
- name: Create storage account
|
||||
azure_rm_storageaccount:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: "{{ storage_name }}"
|
||||
account_type: Standard_LRS
|
||||
|
||||
- name: Create virtual network
|
||||
azure_rm_virtualnetwork:
|
||||
resource_group: "{{ resource_group }}"
|
||||
|
|
@ -52,9 +43,7 @@
|
|||
resource_group: "{{ resource_group }}"
|
||||
name: "{{ vm_name }}"
|
||||
vm_size: Standard_A0
|
||||
storage_account: "{{ storage_name }}"
|
||||
storage_container: "{{ storage_container_name }}"
|
||||
storage_blob: "{{ blob_name }}.vhd"
|
||||
managed_disk_type: Standard_LRS
|
||||
admin_username: adminuser
|
||||
admin_password: Password123!
|
||||
os_type: Linux
|
||||
|
|
@ -64,20 +53,7 @@
|
|||
publisher: Canonical
|
||||
sku: 16.04-LTS
|
||||
version: latest
|
||||
|
||||
- name: Deallocate the virtual machine
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: "{{ vm_name }}"
|
||||
allocated: no
|
||||
vm_size: Standard_A0
|
||||
register: output
|
||||
|
||||
- name: Start the virtual machine
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: "{{ vm_name }}"
|
||||
vm_size: Standard_A0
|
||||
register: vm
|
||||
|
||||
- name: Create new empty managed disk
|
||||
azure_rm_managed_disk:
|
||||
|
|
@ -90,7 +66,7 @@
|
|||
- name: Create an image from VM (check mode)
|
||||
azure_rm_image:
|
||||
resource_group: "{{ resource_group }}"
|
||||
source: "https://{{ storage_name }}.blob.core.windows.net/{{ storage_container_name }}/{{ blob_name }}.vhd"
|
||||
source: "{{ vm.ansible_facts.azure_vm.properties.storageProfile.osDisk.managedDisk.id }}"
|
||||
name: testimage001
|
||||
os_type: Linux
|
||||
data_disk_sources:
|
||||
|
|
@ -104,7 +80,9 @@
|
|||
- name: Create an image from VM
|
||||
azure_rm_image:
|
||||
resource_group: "{{ resource_group }}"
|
||||
source: "https://{{ storage_name }}.blob.core.windows.net/{{ storage_container_name }}/{{ blob_name }}.vhd"
|
||||
source:
|
||||
name: "{{ vm_name }}"
|
||||
type: disks
|
||||
name: testimage001
|
||||
os_type: Linux
|
||||
register: output
|
||||
|
|
@ -117,7 +95,7 @@
|
|||
- name: Create an image from VM (idempotent)
|
||||
azure_rm_image:
|
||||
resource_group: "{{ resource_group }}"
|
||||
source: "https://{{ storage_name }}.blob.core.windows.net/{{ storage_container_name }}/{{ blob_name }}.vhd"
|
||||
source: "{{ vm.ansible_facts.azure_vm.properties.storageProfile.osDisk.managedDisk.id }}"
|
||||
name: testimage001
|
||||
os_type: Linux
|
||||
register: output
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue