Documentation

cs_host - Manages hosts on Apache CloudStack based clouds.

New in version 2.3.

Synopsis

  • Create, update and remove hosts.

Options

parameter required default choices comments
allocation_state
no
  • enabled
  • disabled
Allocation state of the host.
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.
cluster
no
Name of the cluster.
host_tags
no
Tags of the host.

aliases: host_tag
hypervisor
no
  • KVM
  • VMware
  • BareMetal
  • XenServer
  • LXC
  • HyperV
  • UCS
  • OVM
  • Simulator
Name of the cluster.
Required if state=present and host does not yet exist.
name
yes
Name of the host.

aliases: ip_address
password
no
Password for the host.
Required if state=present and host does not yet exist.
pod
no
Name of the pod.
Required if state=present and host does not yet exist.
state
no present
  • present
  • absent
State of the host.
url
no
Url of the host used to create a host.
If not provided, http:// and param name is used as url.
Only considered if state=present and host does not yet exist.
username
no
Username for the host.
Required if state=present and host does not yet exist.
zone
no
Name of the zone in which the host should be deployed.
If not set, default zone is used.

Examples

- name: Ensure a host is present but disabled
  local_action:
    module: cs_host
    name: ix-pod01-esx01.example.com
    cluster: vcenter.example.com/ch-zrh-ix/pod01-cluster01
    pod: pod01
    zone: ch-zrh-ix-01
    hypervisor: VMware
    allocation_state: disabled
    host_tags:
    - perf
    - gpu

- name: Ensure an existing host is disabled
  local_action:
    module: cs_host
    name: ix-pod01-esx01.example.com
    zone: ch-zrh-ix-01
    allocation_state: disabled

- name: Ensure an existing host is disabled
  local_action:
    module: cs_host
    name: ix-pod01-esx01.example.com
    zone: ch-zrh-ix-01
    allocation_state: enabled

- name: Ensure a host is absent
  local_action:
    module: cs_host
    name: ix-pod01-esx01.example.com
    zone: ch-zrh-ix-01
    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
network_kbs_write
Outgoing network traffic on the host.
success int 0
cpu_allocated
Amount in percent of the host's CPU currently allocated.
success string 166.25%
host_tags
Comma-separated list of tags for the host.
success string perf
is_local_storage_active
Whether the local storage is available or not.
success bool False
cluster
Cluster of the host.
success string vcenter.example.com/zone/cluster01
capabilities
Capabilities of the host.
success string hvm
cpu_speed
CPU speed in Mhz
success int 1999
cpu_used
Amount of the host's CPU currently used.
success string 33.6%
pod
Pod name of the host.
success string Pod01
cpu_sockets
Number of CPU sockets of the host.
success int 2
zone
Zone of the host.
success string zone01
cluster_type
Type of the cluster of the host.
success string ExternalManaged
os_category
OS category name of the host.
success string ...
management_server_id
Management server ID of the host.
success int 345050593418
memory_total
Total of memory of the host.
success int 206085263360
state
State of the host.
success string Up
has_enough_capacity
Whether the host has enough CPU and RAM capacity to migrate a VM to it.
success bool True
suitable_for_migration
Whether this host is suitable (has enough capacity and satisfies all conditions like hosttags, max guests VM limit, etc) to migrate a VM to it or not.
success string True
network_kbs_read
Incoming network traffic on the host.
success int 0
events
Events available for the host
success string Ping; HostDown; AgentConnected; AgentDisconnected; PingTimeout; ShutdownRequested; Remove; StartAgentRebalance; ManagementServerDown
host_version
Version of the host.
success string 4.5.2
memory_used
Amount of the host's memory currently used.
success int 65504776192
last_pinged
Date and time the host was last pinged.
success string 1970-01-17T17:27:32+0100
disk_size_total
Total disk size of the host
success int 259300
gpu_group
GPU cards present in the host.
success list []
cpu_with_overprovisioning
Amount of the host's CPU after applying the cpu.overprovisioning.factor.
success string 959520.0
out_of_band_management
Host out-of-band management information.
success string ...
disk_size_allocated
Host's currently allocated disk size.
success int 2593
removed
Date and time the host was removed.
success string 1970-01-17T17:27:32+0100
ip_address
IP address of the host
success string 10.10.10.1
disconnected
Date when the host was disconnected.
success string 2015-05-03T15:05:51+0200
cpu_number
Number of CPUs of the host.
success string 24
hypervisor_version
Hypervisor version.
success string 5.1
name
Name of the host.
success string esx32.example.com
created
Date when the host was created.
success string 2015-05-03T15:05:51+0200
hypervisor
Host's hypervisor.
success string VMware
host_type
Type of the host.
success string Routing
ha_host
Whether the host is a HA host.
success bool False
allocation_state:
Allocation state of the host.
success string enabled
memory_allocated
Amount of the host's memory currently allocated.
success int 69793218560
resource_state
Resource state of the host.
success string Enabled


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 preview which means that it is not guaranteed to have a backwards compatible interface.

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