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
The below requirements are needed on the host that executes this module.
- python >= 2.6
- cs >= 0.6.10
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
account | Account the template, snapshot or VM is related to. | |
api_http_method |
| HTTP method used to query the API endpoint. If not given, the CLOUDSTACK_METHOD env variable is considered.As the last option, the value is taken from the ini config file, also see the notes. Fallback value is get if not specified. |
api_key | API key of the CloudStack API. If not given, the CLOUDSTACK_KEY env variable is considered.As the last option, the value is taken from the ini config file, also see the notes. | |
api_region | Default: "cloudstack" | Name of the ini section in the cloustack.ini file.If not given, the CLOUDSTACK_REGION env variable is considered. |
api_secret | Secret key of the CloudStack API. If not set, the CLOUDSTACK_SECRET env variable is considered.As the last option, the value is taken from the ini config file, also see the notes. | |
api_timeout | HTTP timeout in seconds. If not given, the CLOUDSTACK_TIMEOUT env variable is considered.As the last option, the value is taken from the ini config file, also see the notes. Fallback value is 10 seconds if not specified. | |
api_url | URL of the CloudStack API e.g. https://cloud.example.com/client/api. If not given, the CLOUDSTACK_ENDPOINT env variable is considered.As the last option, the value is taken from the ini config file, also see the notes. | |
bits | Default: 64 | 32 or 64 bits support. |
checksum | Default: "no" | The MD5 checksum value of this template. If set, we search by checksum instead of name. |
cross_zones | Default: "no" | Whether the template should be synced or removed across zones. Only used if state is present or absent. |
details | Template details in key/value pairs. | |
display_text | Display text of the template. | |
domain | Domain the template, snapshot or VM is related to. | |
format |
| The format for the template. Relevant when using state=present . |
hypervisor |
| Name the hypervisor to be used for creating the new template. Relevant when using state=present . |
is_dynamically_scalable | Default: "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 | Default: "no" | True if the template or its derivatives are extractable. |
is_featured | Default: "no" | Register the template to be featured. Only used if state is present. |
is_public | Default: "no" | Register the template to be publicly available to all users. Only used if state is present. |
is_ready | Default: "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 | True if the template type is routing i.e., if template is used to deploy router. Only considered if url is used. | |
mode |
| Mode for the template extraction. Only used if state=extracted . |
name required | Name of the template. | |
os_type | OS type that best represents the OS of this template. | |
password_enabled | Default: "no" | True if the template supports the password reset feature. |
poll_async | Default: "yes" | Poll async jobs until job has finished. |
project | Name of the project the template to be registered in. | |
requires_hvm | Default: "no" | true if this template requires HVM. |
snapshot | 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 | Default: "no" | True if the template supports the sshkey upload feature. |
state |
| State of the template. |
tags (added in 2.4) | 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 |
| Name of the filter used to search for the template. |
template_tag | the tag for this template. | |
url | 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 | 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 | Name of the zone you wish the template to be registered or deleted from. If not specified, first found zone will be used. |
Notes
Note
- Ansible uses the
cs
library’s configuration method if credentials are not provided by the argumentsapi_url
,api_key
,api_secret
. Configuration is read from several locations, in the following order. TheCLOUDSTACK_ENDPOINT
,CLOUDSTACK_KEY
,CLOUDSTACK_SECRET
andCLOUDSTACK_METHOD
.CLOUDSTACK_TIMEOUT
environment variables. ACLOUDSTACK_CONFIG
environment variable pointing to an.ini
file. Acloudstack.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 incloudstack.ini
. Use the argumentapi_region
to select the section name, default section iscloudstack
. See https://github.com/exoscale/cs for more information. - A detailed guide about cloudstack modules can be found in the CloudStack Cloud Guide.
- This module supports check mode.
Examples
- name: 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) - name: 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 - name: 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 - name: 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, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
account string | success | Account the template is related to. Sample: example account |
checksum string | success | MD5 checksum of the template. Sample: 0b31bccccb048d20b551f70830bb7ad0 |
created string | success | Date of registering. Sample: 2015-03-29T14:57:06+0200 |
cross_zones boolean | success | true if the template is managed across all zones, false otherwise. |
display_text string | success | Display text of the template. Sample: Debian 7.7 64-bit minimal 2015-03-19 |
domain string | success | Domain the template is related to. Sample: example domain |
format string | success | Format of the template. Sample: OVA |
hypervisor string | success | Hypervisor related to this template. Sample: VMware |
id string | success | UUID of the template. Sample: a6f7a5fc-43f8-11e5-a151-feff819cdc9f |
is_extractable boolean | success | True if the template is extractable. Sample: True |
is_featured boolean | success | True if the template is featured. Sample: True |
is_public boolean | success | True if the template is public. Sample: True |
is_ready boolean | success | True if the template is ready to be deployed from. Sample: True |
mode string | success | Mode of extraction Sample: http_download |
name string | success | Name of the template. Sample: Debian 7 64-bit |
os_type string | success | Typo of the OS. Sample: CentOS 6.5 (64-bit) |
password_enabled boolean | success | True if the reset password feature is enabled, false otherwise. |
project string | success | Name of project the template is related to. Sample: Production |
sshkey_enabled boolean | success | true if template is sshkey enabled, false otherwise. |
state string | success | State of the extracted template Sample: DOWNLOAD_URL_CREATED |
status string | success | Status of the template. Sample: Download Complete |
tags dict | success | List of resource tags associated with the template. Sample: [ { "key": "foo", "value": "bar" } ] |
template_tag string | success | Template tag related to this template. Sample: special |
template_type string | success | Type of the template. Sample: USER |
url string | success | Url to which the template is extracted to Sample: http://1.2.3.4/userdata/eb307f13-4aca-45e8-b157-a414a14e6b04.ova |
zone string | success | Name of zone the template is registered in. Sample: zuerich |
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.
Maintenance
This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.
For a list of other modules that are also maintained by the Ansible Community, see here.
Author
- René Moser (@resmo)
Hint
If you notice any issues in this documentation you can edit this document to improve it.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.6/modules/cs_template_module.html