-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path39976.yml
128 lines (114 loc) · 3.79 KB
/
39976.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---
- name: For Azure learn
hosts: localhost
connection: local
vars:
resource_group: myRG03
location: westeurope
virtualnetwork: virtualnetwork03
internal_virtualnetwork: internal_virtualnetwork03
internal_subnet: internal_subnet03
internal_public_ip: internal_public_ip03
internal_security_ssh: internal_security_ssh03
internal_test_nic: internal_test_nic03
external_virtualnetwork: external_virtualnetwork03
external_subnet: external_subnet03
external_public_ip: external_public_ip03
external_security_ssh: external_security_ssh03
external_test_nic: external_test_nic03
vm_name: myVM03
tasks:
- name: create resource group
azure_rm_resourcegroup:
name: "{{ resource_group }}"
location: "{{ location }}"
- name: create virtual network
azure_rm_virtualnetwork:
resource_group: "{{ resource_group }}"
name: "{{ virtualnetwork }}"
address_prefixes: "10.0.0.0/16"
- name: Add subnet-internal
azure_rm_subnet:
resource_group: "{{ resource_group }}"
name: "{{ internal_subnet }}"
address_prefix: "10.0.10.0/24"
virtual_network: "{{ virtualnetwork }}"
- name: create public ip-internal
azure_rm_publicipaddress:
resource_group: "{{ resource_group }}"
allocation_method: Static
name: "{{ internal_public_ip }}"
- name: Create security group that allows SSH-internal
azure_rm_securitygroup:
resource_group: "{{ resource_group }}"
name: "{{ internal_security_ssh }}"
rules:
- name: SSH
protocol: Tcp
destination_port_range: 22
access: Allow
priority: 101
direction: Inbound
- name: Add subnet-external
azure_rm_subnet:
resource_group: "{{ resource_group }}"
name: "{{ external_subnet }}"
address_prefix: "10.0.1.0/24"
virtual_network: "{{ virtualnetwork }}"
- name: create public ip-external
azure_rm_publicipaddress:
resource_group: "{{ resource_group }}"
allocation_method: Static
name: "{{ external_public_ip }}"
- name: Create security group that allows SSH-external
azure_rm_securitygroup:
resource_group: "{{ resource_group }}"
name: "{{ external_security_ssh }}"
rules:
- name: SSH
protocol: Tcp
destination_port_range: 22
access: Allow
priority: 101
direction: Inbound
- azure_rm_networkinterface:
resource_group: "{{ resource_group }}"
name: "{{ external_test_nic }}"
virtual_network: "{{ virtualnetwork }}"
subnet_name: "{{ external_subnet }}"
security_group_name: "{{ external_security_ssh }}"
ip_configurations:
- name: ipconfig1
public_ip_address_name: "{{ external_public_ip }}"
primary: yes
- azure_rm_networkinterface:
resource_group: "{{ resource_group }}"
name: "{{ internal_test_nic }}"
virtual_network: "{{ virtualnetwork }}"
subnet_name: "{{ internal_subnet }}"
security_group_name: "{{ internal_security_ssh }}"
ip_configurations:
- name: ipconfig1
primary: no
- azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
location: "{{ location }}"
name: "{{ vm_name }}"
network_interface_names:
- "{{ internal_test_nic }}"
- "{{ external_test_nic }}"
vm_size: Standard_A0
admin_username: azuerser
ssh_password_enabled: False
ssh_public_keys:
- path: "/home/azuerser/.ssh/authorized_keys"
key_data: "ssh-rsa ***************fred@fred-Virtual-Machine"
image:
publisher: OpenLogic
offer: CentOS
sku: '7.4'
version: latest
register: create_vm_log
- name: dump crete vm log
debug:
var: create_vm_log