mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
cs_instance: fix py3 user_data base64 (#37135)
* cs_instance: tests: reproduce py3 user_data base64 issue * cs_instance: fix base64 encoding with py3
This commit is contained in:
parent
4b6b2d4206
commit
0130490faa
2 changed files with 23 additions and 4 deletions
|
@ -348,8 +348,13 @@ instance_name:
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.cloudstack import (AnsibleCloudStack, CS_HYPERVISORS, cs_argument_spec,
|
from ansible.module_utils._text import to_bytes, to_text
|
||||||
cs_required_together)
|
from ansible.module_utils.cloudstack import (
|
||||||
|
AnsibleCloudStack,
|
||||||
|
CS_HYPERVISORS,
|
||||||
|
cs_argument_spec,
|
||||||
|
cs_required_together
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AnsibleCloudStackInstance(AnsibleCloudStack):
|
class AnsibleCloudStackInstance(AnsibleCloudStack):
|
||||||
|
@ -592,7 +597,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
||||||
def get_user_data(self):
|
def get_user_data(self):
|
||||||
user_data = self.module.params.get('user_data')
|
user_data = self.module.params.get('user_data')
|
||||||
if user_data is not None:
|
if user_data is not None:
|
||||||
user_data = base64.b64encode(str(user_data))
|
user_data = to_text(base64.b64encode(to_bytes(user_data)))
|
||||||
return user_data
|
return user_data
|
||||||
|
|
||||||
def get_details(self):
|
def get_details(self):
|
||||||
|
|
|
@ -15,6 +15,11 @@
|
||||||
affinity_group: "{{ cs_resource_prefix }}-ag"
|
affinity_group: "{{ cs_resource_prefix }}-ag"
|
||||||
security_group: "{{ cs_resource_prefix }}-sg"
|
security_group: "{{ cs_resource_prefix }}-sg"
|
||||||
ssh_key: "{{ cs_resource_prefix }}-sshkey"
|
ssh_key: "{{ cs_resource_prefix }}-sshkey"
|
||||||
|
user_data: |
|
||||||
|
#cloud-config
|
||||||
|
package_upgrade: true
|
||||||
|
packages:
|
||||||
|
- tmux
|
||||||
tags: []
|
tags: []
|
||||||
register: instance
|
register: instance
|
||||||
check_mode: true
|
check_mode: true
|
||||||
|
@ -32,6 +37,11 @@
|
||||||
affinity_group: "{{ cs_resource_prefix }}-ag"
|
affinity_group: "{{ cs_resource_prefix }}-ag"
|
||||||
security_group: "{{ cs_resource_prefix }}-sg"
|
security_group: "{{ cs_resource_prefix }}-sg"
|
||||||
ssh_key: "{{ cs_resource_prefix }}-sshkey"
|
ssh_key: "{{ cs_resource_prefix }}-sshkey"
|
||||||
|
user_data: |
|
||||||
|
#cloud-config
|
||||||
|
package_upgrade: true
|
||||||
|
packages:
|
||||||
|
- tmux
|
||||||
tags: []
|
tags: []
|
||||||
register: instance
|
register: instance
|
||||||
- name: verify create instance
|
- name: verify create instance
|
||||||
|
@ -54,6 +64,11 @@
|
||||||
affinity_group: "{{ cs_resource_prefix }}-ag"
|
affinity_group: "{{ cs_resource_prefix }}-ag"
|
||||||
security_group: "{{ cs_resource_prefix }}-sg"
|
security_group: "{{ cs_resource_prefix }}-sg"
|
||||||
ssh_key: "{{ cs_resource_prefix }}-sshkey"
|
ssh_key: "{{ cs_resource_prefix }}-sshkey"
|
||||||
|
user_data: |
|
||||||
|
#cloud-config
|
||||||
|
package_upgrade: true
|
||||||
|
packages:
|
||||||
|
- tmux
|
||||||
tags: []
|
tags: []
|
||||||
register: instance
|
register: instance
|
||||||
- name: verify create instance idempotence
|
- name: verify create instance idempotence
|
||||||
|
@ -84,7 +99,6 @@
|
||||||
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
|
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
|
||||||
- instance.state == "Running"
|
- instance.state == "Running"
|
||||||
|
|
||||||
|
|
||||||
- name: test running instance not updated
|
- name: test running instance not updated
|
||||||
cs_instance:
|
cs_instance:
|
||||||
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
||||||
|
|
Loading…
Reference in a new issue