Revert openstack.cloud.server parameter user_data to userdata

openstacksdk's create_server() [1] takes cloud-init userdata as a
plaintext string (or other data types [2]) via argument 'userdata',
not 'user_data' [3]. This is 'userdata' argument of create_server()
is different from the 'user_data' value which is returned [4]. The
latter is base64 decoded, while the former is e.g. a plaintext string.
As a (tiny) visual indicator for this difference, this patch reverts
the module parameter 'user_data' to 'userdata' which was used before
this module got refactored [5].

[1] 57fbb72e32/openstack/cloud/_compute.py (L678)
[2] 57fbb72e32/openstack/cloud/_compute.py (L1757)
[3] 57fbb72e32/openstack/cloud/_compute.py (L796)
[4] 57fbb72e32/openstack/compute/v2/server.py (L223)
[5] ac401bb354

Change-Id: I1f3b9314e4d82674cd2ae45f6209de5611e2b6cb
This commit is contained in:
Jakob Meng 2022-10-28 18:19:24 +02:00
parent 65ac75b518
commit 1e27b6b69c

View File

@ -205,12 +205,11 @@ options:
into active state.
default: 180
type: int
user_data:
userdata:
description:
- Opaque blob of data which is made available to the instance.
- This server attribute cannot be updated.
type: str
aliases: ['userdata']
volume_size:
description:
- The size of the volume to create in GB if booting from volume based
@ -423,7 +422,7 @@ EXAMPLES = '''
image: "Ubuntu Server 14.04"
flavor: "P-1"
network: "Production"
user_data: |
userdata: |
#cloud-config
chpasswd:
list: |
@ -444,7 +443,7 @@ EXAMPLES = '''
image: "Ubuntu Server 22.04"
flavor: "P-1"
network: "Production"
user_data: |
userdata: |
#!/bin/sh
apt update
apt -y full-upgrade
@ -818,7 +817,7 @@ class ServerModule(OpenStackModule):
security_groups=dict(default=[], type='list', elements='str'),
state=dict(default='present', choices=['absent', 'present']),
terminate_volume=dict(default=False, type='bool'),
user_data=dict(aliases=['userdata']),
userdata=dict(),
volume_size=dict(type='int'),
volumes=dict(default=[], type='list', elements='str'),
)
@ -1065,7 +1064,7 @@ class ServerModule(OpenStackModule):
'boot_volume', 'config_drive', 'description', 'key_name',
'name', 'network', 'reuse_ips', 'scheduler_hints',
'security_groups', 'terminate_volume', 'timeout',
'user_data', 'volume_size', 'volumes', 'wait']:
'userdata', 'volume_size', 'volumes', 'wait']:
if self.params[k] is not None:
args[k] = self.params[k]