hcloud_server – Create and manage cloud servers on the Hetzner Cloud
New in version 2.8.
Synopsis
- Create, update and manage cloud servers on the Hetzner Cloud.
Requirements
The below requirements are needed on the host that executes this module.
- hcloud-python >= 1.0.0
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
api_token string / required | This is the API Token for the Hetzner Cloud. | |
backups boolean |
| Enable or disable Backups for the given Server. |
datacenter string | Datacenter of Server. Required of no location is given and server does not exists. | |
endpoint string | Default: "https://api.hetzner.cloud/v1" | This is the API Endpoint for the Hetzner Cloud. |
force_upgrade boolean |
| Force the upgrade of the server. Power off the server if it is running on upgrade. |
id integer | The ID of the Hetzner Cloud server to manage. Only required if no server name is given | |
image string | Image the server should be created from. Required if server does not exists. | |
labels dictionary | User-defined labels (key-value pairs). | |
location string | Location of Server. Required if no datacenter is given and server does not exists. | |
name string | The Name of the Hetzner Cloud server to manage. Only required if no server id is given or a server does not exists. | |
server_type string | The Server Type of the Hetzner Cloud server to manage. Required if server does not exists. | |
ssh_keys list | List of SSH key names The key names correspond to the SSH keys configured for your Hetzner Cloud account access. | |
state string |
| State of the server. |
upgrade_disk boolean |
| Resize the disk size, when resizing a server. If you want to downgrade the server later, this value should be False. |
user_data string | User Data to be passed to the server on creation. Only used if server does not exists. | |
volumes list | List of Volumes IDs that should be attached to the server on server creation. |
See Also
See also
- Documentation for Hetzner Cloud API
- Complete reference for the Hetzner Cloud API.
Examples
- name: Create a basic server hcloud_server: name: my-server server_type: cx11 image: ubuntu-18.04 state: present - name: Create a basic server with ssh key hcloud_server: name: my-server server_type: cx11 image: ubuntu-18.04 location: fsn1 ssh_keys: - me@myorganisation state: present - name: Resize an existing server hcloud_server: name: my-server server_type: cx21 keep_disk: yes state: present - name: Ensure the server is absent (remove if needed) hcloud_server: name: my-server state: absent - name: Ensure the server is started hcloud_server: name: my-server state: started - name: Ensure the server is stopped hcloud_server: name: my-server state: stopped - name: Ensure the server is restarted hcloud_server: name: my-server state: restarted - name: Ensure the server is rebuild hcloud_server: name: my-server image: ubuntu-18.04 state: rebuild
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
hcloud_server dictionary | Always | The server instance Sample: {'backup_window': None, 'datacenter': 'nbg1-dc3', 'id': 1937415, 'image': 'ubuntu-18.04', 'ipv4_address': '116.203.104.109', 'ipv6': '2a01:4f8:1c1c:c140::/64', 'labels': {}, 'location': 'nbg1', 'name': 'mein-server-2', 'rescue_enabled': False, 'server_type': 'cx11', 'status': 'running'} |
Status
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]
Authors
- Lukas Kaemmerling (@lkaemmerling)
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.8/modules/hcloud_server_module.html