mirror of
https://github.com/ansible-collections/hetzner.hcloud
synced 2024-12-04 17:49:16 +00:00
fix: only rebuild existing servers, skip rebuild if it was just created (#581)
##### SUMMARY Fixes #580 A freshly created server must not be rebuild. ##### ISSUE TYPE - Bugfix Pull Request ##### COMPONENT NAME server
This commit is contained in:
parent
5221828cba
commit
06718d0db0
2 changed files with 20 additions and 12 deletions
2
changelogs/fragments/only-rebuild-existing-servers.yml
Normal file
2
changelogs/fragments/only-rebuild-existing-servers.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- hcloud_server - Only rebuild existing servers, skip rebuild if the server was just created.
|
|
@ -869,6 +869,13 @@ class AnsibleHCloudServer(AnsibleHCloud):
|
|||
return None
|
||||
|
||||
def rebuild_server(self):
|
||||
self._get_server()
|
||||
if self.hcloud_server is None:
|
||||
self._create_server()
|
||||
else:
|
||||
self._update_server()
|
||||
|
||||
# Only rebuild the server if it already existed.
|
||||
self.module.fail_on_missing_params(required_params=["image"])
|
||||
try:
|
||||
if not self.module.check_mode:
|
||||
|
@ -969,7 +976,6 @@ def main():
|
|||
hcloud.stop_server()
|
||||
hcloud.start_server()
|
||||
elif state == "rebuild":
|
||||
hcloud.present_server()
|
||||
hcloud.rebuild_server()
|
||||
|
||||
module.exit_json(**hcloud.get_result())
|
||||
|
|
Loading…
Reference in a new issue