1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

hetzner changed image tag for server, so its working with ids and names (#56406)

* hetzner changed image tag for server, so its working with ids and names

* changed trailing whitespace

* added higher retries count since server creation from own image takes a lot longer
This commit is contained in:
ciliusmp 2019-05-15 09:43:21 +02:00 committed by ansibot
parent 666dfdc551
commit 3b08e75eb2

View file

@ -234,10 +234,14 @@ class AnsibleHcloudServer(Hcloud):
"server_type": self.client.server_types.get_by_name(
self.module.params.get("server_type")
),
"image": self.client.images.get_by_name(self.module.params.get("image")),
"user_data": self.module.params.get("user_data"),
"labels": self.module.params.get("labels"),
}
if self.client.images.get_by_name(self.module.params.get("image")) is not None:
# When image name is not available look for id instead
params["image"] = self.client.images.get_by_name(self.module.params.get("image"))
else:
params["image"] = self.client.images.get_by_id(self.module.params.get("image"))
if self.module.params.get("ssh_keys") is not None:
params["ssh_keys"] = [
@ -266,7 +270,7 @@ class AnsibleHcloudServer(Hcloud):
if not self.module.check_mode:
resp = self.client.servers.create(**params)
self.result["root_password"] = resp.root_password
resp.action.wait_until_finished()
resp.action.wait_until_finished(max_retries=1000)
[action.wait_until_finished() for action in resp.next_actions]
self._mark_as_changed()
self._get_server()