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.2.2).
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 version 2.2.0: of cloudscale_ch.cloud
Parameters
Parameter |
Comments |
---|---|
Timeout in seconds for calls to the cloudscale.ch API. This can also be passed in the Default: 45 |
|
cloudscale.ch API token. This can also be passed in the |
|
cloudscale.ch API URL. This can also be passed in the Default: “https://api.cloudscale.ch/v1” |
|
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: 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: {“md5”: “5b3a1f21cde154cfb522b582f44f1a87”, “sha256”: “5b03bcbd00b687e08791694e47d235a487c294e58ca3b1af704120123aa3f4e6”} |
|
The creation date and time of the resource. Returned: success Sample: “2020-05-29T13:18:42.511407Z” |
|
Error message in case of a failed import. Returned: success Sample: “Expected HTTP 200, got HTTP 403” |
|
The API URL to get details about this resource. Returned: success when state == present Sample: “https://api.cloudscale.ch/v1/custom-imges/11111111-1864-4608-853a-0771b6885a3a” |
|
Shows the progress of an import. Values are one of “started”, “in_progress”, “success” or “failed”. Returned: success Sample: “in_progress” |
|
The human readable name of the custom image. Returned: success Sample: “alan” |
|
A string identifying the custom image for use within the API. Returned: success Sample: “foo” |
|
The current status of the custom image. Returned: success Sample: “present” |
|
Tags assosiated with the custom image. Returned: success Sample: {“project”: “my project”} |
|
How user_data will be handled when creating a server. There are currently two options, “pass-through” and “extend-cloud-config”. Returned: success Sample: “pass-through” |
|
The unique identifier of the custom image. Returned: success Sample: “11111111-1864-4608-853a-0771b6885a3a” |
Authors
Ciril Troxler (@ctx)
Gaudenz Steinlin (@gaudenz)