forked from weldr/lorax
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically upload composed images to the cloud
Currently, Azure, vSphere, and OpenStack are supported. See weldr#826 for more details about this new feature. I've called the upload library "lifted" as a reference to Seuss' The Lorax -- in the book, the Lorax lifts himself up by the seat of his pants through a hole in the smog clouds, and they start calling him the "Lifted Lorax." This adds new features to the /compose route under API v1
- Loading branch information
1 parent
71efbaf
commit 3eaf40f
Showing
20 changed files
with
1,443 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
- hosts: localhost | ||
connection: local | ||
tasks: | ||
- name: Make sure provided credentials work and the storage account exists | ||
azure_rm_storageaccount_facts: | ||
subscription_id: "{{ subscription_id }}" | ||
client_id: "{{ client_id }}" | ||
secret: "{{ secret }}" | ||
tenant: "{{ tenant }}" | ||
resource_group: "{{ resource_group }}" | ||
name: "{{ storage_account_name }}" | ||
register: storageaccount_facts | ||
- name: Fail if we couldn't log in or the storage account was not found | ||
fail: | ||
msg: "Invalid credentials or storage account not found!" | ||
when: storageaccount_facts.ansible_facts.azure_storageaccounts | length < 1 | ||
- stat: | ||
path: "{{ image_path }}" | ||
register: image_stat | ||
- set_fact: | ||
image_id: "{{ image_name }}-{{ image_stat['stat']['checksum'] }}.vhd" | ||
- name: Upload image to Azure | ||
azure_rm_storageblob: | ||
subscription_id: "{{ subscription_id }}" | ||
client_id: "{{ client_id }}" | ||
secret: "{{ secret }}" | ||
tenant: "{{ tenant }}" | ||
resource_group: "{{ resource_group }}" | ||
storage_account_name: "{{ storage_account_name }}" | ||
container: "{{ storage_container }}" | ||
src: "{{ image_path }}" | ||
blob: "{{ image_id }}" | ||
blob_type: page | ||
force: no | ||
- set_fact: | ||
host: "{{ storage_account_name }}.blob.core.windows.net" | ||
- name: Import image | ||
azure_rm_image: | ||
subscription_id: "{{ subscription_id }}" | ||
client_id: "{{ client_id }}" | ||
secret: "{{ secret }}" | ||
tenant: "{{ tenant }}" | ||
resource_group: "{{ resource_group }}" | ||
name: "{{ image_name }}" | ||
os_type: Linux | ||
location: "{{ location }}" | ||
source: "https://{{ host }}/{{ storage_container }}/{{ image_id }}" |
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,53 @@ | ||
display = "Azure" | ||
|
||
supported_types = [ | ||
"vhd", | ||
] | ||
|
||
[settings-info.resource_group] | ||
display = "Resource group" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.storage_account_name] | ||
display = "Storage account name" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.storage_container] | ||
display = "Storage container" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.subscription_id] | ||
display = "Subscription ID" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.client_id] | ||
display = "Client ID" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.secret] | ||
display = "Secret" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.tenant] | ||
display = "Tenant" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.location] | ||
display = "Location" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' |
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,4 @@ | ||
- hosts: localhost | ||
connection: local | ||
tasks: | ||
- pause: seconds=30 |
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,4 @@ | ||
display = "Dummy" | ||
|
||
[settings-info] | ||
# This provider has no settings. |
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,20 @@ | ||
- hosts: localhost | ||
connection: local | ||
tasks: | ||
- stat: | ||
path: "{{ image_path }}" | ||
register: image_stat | ||
- set_fact: | ||
image_id: "{{ image_name }}-{{ image_stat['stat']['checksum'] }}.qcow2" | ||
- name: Upload image to OpenStack | ||
os_image: | ||
auth: | ||
auth_url: "{{ auth_url }}" | ||
username: "{{ username }}" | ||
password: "{{ password }}" | ||
project_name: "{{ project_name }}" | ||
os_user_domain_name: "{{ user_domain_name }}" | ||
os_project_domain_name: "{{ project_domain_name }}" | ||
name: "{{ image_id }}" | ||
filename: "{{ image_path }}" | ||
is_public: "{{ is_public }}" |
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,45 @@ | ||
display = "OpenStack" | ||
|
||
supported_types = [ | ||
"qcow2", | ||
] | ||
|
||
[settings-info.auth_url] | ||
display = "Authentication URL" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.username] | ||
display = "Username" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.password] | ||
display = "Password" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.project_name] | ||
display = "Project name" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.user_domain_name] | ||
display = "User domain name" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.project_domain_name] | ||
display = "Project domain name" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.is_public] | ||
display = "Allow public access" | ||
type = "boolean" |
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 @@ | ||
- hosts: localhost | ||
connection: local | ||
tasks: | ||
- stat: | ||
path: "{{ image_path }}" | ||
register: image_stat | ||
- set_fact: | ||
image_id: "{{ image_name }}-{{ image_stat['stat']['checksum'] }}.vmdk" | ||
- name: Upload image to vSphere | ||
vsphere_copy: | ||
login: "{{ username }}" | ||
password: "{{ password }}" | ||
host: "{{ host }}" | ||
datacenter: "{{ datacenter }}" | ||
datastore: "{{ datastore }}" | ||
src: "{{ image_path }}" | ||
path: "{{ folder }}/{{ image_id }}" |
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,42 @@ | ||
display = "vSphere" | ||
|
||
supported_types = [ | ||
"vmdk", | ||
] | ||
|
||
[settings-info.datacenter] | ||
display = "Datacenter" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.datastore] | ||
display = "Datastore" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.host] | ||
display = "Host" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.folder] | ||
display = "Folder" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.username] | ||
display = "Username" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
||
[settings-info.password] | ||
display = "Password" | ||
type = "string" | ||
placeholder = "" | ||
regex = '' | ||
|
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,16 @@ | ||
# | ||
# Copyright (C) 2019 Red Hat, Inc. | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# |
Oops, something went wrong.