Skip to content

Commit

Permalink
feat: add user_metadata to dedicated_server_install module
Browse files Browse the repository at this point in the history
This field allows to push metadata during the intallation
i.e.: The ssh public key can be pushed as shown in the example

Signed-off-by: Thomas Michelot <[email protected]>
  • Loading branch information
D0tty committed Jun 13, 2024
1 parent 9b25b1f commit 4e99a9b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions plugins/modules/dedicated_server_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
soft_raid_devices:
required: false
description: number of devices in the raid software
user_metadata:
required: false
description: list of key,value objects metadata
'''

Expand All @@ -43,6 +46,9 @@
soft_raid_devices: "2"
ssh_key_name: "mysshkeyname"
partition_scheme_name: "custom"
user_metadata:
- key: sshKey
value: "ssh-ed25519 AAAAC3 ..."
delegate_to: localhost
'''

Expand All @@ -59,7 +65,8 @@ def run_module():
template=dict(required=True),
ssh_key_name=dict(required=False, default=None),
soft_raid_devices=dict(required=False, default=None),
partition_scheme_name=dict(required=False, default="default")
partition_scheme_name=dict(required=False, default="default"),
user_metadata=dict(type="list", requirements=False, default=None)
))

module = AnsibleModule(
Expand All @@ -74,6 +81,7 @@ def run_module():
ssh_key_name = module.params['ssh_key_name']
soft_raid_devices = module.params['soft_raid_devices']
partition_scheme_name = module.params['partition_scheme_name']
user_metadata = module.params['user_metadata']

if module.check_mode:
module.exit_json(msg="Installation in progress on {} as {} with template {} - (dry run mode)".format(service_name, hostname, template),
Expand All @@ -95,7 +103,12 @@ def run_module():

client.wrap_call(
"POST",
f"/dedicated/server/{service_name}/install/start", **details, templateName=template, partitionSchemeName=partition_scheme_name)
f"/dedicated/server/{service_name}/install/start",
**details,
templateName=template,
partitionSchemeName=partition_scheme_name,
userMetadata=user_metadata,
)

module.exit_json(msg="Installation in progress on {} as {} with template {}!".format(service_name, hostname, template), changed=True)

Expand Down

0 comments on commit 4e99a9b

Please sign in to comment.