Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
For 2.9 release (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
puicchan authored and mybayern1974 committed Oct 8, 2019
1 parent d1d708f commit 5b51522
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 0 deletions.
51 changes: 51 additions & 0 deletions SIG_generalized_image/00-prerequisites.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
- hosts: localhost
connection: local
vars_files:
- ./vars.yml

tasks:
- name: Create resource group if doesn't exist
azure_rm_resourcegroup:
name: "{{ resource_group }}"
location: "{{ location }}"

- name: Create virtual network
azure_rm_virtualnetwork:
resource_group: "{{ resource_group }}"
name: "{{ virtual_network_name }}"
address_prefixes: "10.0.0.0/16"

- name: Add subnet
azure_rm_subnet:
resource_group: "{{ resource_group }}"
name: "{{ subnet_name }}"
address_prefix: "10.0.1.0/24"
virtual_network: "{{ virtual_network_name }}"

- name: Create public IP address
azure_rm_publicipaddress:
resource_group: "{{ resource_group }}"
allocation_method: Static
name: "{{ ip_name }}"

- name: Create virtual network inteface cards for VM A and B
azure_rm_networkinterface:
resource_group: "{{ resource_group }}"
name: "{{ network_interface_name }}"
virtual_network: "{{ virtual_network_name }}"
subnet: "{{ subnet_name }}"

- name: Create VM
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: "{{ source_vm_name }}"
admin_username: testuser
admin_password: "Password1234!"
vm_size: Standard_B1ms
network_interfaces: "{{ network_interface_name }}"
image:
offer: UbuntuServer
publisher: Canonical
sku: 16.04-LTS
version: latest

18 changes: 18 additions & 0 deletions SIG_generalized_image/01a-create-generalized-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
- hosts: localhost
connection: local
vars_files:
- ./vars.yml

tasks:
- name: Generalize VM
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: "{{ source_vm_name }}"
generalized: yes

- name: Create custom image
azure_rm_image:
resource_group: "{{ resource_group }}"
name: "{{ image_name }}"
source: "{{ source_vm_name }}"

12 changes: 12 additions & 0 deletions SIG_generalized_image/02-create-shared-image-gallery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- hosts: localhost
connection: local
vars_files:
- ./vars.yml

tasks:
- name: Create shared image gallery
azure_rm_gallery:
resource_group: "{{ resource_group }}"
name: "{{ shared_gallery_name }}"
location: "{{ location }}"
description: This is the gallery description.
45 changes: 45 additions & 0 deletions SIG_generalized_image/03a-create-shared-image-generalized.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
- hosts: localhost
connection: local
vars_files:
- ./vars.yml

tasks:
- name: Create shared image
azure_rm_galleryimage:
resource_group: "{{ resource_group }}"
gallery_name: "{{ shared_gallery_name }}"
name: "{{ shared_image_name }}"
location: "{{ location }}"
os_type: linux
os_state: generalized
identifier:
publisher: myPublisherName
offer: myOfferName
sku: mySkuName
description: Image Description

- name: Create or update a simple gallery Image Version.
azure_rm_galleryimageversion:
resource_group: "{{ resource_group }}"
gallery_name: "{{ shared_gallery_name }}"
gallery_image_name: "{{ shared_image_name }}"
name: "{{ shared_image_version }}"
location: "{{ location }}"
publishing_profile:
end_of_life_date: "2020-10-01t00:00:00+00:00"
exclude_from_latest: yes
replica_count: 3
storage_account_type: Standard_LRS
target_regions:
- name: West US
regional_replica_count: 1
- name: East US
regional_replica_count: 2
storage_account_type: Standard_ZRS
managed_image:
name: "{{ image_name }}"
resource_group: "{{ resource_group }}"
register: output

- debug:
var: output
16 changes: 16 additions & 0 deletions SIG_generalized_image/04a-create-vm-using-generalized-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- hosts: localhost
connection: local
vars_files:
- ./vars.yml

tasks:
- name: Create VM using shared image
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: "{{ vm_name }}"
vm_size: Standard_DS1_v2
admin_username: adminUser
admin_password: PassWord01
managed_disk_type: Standard_LRS
image:
id: "/subscriptions/{{ lookup('env', 'AZURE_SUBSCRIPTION_ID') }}/resourceGroups/{{ resource_group }}/providers/Microsoft.Compute/galleries/{{ shared_gallery_name }}/images/{{ shared_image_name }}/versions/{{ shared_image_version }}"
20 changes: 20 additions & 0 deletions SIG_generalized_image/05a-create-vmss-using-generalized-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- hosts: localhost
connection: local
vars_files:
- ./vars.yml

tasks:
- name: Create VMSS using shared image
azure_rm_virtualmachinescaleset:
resource_group: "{{ resource_group }}"
name: "{{ vmss_name }}"
vm_size: Standard_DS1_v2
admin_username: adminUser
admin_password: PassWord01
capacity: 2
virtual_network_name: "{{ virtual_network_name }}"
upgrade_policy: Manual
subnet_name: "{{ subnet_name }}"
managed_disk_type: Standard_LRS
image:
id: "/subscriptions/{{ lookup('env', 'AZURE_SUBSCRIPTION_ID') }}/resourceGroups/{{ resource_group }}/providers/Microsoft.Compute/galleries/{{ shared_gallery_name }}/images/{{ shared_image_name }}/versions/{{ shared_image_version }}"
21 changes: 21 additions & 0 deletions SIG_generalized_image/06-get-info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
- hosts: localhost
connection: local
vars_files:
- ./vars.yml

tasks:
- name: Get Shared Image Gallery information
azure_rm_gallery_info:
resource_group: "{{ resource_group }}"
name: "{{ shared_gallery_name }}"
- name: Get Shared Image Information
azure_rm_galleryimage_info:
resource_group: "{{ resource_group }}"
gallery_name: "{{ shared_gallery_name }}"
name: "{{ shared_image_name }}"
- name: Get Gallery Image Version Information
azure_rm_galleryimageversion_info:
resource_group: "{{ resource_group }}"
gallery_name: "{{ shared_gallery_name }}"
gallery_image_name: "{{ shared_image_name }}"
name: "{{ shared_image_version }}"
27 changes: 27 additions & 0 deletions SIG_generalized_image/07-delete-gallery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
- hosts: localhost
connection: local
vars_files:
- ./vars.yml

tasks:
- name: Delete gallery Image Version.
azure_rm_galleryimageversion:
resource_group: "{{ resource_group }}"
gallery_name: "{{ shared_gallery_name }}"
gallery_image_name: "{{ shared_image_name }}"
name: "{{ shared_image_version }}"
state: absent
register: result

- name: Delete gallery image
azure_rm_galleryimage:
resource_group: "{{ resource_group }}"
gallery_name: "{{ shared_gallery_name }}"
name: "{{ shared_image_name }}"
state: absent

- name: Delete a simple gallery.
azure_rm_gallery:
resource_group: "{{ resource_group }}"
name: "{{ shared_gallery_name }}"
state: absent
14 changes: 14 additions & 0 deletions SIG_generalized_image/vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
resource_group: mysiggrg
location: eastus
virtual_network_name: testVnet
subnet_name: testSubnet
ip_name: testPublicIP
source_vm_name: vmforimagesigg
network_interface_name: vmforimagesiggnic
image_name: testimagea
shared_gallery_name: myGallery
shared_image_name: myImage
shared_image_version: 10.1.3
vm_name: testvm001
vmss_name: testvmssx
snapshot_name: mySnapshot

0 comments on commit 5b51522

Please sign in to comment.