lorax/share/lifted/providers/azure/playbook.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 }}"