Manages SiteHost Server Instance. Make sure to checkout our developer KB article for more information on our API. Please ensure that the Servers & Cloud Containers: Server
and Servers & Cloud Containers: Job
privilege is enabled your your SiteHost API key.
Field | Type | Required | Description |
---|---|---|---|
state |
str |
Optional (Default: present) | The desired state of the target. (Choices: present , absent , started ,stopped , restarted ) |
label |
str |
Optional | User chosen label of the new server, mutually exclusive to name . Please ensure that verbose mode -v is enabled to see the password of the newly created server. |
name |
str |
Optional | Unique auto generated machine name for server. Used to select servers that are already present. |
location |
str |
Optional | The code for the location to provision the new server at. eg. AKLCITY |
product_code |
str |
Optional | The code for the server specification to use when provisioning the new server. eg. XENLIT |
image |
str |
Optional | The image to use for the new server. eg. ubuntu-jammy-pvh.amd64 |
api_key |
str |
Required | Your SiteHost API key generated from CP. |
api_client_id |
int |
Required | The client ID of your SiteHost account. |
- Note that
label
is only used for creating new servers andname
is used for selecting exisiting servers. Thereforelabel
andname
cannot be defined at the same time. location
,product_code
,image
are used only for creating new servers. Therefore they must be present iflabel
is defined.
To provision a Cloud Container Server, you must use image: ubuntu-focal.amd64
as your image parameter. Additionally, please use one of the following code as your product_code
argument:
CLDCON1
CLDCON2
CLDCON4
CLDCON6
CLDCON8
For example, use product_code: CLDCON1
for a 1 core Cloud Container Server.
- Creating a VPS, use
-v
as argument when running the playbook to see password:
- name: create a 1 core VPS with ubuntu jammy image
sitehost.cloud.server:
label: myserver
location: AKLCITY
product_code: XENLIT
image: ubuntu-jammy-pvh.amd64
api_client_id: "{{ CLIENT_ID }}"
api_key: "{{ USER_API_KEY }}"
state: present
- Create a VPS and register its output to shserver and outputs the password with debug:
- name: create a 1 core VPS with ubuntu jammy image
sitehost.cloud.server:
label: myserver
location: AKLCITY
product_code: XENLIT
image: ubuntu-jammy-pvh.amd64
api_client_id: "{{ CLIENT_ID }}"
api_key: "{{ USER_API_KEY }}"
state: present
register: shserver
- name: output shserver
ansible.builtin.debug:
msg: "{{ shserver.server.password }}"
- Creating a server then upgrading it.
- name: create a 1 core VPS with ubuntu jammy image
sitehost.cloud.server:
label: myserver
location: AKLCITY
product_code: XENLIT
image: ubuntu-jammy-pvh.amd64
api_client_id: "{{ CLIENT_ID }}"
api_key: "{{ USER_API_KEY }}"
state: present
register: shserver
- name: upgrade the previously created server
sitehost.cloud.server:
name: "{{ shserver.server.name }}"
product_code: XENPRO
api_client_id: "{{ CLIENT_ID }}"
api_key: "{{ USER_API_KEY }}"
state: present
- Restarts the previously created server
- name: restart server
sitehost.cloud.server:
name: "{{ shserver.server.name }}"
api_client_id: "{{ CLIENT_ID }}"
api_key: "{{ USER_API_KEY }}"
state: restarted
- Deletes server
- name: delete server
sitehost.cloud.server:
name: "{{ shserver.server.name }}"
api_client_id: "{{ CLIENT_ID }}"
api_key: "{{ USER_API_KEY }}"
state: absent
msg
- Text that indicates the status of the module.- returned: always
- type: str
- sample:
mywebserv2 has been deleted
server
- The sitehost server being actioned. Note that there is more information output on server creation and upgrade.- returned: On success
- type: dict
- elements:
label
- User chosen label for the server.- returned: On success
- type: str
- sample:
mywebserver
name
- Unique system generated name for server.- returned: On success
- type: str
- sample:
mywebserv2
password
- Password for the root user.- returned: On success, and only returned during server creation.
- type: str
- sample:
Up8Da5oE60ns
state
- The state of the server after executing the command.- returned: On sucess
- type: str
- sample:
On
Off
Reboot
Deleted