cloudscale_server: fix missing param use_private_network (#53381)
This commit is contained in:
parent
c44e83ee13
commit
4ac317239c
2 changed files with 28 additions and 19 deletions
|
@ -377,19 +377,11 @@ class AnsibleCloudscaleServer(AnsibleCloudscaleBase):
|
||||||
self._result['changed'] = True
|
self._result['changed'] = True
|
||||||
required_params = ('name', 'ssh_keys', 'image', 'flavor')
|
required_params = ('name', 'ssh_keys', 'image', 'flavor')
|
||||||
self._module.fail_on_missing_params(required_params)
|
self._module.fail_on_missing_params(required_params)
|
||||||
params = self._module.params
|
|
||||||
data = {
|
data = deepcopy(self._module.params)
|
||||||
'name': params['name'],
|
for i in ('uuid', 'state', 'force', 'api_timeout', 'api_token'):
|
||||||
'image': params['image'],
|
del data[i]
|
||||||
'flavor': params['flavor'],
|
|
||||||
'volume_size_gb': params['volume_size_gb'],
|
|
||||||
'bulk_volume_size_gb': params['bulk_volume_size_gb'],
|
|
||||||
'ssh_keys': params['ssh_keys'],
|
|
||||||
'use_public_network': params['use_public_network'],
|
|
||||||
'use_ipv6': params['use_ipv6'],
|
|
||||||
'anti_affinity_with': params['anti_affinity_with'],
|
|
||||||
'user_data': params['user_data'],
|
|
||||||
}
|
|
||||||
self._result['diff']['before'] = self._init_server_container()
|
self._result['diff']['before'] = self._init_server_container()
|
||||||
self._result['diff']['after'] = deepcopy(data)
|
self._result['diff']['after'] = deepcopy(data)
|
||||||
if not self._module.check_mode:
|
if not self._module.check_mode:
|
||||||
|
|
|
@ -186,48 +186,65 @@
|
||||||
- server.flavor.slug == '{{ cloudscale_test_flavor_2 }}'
|
- server.flavor.slug == '{{ cloudscale_test_flavor_2 }}'
|
||||||
- server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
|
- server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
|
||||||
|
|
||||||
- name: Test create server stopped in check mode
|
- name: Remember uuid of running server for anti affinity
|
||||||
|
set_fact:
|
||||||
|
running_server_uuid: '{{ server.uuid }}'
|
||||||
|
|
||||||
|
- name: Test create server stopped in anti affinity and private network only in check mode
|
||||||
cloudscale_server:
|
cloudscale_server:
|
||||||
name: '{{ cloudscale_resource_prefix }}-test-stopped'
|
name: '{{ cloudscale_resource_prefix }}-test-stopped'
|
||||||
flavor: '{{ cloudscale_test_flavor }}'
|
flavor: '{{ cloudscale_test_flavor }}'
|
||||||
image: '{{ cloudscale_test_image }}'
|
image: '{{ cloudscale_test_image }}'
|
||||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||||
|
anti_affinity_with: '{{ running_server_uuid }}'
|
||||||
|
use_public_network: no
|
||||||
|
use_private_network: yes
|
||||||
state: stopped
|
state: stopped
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: server_stopped
|
register: server_stopped
|
||||||
- name: Verify create server stopped
|
- name: Verify create server stopped in anti affinity and private network only in check mode
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- server_stopped is changed
|
- server_stopped is changed
|
||||||
- server_stopped.state == 'absent'
|
- server_stopped.state == 'absent'
|
||||||
|
|
||||||
- name: Test create server stopped
|
- name: Test create server stopped in anti affinity and private network only
|
||||||
cloudscale_server:
|
cloudscale_server:
|
||||||
name: '{{ cloudscale_resource_prefix }}-test-stopped'
|
name: '{{ cloudscale_resource_prefix }}-test-stopped'
|
||||||
flavor: '{{ cloudscale_test_flavor }}'
|
flavor: '{{ cloudscale_test_flavor }}'
|
||||||
image: '{{ cloudscale_test_image }}'
|
image: '{{ cloudscale_test_image }}'
|
||||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||||
|
anti_affinity_with: '{{ running_server_uuid }}'
|
||||||
|
use_public_network: no
|
||||||
|
use_private_network: yes
|
||||||
state: stopped
|
state: stopped
|
||||||
register: server_stopped
|
register: server_stopped
|
||||||
- name: Verify create server stopped
|
- name: Verify create server stopped in anti affinity and private network only
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- server_stopped is changed
|
- server_stopped is changed
|
||||||
- server_stopped.state == 'stopped'
|
- server_stopped.state == 'stopped'
|
||||||
|
- server_stopped.anti_affinity_with.0.uuid == running_server_uuid
|
||||||
|
- server_stopped.interfaces.0.type == 'private'
|
||||||
|
|
||||||
- name: Test create server stopped idempotence
|
- name: Test create server stopped in anti affinity and private network only idempotence
|
||||||
cloudscale_server:
|
cloudscale_server:
|
||||||
name: '{{ cloudscale_resource_prefix }}-test-stopped'
|
name: '{{ cloudscale_resource_prefix }}-test-stopped'
|
||||||
flavor: '{{ cloudscale_test_flavor }}'
|
flavor: '{{ cloudscale_test_flavor }}'
|
||||||
image: '{{ cloudscale_test_image }}'
|
image: '{{ cloudscale_test_image }}'
|
||||||
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
ssh_keys: '{{ cloudscale_test_ssh_key }}'
|
||||||
|
anti_affinity_with: '{{ running_server_uuid }}'
|
||||||
|
use_public_network: no
|
||||||
|
use_private_network: yes
|
||||||
state: stopped
|
state: stopped
|
||||||
register: server_stopped
|
register: server_stopped
|
||||||
- name: Verify create server stopped idempotence
|
- name: Verify create server stopped in anti affinity and private network only idempotence
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- server_stopped is not changed
|
- server_stopped is not changed
|
||||||
- server_stopped.state == 'stopped'
|
- server_stopped.state == 'stopped'
|
||||||
|
- server_stopped.anti_affinity_with.0.uuid == running_server_uuid
|
||||||
|
- server_stopped.interfaces.0.type == 'private'
|
||||||
|
|
||||||
- name: Test create server failure without required parameters
|
- name: Test create server failure without required parameters
|
||||||
cloudscale_server:
|
cloudscale_server:
|
||||||
|
|
Loading…
Reference in a new issue