W3cubDocs

/Ansible

cs_template - Manages templates on Apache CloudStack based clouds.

New in version 2.0.

Synopsis

  • Register a template from URL, create a template from a ROOT volume of a stopped VM or its snapshot, extract and delete templates.

Requirements (on host that executes module)

  • python >= 2.6
  • cs >= 0.6.10

Options

parameter required default choices comments
account
no
Account the template, snapshot or VM is related to.
api_http_method
no get
  • get
  • post
HTTP method used.
api_key
no
API key of the CloudStack API.
api_region
no cloudstack
Name of the ini section in the cloustack.ini file.
api_secret
no
Secret key of the CloudStack API.
api_timeout
no 10
HTTP timeout.
api_url
no
URL of the CloudStack API e.g. https://cloud.example.com/client/api.
bits
no 64
32 or 64 bits support.
checksum
no
The MD5 checksum value of this template.
If set, we search by checksum instead of name.
cross_zones
no
Whether the template should be synced or removed across zones.
Only used if state is present or absent.
details
no
Template details in key/value pairs.
display_text
no
Display text of the template.
domain
no
Domain the template, snapshot or VM is related to.
format
no
  • QCOW2
  • RAW
  • VHD
  • OVA
The format for the template.
Relevant when using state=present.
hypervisor
no
  • KVM
  • VMware
  • BareMetal
  • XenServer
  • LXC
  • HyperV
  • UCS
  • OVM
Name the hypervisor to be used for creating the new template.
Relevant when using state=present.
is_dynamically_scalable
no
Register the template having XS/VMWare tools installed in order to support dynamic scaling of VM CPU/memory.
Only used if state is present.
is_extractable
no
True if the template or its derivatives are extractable.
is_featured
no
Register the template to be featured.
Only used if state is present.
is_public
no
Register the template to be publicly available to all users.
Only used if state is present.
is_ready
no
This flag is used for searching existing templates.
If set to true, it will only list template ready for deployment e.g. successfully downloaded and installed.
Recommended to set it to false.
is_routing
no
True if the template type is routing i.e., if template is used to deploy router.
Only considered if url is used.
mode
no http_download
  • http_download
  • ftp_upload
Mode for the template extraction.
Only used if state=extracted.
name
yes
Name of the template.
os_type
no
OS type that best represents the OS of this template.
password_enabled
no
True if the template supports the password reset feature.
poll_async
no True
Poll async jobs until job has finished.
project
no
Name of the project the template to be registered in.
requires_hvm
no
true if this template requires HVM.
snapshot
no
Name of the snapshot, created from the VM ROOT volume, the template will be created from.
vm is required together with this argument.
sshkey_enabled
no
True if the template supports the sshkey upload feature.
state
no present
  • present
  • absent
  • extacted
State of the template.
tags
(added in 2.4)
no
List of tags. Tags are a list of dictionaries having keys key and value.
To delete all tags, set a empty list e.g. tags: [].
aliases: tag
template_filter
no self
  • featured
  • self
  • selfexecutable
  • sharedexecutable
  • executable
  • community
Name of the filter used to search for the template.
template_tag
no
the tag for this template.
url
no
URL of where the template is hosted on state=present.
URL to which the template would be extracted on state=extracted.
Mutually exclusive with vm.
vm
no
VM name the template will be created from its volume or alternatively from a snapshot.
VM must be in stopped state if created from its volume.
Mutually exclusive with url.
zone
no
Name of the zone you wish the template to be registered or deleted from.
If not specified, first found zone will be used.

Examples

# Register a systemvm template
- local_action:
    module: cs_template
    name: systemvm-vmware-4.5
    url: "http://packages.shapeblue.com/systemvmtemplate/4.5/systemvm64template-4.5-vmware.ova"
    hypervisor: VMware
    format: OVA
    cross_zones: yes
    os_type: Debian GNU/Linux 7(64-bit)

# Create a template from a stopped virtual machine's volume
- local_action:
    module: cs_template
    name: debian-base-template
    vm: debian-base-vm
    os_type: Debian GNU/Linux 7(64-bit)
    zone: tokio-ix
    password_enabled: yes
    is_public: yes

# Create a template from a virtual machine's root volume snapshot
- local_action:
    module: cs_template
    name: debian-base-template
    vm: debian-base-vm
    snapshot: ROOT-233_2015061509114
    os_type: Debian GNU/Linux 7(64-bit)
    zone: tokio-ix
    password_enabled: yes
    is_public: yes

# Remove a template
- local_action:
    module: cs_template
    name: systemvm-4.2
    cross_zones: yes
    state: absent

Return Values

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

name description returned type sample
status
Status of the template.
success string Download Complete
is_featured
True if the template is featured.
success boolean True
format
Format of the template.
success string OVA
domain
Domain the template is related to.
success string example domain
is_extractable
True if the template is extractable.
success boolean True
is_public
True if the template is public.
success boolean True
id
UUID of the template.
success string a6f7a5fc-43f8-11e5-a151-feff819cdc9f
tags
List of resource tags associated with the template.
success dict [ { "key": "foo", "value": "bar" } ]
name
Name of the template.
success string Debian 7 64-bit
display_text
Display text of the template.
success string Debian 7.7 64-bit minimal 2015-03-19
project
Name of project the template is related to.
success string Production
account
Account the template is related to.
success string example account
password_enabled
True if the reset password feature is enabled, false otherwise.
success boolean False
zone
Name of zone the template is registered in.
success string zuerich
created
Date of registering.
success string 2015-03-29T14:57:06+0200
url
Url to which the template is extracted to
success string http://1.2.3.4/userdata/eb307f13-4aca-45e8-b157-a414a14e6b04.ova
hypervisor
Hypervisor related to this template.
success string VMware
sshkey_enabled
true if template is sshkey enabled, false otherwise.
success boolean False
cross_zones
true if the template is managed across all zones, false otherwise.
success boolean False
template_type
Type of the template.
success string USER
state
State of the extracted template
success string DOWNLOAD_URL_CREATED
is_ready
True if the template is ready to be deployed from.
success boolean True
mode
Mode of extraction
success string http_download
checksum
MD5 checksum of the template.
success string 0b31bccccb048d20b551f70830bb7ad0
os_type
Typo of the OS.
success string CentOS 6.5 (64-bit)
template_tag
Template tag related to this template.
success string special

Notes

Note

  • Ansible uses the cs library’s configuration method if credentials are not provided by the arguments api_url, api_key, api_secret. Configuration is read from several locations, in the following order. - The CLOUDSTACK_ENDPOINT, CLOUDSTACK_KEY, CLOUDSTACK_SECRET and CLOUDSTACK_METHOD. CLOUDSTACK_TIMEOUT environment variables. - A CLOUDSTACK_CONFIG environment variable pointing to an .ini file, - A cloudstack.ini file in the current working directory. - A .cloudstack.ini file in the users home directory. Optionally multiple credentials and endpoints can be specified using ini sections in cloudstack.ini. Use the argument api_region to select the section name, default section is cloudstack. See https://github.com/exoscale/cs for more information.
  • A detailed guide about cloudstack modules can be found on http://docs.ansible.com/ansible/guide_cloudstack.html
  • This module supports check mode.

Status

This module is flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.

© 2012–2017 Michael DeHaan
© 2017 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/cs_template_module.html