add azure

This commit is contained in:
willtome
2022-06-09 13:45:47 -04:00
parent e9282c3c09
commit 9b7ab0915e
7 changed files with 77 additions and 6 deletions

View File

@@ -1,6 +1,14 @@
---
vm_blueprint_providers:
- aws
- azure
aws_image_filter: 'Windows_Server-2019-English-Core-Base*'
aws_instance_size: t3.medium
aws_userdata_template: aws_windows_userdata
az_vm_os_type: Windows
az_vm_size: Standard_DS1_v2
az_vm_image:
offer: WindowsServer
publisher: MicrosoftWindowsServer
sku: 2022-Datacenter
version: latest

View File

@@ -12,4 +12,4 @@
include_role:
name: "demo.cloud.aws"
tasks_from: destroy_vm
when: "'cloud_aws' in group_names"
when: "'cloud_aws' in group_names or 'cloud_azure' in group_names"

View File

@@ -35,6 +35,23 @@ controller_inventory_sources:
- key: platform
prefix: os
- name: Azure Inventory
organization: Default
source: azure_rm
inventory: Workshop Inventory
credential: Azure
overwrite: true
source_vars:
hostnames:
- tags.Name
- default
keyed_groups:
- key: os_profile.system
prefix: os
groups:
cloud_azure: true
controller_templates:
- name: Cloud / Create Infra
job_type: run
@@ -58,6 +75,7 @@ controller_templates:
required: true
choices:
- aws
- azure
- question_name: AWS Public Key (only required for aws provider)
type: textarea
required: false
@@ -93,6 +111,7 @@ controller_templates:
required: true
choices:
- aws
- azure
- question_name: Blueprint
type: multiplechoice
variable: vm_blueprint

View File

@@ -2,8 +2,16 @@
##############
# Azure Vars
##############
az_region:
az_region: eastus
az_rg_name: ansible
az_rg_prefix: demo
az_vnet_cidr_block: 10.0.0.0/16
az_subnet_cidr: 10.0.1.0/24
az_vm_name: "{{ vm_name }}"
az_vm_owner: "{{ vm_owner }}"
az_blueprint: "{{ vm_blueprint }}"
az_vm_username: "{{ ansible_user }}"
az_vm_password: "{{ ansible_password }}"
az_env_tag: prod
az_purpose_tag: ansible_demo
az_ansiblegroup_tag: cloud

View File

@@ -1,8 +1,8 @@
---
- name: AZURE | CREATE INFRA | resource group
azure.azcollection.azure_rm_resourcegroup:
name: "{{ az_rg_name }}-{{ az_rg_prefix }}-rg"
location: "{{ az_region }}"
name: "{{ az_rg_name }}-{{ az_rg_prefix }}-rg"
location: "{{ az_region }}"
- name: AZURE | CREATE INFRA | virtual network
azure.azcollection.azure_rm_virtualnetwork:

View File

@@ -0,0 +1,28 @@
---
- name: AZURE | CREATE VM | vnet interface
azure.azcollection.azure_rm_networkinterface:
resource_group: "{{ az_rg_name }}-{{ az_rg_prefix }}-rg"
name: "{{ az_vm_name }}_nic"
public_ip_name: "{{ az_vm_name }}_ip"
virtual_network: "{{ az_rg_name }}-{{ az_rg_prefix }}-vnet"
subnet: "{{ az_rg_name }}-{{ az_rg_prefix }}-subnet }}"
security_group: "{{ az_rg_name }}-{{ az_rg_prefix }}-sec-group"
- name: AZURE | CREATE VM | vm
azure.azcollection.azure_rm_virtualmachine:
resource_group: "{{ az_rg_name }}-{{ az_rg_prefix }}-rg"
name: "{{ az_vm_name }}"
os_type: "{{ az_vm_os_type }}"
vm_size: "{{ az_vm_size }}"
admin_username: "{{ az_vm_username }}"
admin_password: "{{ az_vm_password }}"
network_interfaces: "{{ az_vm_name }}_nic"
image: "{{ az_vm_image }}"
tags:
blueprint: "{{ az_blueprint }}"
purpose: "{{ az_purpose_tag }}"
env: "{{ az_env_tag }}"
ansible_group: "{{ az_ansiblegroup_tag }}"
owner: "{{ az_vm_owner }}"
info: "This instance was built by Red Hat Product Demos"
Name: "{{ az_vm_name }}"

View File

@@ -0,0 +1,8 @@
---
- name: Destroy VM
azure.azcollection.azure_rm_virtualmachine:
resource_group: "{{ az_rg_name }}-{{ az_rg_prefix }}-rg"
name: "{{ inventory_hostname }}"
state: absent
remove_on_absent: all_autocreated
delegate_to: localhost