community.general.one_image module – Manages OpenNebula images

Note

This module is part of the community.general collection (version 10.1.0).

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 community.general. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: community.general.one_image.

Synopsis

  • Manages OpenNebula images

Requirements

The below requirements are needed on the host that executes this module.

  • pyone

Parameters

Parameter

Comments

api_password

aliases: api_token

string

The password or token for XMLRPC authentication.

If not specified then the value of the ONE_PASSWORD environment variable, if any, is used.

api_url

aliases: api_endpoint

string

The ENDPOINT URL of the XMLRPC server.

If not specified then the value of the ONE_URL environment variable, if any, is used.

api_username

string

The name of the user for XMLRPC authentication.

If not specified then the value of the ONE_USERNAME environment variable, if any, is used.

create

boolean

added in community.general 10.0.0

Whether the image should be created if not present.

This is ignored if state=absent.

Choices:

  • false

  • true

datastore_id

integer

added in community.general 10.0.0

Use with create=true to specify datastore for image.

enabled

boolean

Whether the image should be enabled or disabled.

Choices:

  • false

  • true

id

integer

A id of the image you would like to manage.

name

string

A name of the image you would like to manage.

Required if create=true.

new_name

string

A name that will be assigned to the existing or new image.

In the case of cloning, by default new_name will take the name of the origin image with the prefix ‘Copy of’.

persistent

boolean

added in community.general 9.5.0

Whether the image should be persistent or non-persistent.

Choices:

  • false

  • true

state

string

present - state that is used to manage the image.

absent - delete the image.

cloned - clone the image.

renamed - rename the image to the new_name.

Choices:

  • "present" ← (default)

  • "absent"

  • "cloned"

  • "renamed"

template

string

added in community.general 10.0.0

Use with create=true to specify image template.

validate_certs

boolean

Whether to validate the TLS/SSL certificates or not.

This parameter is ignored if PYTHONHTTPSVERIFY environment variable is used.

Choices:

  • false

  • true ← (default)

wait_timeout

integer

added in community.general 10.0.0

Seconds to wait until image is ready, deleted or cloned.

Default: 60

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Examples

- name: Fetch the IMAGE by id
  community.general.one_image:
    id: 45
  register: result

- name: Print the IMAGE properties
  ansible.builtin.debug:
    var: result

- name: Rename existing IMAGE
  community.general.one_image:
    id: 34
    state: renamed
    new_name: bar-image

- name: Disable the IMAGE by id
  community.general.one_image:
    id: 37
    enabled: false

- name: Make the IMAGE persistent
  community.general.one_image:
    id: 37
    persistent: true

- name: Enable the IMAGE by name
  community.general.one_image:
    name: bar-image
    enabled: true

- name: Clone the IMAGE by name
  community.general.one_image:
    name: bar-image
    state: cloned
    new_name: bar-image-clone
  register: result

- name: Delete the IMAGE by id
  community.general.one_image:
    id: '{{ result.id }}'
    state: absent

- name: Make sure IMAGE is present
  community.general.one_image:
    name: myyy-image
    state: present
    create: true
    datastore_id: 100
    template: |
      PATH = "/var/tmp/image"
      TYPE = "OS"
      SIZE = 20512
      FORMAT = "qcow2"
      PERSISTENT = "Yes"
      DEV_PREFIX = "vd"

- name: Make sure IMAGE is present with a longer timeout
  community.general.one_image:
    name: big-image
    state: present
    create: true
    datastore_id: 100
    wait_timeout: 900
    template: |
      PATH = "https://192.0.2.200/repo/tipa_image.raw"
      TYPE = "OS"
      SIZE = 82048
      FORMAT = "raw"
      PERSISTENT = "Yes"
      DEV_PREFIX = "vd"

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

app_clones

list / elements=integer

added in community.general 9.5.0

The image’s list of app_clones ID’s.

Returned: when state=present, state=cloned, or state=renamed

Sample: [1, 2, 3]

clones

list / elements=integer

added in community.general 9.5.0

The image’s list of clones ID’s.

Returned: when state=present, state=cloned, or state=renamed

Sample: [1, 2, 3]

cloning_id

integer

added in community.general 9.5.0

The image’s cloning ID.

Returned: when state=present, state=cloned, or state=renamed

Sample: -1

cloning_ops

integer

