-
Notifications
You must be signed in to change notification settings - Fork 7
/
deploy-to-azure.yml
99 lines (88 loc) · 3.3 KB
/
deploy-to-azure.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
- hosts: localhost
gather_facts: false
tasks:
- name: Create the resource group
azure_rm_resourcegroup:
name: monitoring-rg
location: westeurope
- name: Create the public ip address
azure_rm_publicipaddress:
resource_group: monitoring-rg
name: monitoring-ip
allocation_method: Static
- name: Create the network security group
azure_rm_securitygroup:
resource_group: monitoring-rg
name: monitoring-nsg
rules:
- name: HTTP
protocol: Tcp
destination_port_range: 80
access: Allow
priority: 100
direction: Inbound
- name: HTTPS
protocol: Tcp
destination_port_range: 443
access: Allow
priority: 110
direction: Inbound
- name: Create the virtual network interface card
azure_rm_networkinterface:
resource_group: monitoring-rg
name: monitoring-nic
virtual_network:
resource_group: myResourceGroup
name: VNet1
subnet_name: default
security_group_name: monitoring-nsg
ip_configurations:
- name: default
public_ip_address_name: monitoring-ip
primary: true
- name: Create the storage account
azure_rm_storageaccount:
resource_group: monitoring-rg
name: savvymonitoringsa
type: Standard_LRS
- name: Create the Savvy Monitoring VM
azure_rm_virtualmachine:
resource_group: monitoring-rg
name: monitoring
admin_username: sdiadmin
ssh_password_enabled: false
ssh_public_keys:
- path: /home/sdiadmin/.ssh/authorized_keys
key_data: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfmGVUQImyNEbQnNwfGjLuhQYk6Hqom9r0sntcE4fStrTCMRN030Qt3m6R0H0ykEhONDQ0WnpXZSjPdSLxFi+IQVTeghRouRwE1joznBllBYbGP7ArWYjfHiXzhqE8zVDslpdq2Q6yu9OjVBnh0CdV8ynVuQjIkKZ/Ct1Zk9+vvgKbl/JuGt2yIna/q1XB7AC6DgJTv2gQ1CrUCHrPtAJSmzTzfhI9Y203FiO+iCXD2QwzkOrJHhqpJu5c3x6j67fmV46651XbW6o4iXwj96J6oDfGOZHChGbutmkC6asUZYtQhsld49ZV6EerB+SoMV6Z2BBhC+Ixkx97dE8Y2nDB
vm_size: Standard_B2s
network_interfaces: monitoring-nic
storage_account_name: savvymonitoringsa
image:
name: myUbuntuImage
resource_group: myResourceGroup
register: azure_rm_virtualmachine_result
- name: Create a DNS record for the Savvy Monitoring VM
azure_rm_dnsrecordset:
resource_group: myResourceGroup
relative_name: monitoring
zone_name: savvydatainsights.co.uk
time_to_live: 60
record_type: A
state: present
records:
- entry: "{{ azure_rm_virtualmachine_result.ansible_facts.azure_vm.properties.networkProfile.networkInterfaces[0].properties.ipConfigurations[0].properties.publicIPAddress.properties.ipAddress }}"
- name: Add the Savvy Monitoring VM to the ansible-playbook in-memory inventory
add_host:
groups: azure-vm
hostname: "{{ azure_rm_virtualmachine_result.ansible_facts.azure_vm.properties.networkProfile.networkInterfaces[0].properties.ipConfigurations[0].properties.privateIPAddress }}"
ansible_user: sdiadmin
ansible_ssh_private_key_file: ~/.ssh/savvy_azure_key
ansible_python_interpreter: /usr/bin/python3
- import_playbook: provision.yml
vars:
target: azure-vm
staging: false
- import_playbook: add-host.yml
vars:
prometheus_host: azure-vm