cloudscale_ch.cloud.custom_image module – Manage custom images on the cloudscale.ch IaaS service
Note
This module is part of the cloudscale_ch.cloud collection (version 2.3.1).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install cloudscale_ch.cloud
.
To use it in a playbook, specify: cloudscale_ch.cloud.custom_image
.
New in cloudscale_ch.cloud 2.2.0
Synopsis
Import, modify and delete custom images.
Parameters
Parameter |
Comments |
---|---|
Timeout in seconds for calls to the cloudscale.ch API. This can also be passed in the Default: |
|
cloudscale.ch API token. This can also be passed in the |
|
cloudscale.ch API URL. This can also be passed in the Default: |
|
The firmware type that will be used for servers created with this image. Choices:
|
|
Retry the image import even if a failed import using the same name and URL already exists. This is necessary to recover from download errors. Choices:
|
|
The human readable name of the custom image. Either name or UUID must be present to change an existing image. |
|
A string identifying the custom image for use within the API. |
|
The file format of the image referenced in the url. Currently only raw is supported. |
|
State of the coustom image. Choices:
|
|
The tags assigned to the custom image. |
|
The URL used to download the image. |
|
How user_data will be handled when creating a server. There are currently two options, “pass-through” and “extend-cloud-config”. Choices:
|
|
The unique identifier of the custom image import. Either name or UUID must be present to change an existing image. |
|
Specify zones in which the custom image will be available (e.g. |
Notes
Note
To import a new custom-image the url and name options are required.
All operations are performed using the cloudscale.ch public API v1.
For details consult the full API documentation: https://www.cloudscale.ch/en/api/v1.
A valid API token is required for all operations. You can create as many tokens as you like using the cloudscale.ch control panel at https://control.cloudscale.ch.
Examples
- name: Import custom image
cloudscale_ch.cloud.custom_image:
name: "My Custom Image"
url: https://ubuntu.com/downloads/hirsute.img
slug: my-custom-image
user_data_handling: extend-cloud-config
zones: lpg1
tags:
project: luna
state: present
register: my_custom_image
- name: Wait until import succeeded
cloudscale_ch.cloud.custom_image:
uuid: "{{ my_custom_image.uuid }}"
retries: 15
delay: 5
register: image
until: image.import_status == 'success'
failed_when: image.import_status == 'failed'
- name: Import custom image and wait until import succeeded
cloudscale_ch.cloud.custom_image:
name: "My Custom Image"
url: https://ubuntu.com/downloads/hirsute.img
slug: my-custom-image
user_data_handling: extend-cloud-config
zones: lpg1
tags:
project: luna
state: present
retries: 15
delay: 5
register: image
until: image.import_status == 'success'
failed_when: image.import_status == 'failed'
- name: Import custom image with UEFI firmware type
cloudscale_ch.cloud.custom_image:
name: "My Custom UEFI Image"
url: https://ubuntu.com/downloads/hirsute.img
slug: my-custom-uefi-image
user_data_handling: extend-cloud-config
zones: lpg1
firmware_type: uefi
tags:
project: luna
state: present
register: my_custom_image
- name: Update custom image
cloudscale_ch.cloud.custom_image:
name: "My Custom Image"
slug: my-custom-image
user_data_handling: extend-cloud-config
tags:
project: luna
state: present
- name: Delete custom image
cloudscale_ch.cloud.custom_image:
uuid: '{{ my_custom_image.uuid }}'
state: absent
- name: List all custom images
uri:
url: 'https://api.cloudscale.ch/v1/custom-images'
headers:
Authorization: 'Bearer {{ query("env", "CLOUDSCALE_API_TOKEN") }}'
status_code: 200
register: image_list
- name: Search the image list for all images with name 'My Custom Image'
set_fact:
my_custom_images: '{{ image_list.json | selectattr("name","search", "My Custom Image" ) }}'
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The checksums of the custom image as key and value pairs. The algorithm (e.g. sha256) name is in the key and the checksum in the value. The set of algorithms used might change in the future. Returned: success Sample: |
|
The creation date and time of the resource. Returned: success Sample: |
|
Error message in case of a failed import. Returned: success Sample: |
|
The API URL to get details about this resource. Returned: success when state == present Sample: |
|
Shows the progress of an import. Values are one of “started”, “in_progress”, “success” or “failed”. Returned: success Sample: |
|
The human readable name of the custom image. Returned: success Sample: |
|
A string identifying the custom image for use within the API. Returned: success Sample: |
|
The current status of the custom image. Returned: success Sample: |
|
Tags assosiated with the custom image. Returned: success Sample: |
|
How user_data will be handled when creating a server. There are currently two options, “pass-through” and “extend-cloud-config”. Returned: success Sample: |
|
The unique identifier of the custom image. Returned: success Sample: |