Skip to content

Commit 30beadb

Browse files
authored
Modify naming in the cloud resources and client config files (#1353)
* Modify naming in the cloud resources and client config files * Azure template: Eliminate unneeded variables
1 parent 4ae5972 commit 30beadb

File tree

6 files changed

+42
-63
lines changed

6 files changed

+42
-63
lines changed

roles/cloud-azure/files/deployment.json

+22-28
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json",
33
"contentVersion": "1.0.0.0",
44
"parameters": {
5-
"AlgoServerName": {
6-
"type": "string"
7-
},
85
"sshKeyData": {
96
"type": "string"
107
},
11-
"location": {
12-
"type": "string"
13-
},
148
"WireGuardPort": {
159
"type": "int"
1610
},
@@ -22,15 +16,15 @@
2216
}
2317
},
2418
"variables": {
25-
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', parameters('AlgoServerName'))]",
26-
"subnet1Ref": "[concat(variables('vnetID'),'/subnets/', parameters('AlgoServerName'))]"
19+
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', resourceGroup().name)]",
20+
"subnet1Ref": "[concat(variables('vnetID'),'/subnets/', resourceGroup().name)]"
2721
},
2822
"resources": [
2923
{
3024
"apiVersion": "2015-06-15",
3125
"type": "Microsoft.Network/networkSecurityGroups",
32-
"name": "[parameters('AlgoServerName')]",
33-
"location": "[parameters('location')]",
26+
"name": "[resourceGroup().name]",
27+
"location": "[resourceGroup().location]",
3428
"properties": {
3529
"securityRules": [
3630
{
@@ -95,17 +89,17 @@
9589
{
9690
"apiVersion": "2015-06-15",
9791
"type": "Microsoft.Network/publicIPAddresses",
98-
"name": "[parameters('AlgoServerName')]",
99-
"location": "[parameters('location')]",
92+
"name": "[resourceGroup().name]",
93+
"location": "[resourceGroup().location]",
10094
"properties": {
10195
"publicIPAllocationMethod": "Static"
10296
}
10397
},
10498
{
10599
"apiVersion": "2015-06-15",
106100
"type": "Microsoft.Network/virtualNetworks",
107-
"name": "[parameters('AlgoServerName')]",
108-
"location": "[parameters('location')]",
101+
"name": "[resourceGroup().name]",
102+
"location": "[resourceGroup().location]",
109103
"properties": {
110104
"addressSpace": {
111105
"addressPrefixes": [
@@ -114,7 +108,7 @@
114108
},
115109
"subnets": [
116110
{
117-
"name": "[parameters('AlgoServerName')]",
111+
"name": "[resourceGroup().name]",
118112
"properties": {
119113
"addressPrefix": "10.10.0.0/24"
120114
}
@@ -125,24 +119,24 @@
125119
{
126120
"apiVersion": "2015-06-15",
127121
"type": "Microsoft.Network/networkInterfaces",
128-
"name": "[parameters('AlgoServerName')]",
129-
"location": "[parameters('location')]",
122+
"name": "[resourceGroup().name]",
123+
"location": "[resourceGroup().location]",
130124
"dependsOn": [
131-
"[concat('Microsoft.Network/networkSecurityGroups/', parameters('AlgoServerName'))]",
132-
"[concat('Microsoft.Network/publicIPAddresses/', parameters('AlgoServerName'))]",
133-
"[concat('Microsoft.Network/virtualNetworks/', parameters('AlgoServerName'))]"
125+
"[concat('Microsoft.Network/networkSecurityGroups/', resourceGroup().name)]",
126+
"[concat('Microsoft.Network/publicIPAddresses/', resourceGroup().name)]",
127+
"[concat('Microsoft.Network/virtualNetworks/', resourceGroup().name)]"
134128
],
135129
"properties": {
136130
"networkSecurityGroup": {
137-
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('AlgoServerName'))]"
131+
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', resourceGroup().name)]"
138132
},
139133
"ipConfigurations": [
140134
{
141135
"name": "ipconfig1",
142136
"properties": {
143137
"privateIPAllocationMethod": "Dynamic",
144138
"publicIPAddress": {
145-
"id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('AlgoServerName'))]"
139+
"id": "[resourceId('Microsoft.Network/publicIPAddresses', resourceGroup().name)]"
146140
},
147141
"subnet": {
148142
"id": "[variables('subnet1Ref')]"
@@ -155,17 +149,17 @@
155149
{
156150
"apiVersion": "2016-04-30-preview",
157151
"type": "Microsoft.Compute/virtualMachines",
158-
"name": "[parameters('AlgoServerName')]",
159-
"location": "[parameters('location')]",
152+
"name": "[resourceGroup().name]",
153+
"location": "[resourceGroup().location]",
160154
"dependsOn": [
161-
"[concat('Microsoft.Network/networkInterfaces/', parameters('AlgoServerName'))]"
155+
"[concat('Microsoft.Network/networkInterfaces/', resourceGroup().name)]"
162156
],
163157
"properties": {
164158
"hardwareProfile": {
165159
"vmSize": "[parameters('vmSize')]"
166160
},
167161
"osProfile": {
168-
"computerName": "[parameters('AlgoServerName')]",
162+
"computerName": "[resourceGroup().name]",
169163
"adminUsername": "ubuntu",
170164
"linuxConfiguration": {
171165
"disablePasswordAuthentication": true,
@@ -193,7 +187,7 @@
193187
"networkProfile": {
194188
"networkInterfaces": [
195189
{
196-
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('AlgoServerName'))]"
190+
"id": "[resourceId('Microsoft.Network/networkInterfaces', resourceGroup().name)]"
197191
}
198192
]
199193
}
@@ -203,7 +197,7 @@
203197
"outputs": {
204198
"publicIPAddresses": {
205199
"type": "string",
206-
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses',parameters('AlgoServerName')),providers('Microsoft.Network', 'publicIPAddresses').apiVersions[0]).ipAddress]",
200+
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses',resourceGroup().name),providers('Microsoft.Network', 'publicIPAddresses').apiVersions[0]).ipAddress]",
207201
}
208202
}
209203
}

roles/cloud-azure/tasks/main.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@
1616
- name: Create AlgoVPN Server
1717
azure_rm_deployment:
1818
state: present
19-
deployment_name: "AlgoVPN-{{ algo_server_name }}"
19+
deployment_name: "{{ algo_server_name }}"
2020
template: "{{ lookup('file', 'deployment.json') }}"
2121
secret: "{{ secret }}"
2222
tenant: "{{ tenant }}"
2323
client_id: "{{ client_id }}"
2424
subscription_id: "{{ subscription_id }}"
25-
resource_group_name: "AlgoVPN-{{ algo_server_name }}"
25+
resource_group_name: "{{ algo_server_name }}"
26+
location: "{{ algo_region }}"
2627
parameters:
27-
AlgoServerName:
28-
value: "{{ algo_server_name }}"
2928
sshKeyData:
3029
value: "{{ lookup('file', '{{ SSH_keys.public }}') }}"
31-
location:
32-
value: "{{ algo_region }}"
3330
WireGuardPort:
3431
value: "{{ wireguard_port }}"
3532
vmSize:

roles/cloud-ec2/files/stack.yml

+7-19
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ Resources:
2121
InstanceTenancy: default
2222
Tags:
2323
- Key: Name
24-
Value: Algo
25-
- Key: Environment
26-
Value: Algo
24+
Value: !Ref AWS::StackName
2725

2826
VPCIPv6:
2927
Type: AWS::EC2::VPCCidrBlock
@@ -35,22 +33,18 @@ Resources:
3533
Type: AWS::EC2::InternetGateway
3634
Properties:
3735
Tags:
38-
- Key: Environment
39-
Value: Algo
4036
- Key: Name
41-
Value: Algo
37+
Value: !Ref AWS::StackName
4238

4339
Subnet:
4440
Type: AWS::EC2::Subnet
4541
Properties:
4642
CidrBlock: 172.16.254.0/23
4743
MapPublicIpOnLaunch: false
44+
VpcId: !Ref VPC
4845
Tags:
49-
- Key: Environment
50-
Value: Algo
5146
- Key: Name
52-
Value: Algo
53-
VpcId: !Ref VPC
47+
Value: !Ref AWS::StackName
5448

5549
VPCGatewayAttachment:
5650
Type: AWS::EC2::VPCGatewayAttachment
@@ -63,10 +57,8 @@ Resources:
6357
Properties:
6458
VpcId: !Ref VPC
6559
Tags:
66-
- Key: Environment
67-
Value: Algo
6860
- Key: Name
69-
Value: Algo
61+
Value: !Ref AWS::StackName
7062

7163
Route:
7264
Type: AWS::EC2::Route
@@ -140,9 +132,7 @@ Resources:
140132
CidrIp: 0.0.0.0/0
141133
Tags:
142134
- Key: Name
143-
Value: Algo
144-
- Key: Environment
145-
Value: Algo
135+
Value: !Ref AWS::StackName
146136

147137
EC2Instance:
148138
Type: AWS::EC2::Instance
@@ -181,9 +171,7 @@ Resources:
181171
cfn-signal -e $? --stack ${AWS::StackName} --resource EC2Instance --region ${AWS::Region}
182172
Tags:
183173
- Key: Name
184-
Value: Algo
185-
- Key: Environment
186-
Value: Algo
174+
Value: !Ref AWS::StackName
187175

188176
ElasticIP:
189177
Type: AWS::EC2::EIP

roles/cloud-gce/tasks/main.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
- name: Network configured
1010
gce_net:
11-
name: "algo-net-{{ algo_server_name }}"
12-
fwname: "algo-net-{{ algo_server_name }}-fw"
11+
name: "{{ algo_server_name }}"
12+
fwname: "{{ algo_server_name }}-fw"
1313
allowed: "udp:500,4500,{{ wireguard_port }};tcp:22"
1414
state: "present"
1515
mode: auto
@@ -45,7 +45,7 @@
4545
credentials_file: "{{ credentials_file_path }}"
4646
project_id: "{{ project_id }}"
4747
metadata: '{"ssh-keys":"ubuntu:{{ ssh_public_key_lookup }}"}'
48-
network: "algo-net-{{ algo_server_name }}"
48+
network: "{{ algo_server_name }}"
4949
tags:
5050
- "environment-algo"
5151
register: google_vm

roles/strongswan/templates/client_windows.ps1.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Save the embedded CA cert and encrypted user PKCS12 file.
8585
$ErrorActionPreference = "Stop"
8686

8787
$VpnServerAddress = "{{ IP_subject_alt_name }}"
88-
$VpnName = "Algo VPN {{ IP_subject_alt_name }} IKEv2"
88+
$VpnName = "AlgoVPN {{ algo_server_name }} IKEv2"
8989
$VpnUser = "{{ item.0 }}"
9090
$CaCertificateBase64 = "{{ PayloadContentCA }}"
9191
$UserPkcs12Base64 = "{{ item.1.stdout }}"

roles/strongswan/templates/mobileconfig.j2

+6-6
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
<key>PayloadDescription</key>
117117
<string>Configures VPN settings</string>
118118
<key>PayloadDisplayName</key>
119-
<string>VPN</string>
119+
<string>{{ algo_server_name }}</string>
120120
<key>PayloadIdentifier</key>
121121
<string>com.apple.vpn.managed.{{ VPN_PayloadIdentifier }}</string>
122122
<key>PayloadType</key>
@@ -133,7 +133,7 @@
133133
<integer>0</integer>
134134
</dict>
135135
<key>UserDefinedName</key>
136-
<string>Algo VPN {{ IP_subject_alt_name }} IKEv2</string>
136+
<string>AlgoVPN {{ algo_server_name }} IKEv2</string>
137137
<key>VPNType</key>
138138
<string>IKEv2</string>
139139
</dict>
@@ -149,7 +149,7 @@
149149
<key>PayloadDescription</key>
150150
<string>Adds a PKCS#12-formatted certificate</string>
151151
<key>PayloadDisplayName</key>
152-
<string>{{ item.0 }}.p12</string>
152+
<string>{{ algo_server_name }}</string>
153153
<key>PayloadIdentifier</key>
154154
<string>com.apple.security.pkcs12.{{ pkcs12_PayloadCertificateUUID }}</string>
155155
<key>PayloadType</key>
@@ -169,7 +169,7 @@
169169
<key>PayloadDescription</key>
170170
<string>Adds a CA root certificate</string>
171171
<key>PayloadDisplayName</key>
172-
<string>{{ IP_subject_alt_name }}</string>
172+
<string>{{ algo_server_name }}</string>
173173
<key>PayloadIdentifier</key>
174174
<string>com.apple.security.root.{{ CA_PayloadIdentifier }}</string>
175175
<key>PayloadType</key>
@@ -181,11 +181,11 @@
181181
</dict>
182182
</array>
183183
<key>PayloadDisplayName</key>
184-
<string>{{ IP_subject_alt_name }} IKEv2</string>
184+
<string>AlgoVPN {{ algo_server_name }} IKEv2</string>
185185
<key>PayloadIdentifier</key>
186186
<string>donut.local.{{ 500000 | random | to_uuid | upper }}</string>
187187
<key>PayloadOrganization</key>
188-
<string>Algo VPN</string>
188+
<string>AlgoVPN</string>
189189
<key>PayloadRemovalDisallowed</key>
190190
<false/>
191191
<key>PayloadType</key>

0 commit comments

Comments
 (0)