added in community.general 9.5.0

The image’s cloning operations per second.

Returned: when state=present, state=cloned, or state=renamed

Sample: 0

datastore

integer

added in community.general 9.5.0

The image’s datastore name.

Returned: when state=present, state=cloned, or state=renamed

Sample: "image_datastore"

datastore_id

integer

added in community.general 9.5.0

The image’s datastore ID.

Returned: when state=present, state=cloned, or state=renamed

Sample: 100

disk_type

string

added in community.general 9.5.0

The image’s format type.

Returned: when state=present, state=cloned, or state=renamed

Sample: "0"

fstype

string

added in community.general 9.5.0

The image’s filesystem type.

Returned: when state=present, state=cloned, or state=renamed

Sample: "ext4"

group_id

integer

image’s group id

Returned: when state=present, state=cloned, or state=renamed

Sample: 1

group_name

string

image’s group name

Returned: when state=present, state=cloned, or state=renamed

Sample: "one-users"

id

integer

image id

Returned: when state=present, state=cloned, or state=renamed

Sample: 153

name

string

image name

Returned: when state=present, state=cloned, or state=renamed

Sample: "app1"

owner_id

integer

image’s owner id

Returned: when state=present, state=cloned, or state=renamed

Sample: 143

owner_name

string

image’s owner name

Returned: when state=present, state=cloned, or state=renamed

Sample: "ansible-test"

path

string

added in community.general 9.5.0

The image’s filesystem path.

Returned: when state=present, state=cloned, or state=renamed

Sample: "/var/tmp/hello.qcow2"

permissions

dictionary

added in community.general 9.5.0

The image’s permissions.

Returned: when state=present, state=cloned, or state=renamed

Sample: {"group_a": 0, "group_m": 0, "group_u": 0, "other_a": 0, "other_m": 0, "other_u": 0, "owner_a": 0, "owner_m": 0, "owner_u": 1}

group_a

string

The image’s group ADMIN permissions.

Returned: success

Sample: "0"

group_m

string

The image’s group MANAGE permissions.

Returned: success

Sample: "0"

group_u

string

The image’s group USAGE permissions.

Returned: success

Sample: "0"

other_a

string

The image’s other users ADMIN permissions

Returned: success

Sample: "0"

other_m

string

The image’s other users MANAGE permissions.

Returned: success

Sample: "0"

other_u

string

The image’s other users USAGE permissions.

Returned: success

Sample: "0"

owner_a

string

The image’s owner ADMIN permissions.

Returned: success

Sample: "0"

owner_m

string

The image’s owner MANAGE permissions.

Returned: success

Sample: "0"

owner_u

string

The image’s owner USAGE permissions.

Returned: success

Sample: "1"

persistent

integer

added in community.general 9.5.0

The image’s persistence status (1 means true, 0 means false).

Returned: when state=present, state=cloned, or state=renamed

Sample: 1

running_vms

integer

count of running vms that use this image

Returned: when state=present, state=cloned, or state=renamed

Sample: 7

size

integer

added in community.general 9.5.0

The image’s size in MegaBytes.

Returned: when state=present, state=cloned, or state=renamed

Sample: 10000

snapshots

list / elements=string

added in community.general 9.5.0

The image’s list of snapshots.

Returned: when state=present, state=cloned, or state=renamed

Sample: [{"active": 1, "allow_orphans": 1, "children": 0, "date": 123123, "name": "SampleName", "parent": 1, "size": 10228}]

source

string

The image’s source.

Returned: when state=present, state=cloned, or state=renamed

Sample: "/var/lib/one//datastores/100/somerandomstringxd"

state

string

state of image instance

Returned: when state=present, state=cloned, or state=renamed

Sample: "READY"

target_snapshot

integer

added in community.general 9.5.0

The image’s target snapshot.

Returned: when state=present, state=cloned, or state=renamed

Sample: 1

type

string

added in community.general 9.5.0

The image’s type.

Returned: when state=present, state=cloned, or state=renamed

Sample: "0"

used

boolean

is image in use

Returned: when state=present, state=cloned, or state=renamed

Sample: true

vms

list / elements=integer

added in community.general 9.5.0

The image’s list of vm ID’s.

Returned: when state=present, state=cloned, or state=renamed

Sample: [1, 2, 3]

Authors

  • Milan Ilic (@ilicmilan)