Currently, Azure, vSphere, and OpenStack are supported. See https://github.com/weldr/lorax/pull/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
48 lines
1.8 KiB
YAML
48 lines
1.8 KiB
YAML
- 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 }}"
|