-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1411 from JunqiZhang0/add-api-azure
Merged by Jenkins
- Loading branch information
Showing
15 changed files
with
230 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash -xe | ||
|
||
# Verify the azure vm provisioning | ||
# distros.exclude: none | ||
# providers.include: azure | ||
# providers.exclude: none | ||
|
||
DISTRO=${1} | ||
PROVIDER=${2} | ||
subscriptionid=${3} | ||
resourcegroupname="${DISTRO}-LinchpinCreatedGroup" | ||
providers='compute' | ||
TARGET="azure_api" | ||
vmname="${1}test" | ||
body_path="/workDir/workspace/ci-linchpin/linchpin/docs/source/examples/workspaces/azure/body.json" | ||
pushd docs/source/examples/workspaces/${PROVIDER} | ||
function clean_up { | ||
set +e | ||
linchpin -w . -vvv --template-data '{ "distro": '${DISTRO}', "subscriptionid": '${subscriptionid}',"resourcegroupname": '${resourcegroupname}',"providers": '${providers}',"vmname": '${vmname}',"body_path": '${body_path}'}' destroy "${TARGET}" | ||
linchpin -w . -vvv --template-data '{ "distro": '${DISTRO}'}' destroy "azure_nic" | ||
linchpin -w . -vvv --template-data '{ "distro": '${DISTRO}""'}' destroy "azure_vn" | ||
sed "s/\(\"id\".*\/\).*/\1TestingNIC\",/" ${body_path} -i | ||
sed "s/${resourcegroupname}/REDSOURCEGROUPPLACEHOLDER/" ${body_path} -i | ||
sed "s/${subscriptionid}/SUBSCRIPTIONPLACEHOLDER/" ${body_path} -i | ||
rm -rf resources/ inventories/ | ||
} | ||
|
||
trap clean_up EXIT | ||
|
||
linchpin -w . -vvv --template-data '{ "distro": '${DISTRO}""'}' up "azure_vn" | ||
linchpin -w . -vvv --template-data '{ "distro": '${DISTRO}""'}' up "azure_vn_subnet" | ||
linchpin -w . -vvv --template-data '{ "distro": '${DISTRO}'}' up "azure_nic" | ||
sed "s/\(\"id\".*\/\).*/\1${DISTRO}-forLinchpinautomation\",/" ${body_path} -i | ||
sed "s/REDSOURCEGROUPPLACEHOLDER/${resourcegroupname}/" ${body_path} -i | ||
sed "s/SUBSCRIPTIONPLACEHOLDER/${subscriptionid}/" ${body_path} -i | ||
cat ${body_path} | ||
linchpin -w . -vvv --template-data '{ "distro": '${DISTRO}', "subscriptionid": '${subscriptionid}',"resourcegroupname": '${resourcegroupname}',"providers": '${providers}',"vmname": '${vmname}',"body_path": '${body_path}'}' up "${TARGET}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"location": "centralus", | ||
"properties": { | ||
"hardwareProfile": { | ||
"vmSize": "Standard_D1_v2" | ||
}, | ||
"storageProfile": { | ||
"imageReference": { | ||
"sku": "7.1", | ||
"publisher": "OpenLogic", | ||
"version": "latest", | ||
"offer": "CentOS" | ||
}, | ||
"osDisk": { | ||
"caching": "ReadWrite", | ||
"managedDisk": { | ||
"storageAccountType": "Standard_LRS" | ||
}, | ||
"name": "myVMosdisk", | ||
"createOption": "FromImage" | ||
} | ||
}, | ||
"osProfile": { | ||
"adminUsername": "Linchpin", | ||
"computerName": "myVM", | ||
"adminPassword": "IloveLinchpin!" | ||
}, | ||
"networkProfile": { | ||
"networkInterfaces": [ | ||
{ | ||
"id": "/subscriptions/SUBSCRIPTIONPLACEHOLDER/resourceGroups/REDSOURCEGROUPPLACEHOLDER/providers/Microsoft.Network/networkInterfaces/TestingNIC", | ||
"properties": { | ||
"primary": true | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
linchpin/provision/roles/azure/tasks/provision_azure_api.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
- name: set a body path | ||
set_fact: | ||
body_path: "{{res_def['body_path']|default('{{workspace}}/body.json')}}" | ||
|
||
- debug: | ||
msg: "{{ res_def['url']}}" | ||
|
||
- name: Use Azure Api to manage resources | ||
azure_rm_resource: | ||
client_id: "{{ auth_var['client_id'] | default(omit) }}" | ||
tenant: "{{ auth_var['tenant'] | default(omit) }}" | ||
secret: "{{ auth_var['secret'] | default(omit) }}" | ||
subscription_id: "{{ auth_var['subscription_id'] | default(omit) }}" | ||
api_version: "{{res_def['api_version']|default('2019-03-01')}}" | ||
url: "{{ res_def['url']|default(omit)}}" | ||
body: "{{ lookup('file', body_path) }}" | ||
register: res_def_output | ||
until: res_def_output.response.properties.provisioningState == "Updating" | ||
retries: 30 | ||
delay: 30 | ||
|
||
- name: "Append outputitem to topology_outputs" | ||
set_fact: | ||
topology_outputs_azure_api: "{{ topology_outputs_azure_api + [res_def_output] }}" | ||
when: res_def_output['changed'] == true | ||
|
||
- name: "Add type to resource" | ||
set_fact: | ||
topology_outputs_azure_api: "{{ topology_outputs_azure_api | add_res_data(lookup('vars', 'role_name'),'azure_api') }}" |
2 changes: 1 addition & 1 deletion
2
linchpin/provision/roles/azure/tasks/provision_azure_network_interface.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
linchpin/provision/roles/azure/tasks/teardown_azure_api.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
- name: set a body path | ||
set_fact: | ||
body_path: "{{res_def['body_path']|default('{{workspace}}/body.json')}}" | ||
|
||
- name: Use Azure Api to manage resources | ||
azure_rm_resource: | ||
client_id: "{{ auth_var['client_id'] | default(omit) }}" | ||
tenant: "{{ auth_var['tenant'] | default(omit) }}" | ||
secret: "{{ auth_var['secret'] | default(omit) }}" | ||
subscription_id: "{{ auth_var['subscription_id'] | default(omit) }}" | ||
api_version: "{{res_def['api_version']|default('2019-03-01')}}" | ||
url: "{{ res_def['url']|default(omit)}}" | ||
method: 'DELETE' | ||
polling_timeout: 60 | ||
polling_interval: 10 | ||
body: "{{ lookup('file', body_path) }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters