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 |
| 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 |
| The format for the template. Relevant when using state=present . | |
hypervisor | no |
| 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 |
| 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 |
| 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 |
| 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 |
---|---|---|---|---|
account | Account the template is related to. | success | string | example account |
checksum | MD5 checksum of the template. | success | string | 0b31bccccb048d20b551f70830bb7ad0 |
created | Date of registering. | success | string | 2015-03-29T14:57:06+0200 |
cross_zones | true if the template is managed across all zones, false otherwise. | success | boolean | False |
display_text | Display text of the template. | success | string | Debian 7.7 64-bit minimal 2015-03-19 |
domain | Domain the template is related to. | success | string | example domain |
format | Format of the template. | success | string | OVA |
hypervisor | Hypervisor related to this template. | success | string | VMware |
id | UUID of the template. | success | string | a6f7a5fc-43f8-11e5-a151-feff819cdc9f |
is_extractable | True if the template is extractable. | success | boolean | True |
is_featured | True if the template is featured. | success | boolean | True |
is_public | True if the template is public. | success | boolean | True |
is_ready | True if the template is ready to be deployed from. | success | boolean | True |
mode | Mode of extraction | success | string | http_download |
name | Name of the template. | success | string | Debian 7 64-bit |
os_type | Typo of the OS. | success | string | CentOS 6.5 (64-bit) |
password_enabled | True if the reset password feature is enabled, false otherwise. | success | boolean | False |
project | Name of project the template is related to. | success | string | Production |
sshkey_enabled | true if template is sshkey enabled, false otherwise. | success | boolean | False |
state | State of the extracted template | success | string | DOWNLOAD_URL_CREATED |
status | Status of the template. | success | string | Download Complete |
tags | List of resource tags associated with the template. | success | dict | [ { "key": "foo", "value": "bar" } ] |
template_tag | Template tag related to this template. | success | string | special |
template_type | Type of the template. | success | string | USER |
url | Url to which the template is extracted to | success | string | http://1.2.3.4/userdata/eb307f13-4aca-45e8-b157-a414a14e6b04.ova |
zone | Name of zone the template is registered in. | success | string | zuerich |
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 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–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/cs_template_module.html