cloudscale_ch.cloud.custom_image (2.3.1) — module

Manage custom images on the cloudscale.ch IaaS service

| "added in version" 2.2.0 of cloudscale_ch.cloud"

Authors: Ciril Troxler (@ctx), Gaudenz Steinlin (@gaudenz)

Install collection

Install with ansible-galaxy collection install cloudscale_ch.cloud:==2.3.1


Add to requirements.yml

  collections:
    - name: cloudscale_ch.cloud
      version: 2.3.1

Description

Import, modify and delete custom images.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete custom image
  cloudscale_ch.cloud.custom_image:
    uuid: '{{ my_custom_image.uuid }}'
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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" ) }}'

Inputs

    
url:
    description:
    - The URL used to download the image.
    type: str

name:
    description:
    - The human readable name of the custom image. Either name or UUID must be present
      to change an existing image.
    type: str

slug:
    description:
    - A string identifying the custom image for use within the API.
    type: str

tags:
    description:
    - The tags assigned to the custom image.
    type: dict

uuid:
    description:
    - The unique identifier of the custom image import. Either name or UUID must be present
      to change an existing image.
    type: str

state:
    choices:
    - present
    - absent
    default: present
    description: State of the coustom image.
    type: str

zones:
    description:
    - Specify zones in which the custom image will be available (e.g. C(lpg1) or C(rma1)).
    elements: str
    type: list

api_url:
    default: https://api.cloudscale.ch/v1
    description:
    - cloudscale.ch API URL.
    - This can also be passed in the C(CLOUDSCALE_API_URL) environment variable.
    type: str
    version_added: 1.3.0
    version_added_collection: cloudscale_ch.cloud

api_token:
    description:
    - cloudscale.ch API token.
    - This can also be passed in the C(CLOUDSCALE_API_TOKEN) environment variable.
    required: true
    type: str

api_timeout:
    default: 45
    description:
    - Timeout in seconds for calls to the cloudscale.ch API.
    - This can also be passed in the C(CLOUDSCALE_API_TIMEOUT) environment variable.
    type: int

force_retry:
    default: false
    description:
    - 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.
    type: bool

firmware_type:
    choices:
    - bios
    - uefi
    default: bios
    description:
    - The firmware type that will be used for servers created with this image.
    type: str

source_format:
    description:
    - The file format of the image referenced in the url. Currently only raw is supported.
    type: str

user_data_handling:
    choices:
    - pass-through
    - extend-cloud-config
    description:
    - How user_data will be handled when creating a server. There are currently two options,
      "pass-through" and "extend-cloud-config".
    type: str

Outputs

checksums:
  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
  type: dict
created_at:
  description: The creation date and time of the resource.
  returned: success
  sample: '2020-05-29T13:18:42.511407Z'
  type: str
error_message:
  description: Error message in case of a failed import.
  returned: success
  sample: Expected HTTP 200, got HTTP 403
  type: str
href:
  description: 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
  type: str
import_status:
  description: Shows the progress of an import. Values are one of "started", "in_progress",
    "success" or "failed".
  returned: success
  sample: in_progress
  type: str
name:
  description: The human readable name of the custom image.
  returned: success
  sample: alan
  type: str
slug:
  description: A string identifying the custom image for use within the API.
  returned: success
  sample: foo
  type: str
state:
  description: The current status of the custom image.
  returned: success
  sample: present
  type: str
tags:
  description: Tags assosiated with the custom image.
  returned: success
  sample:
    project: my project
  type: dict
user_data_handling:
  description: 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
  type: str
uuid:
  description: The unique identifier of the custom image.
  returned: success
  sample: 11111111-1864-4608-853a-0771b6885a3a
  type: str