1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

vultr_server: fix idempotency for private network and IPv6 options (#55619)

* vultr_server: fix idempotency for private network and IPv6 options

* add changelog
This commit is contained in:
René Moser 2019-04-23 21:22:17 +02:00 committed by GitHub
parent db6cc60352
commit 1705ef5f26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 9 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- vultr_server - Fix idempotency for options ``ipv6_enabled`` and ``private_network_enabled``.

View file

@ -128,15 +128,15 @@ class Vultr:
return return
r_value = resource.get(resource_key) r_value = resource.get(resource_key)
if isinstance(param, bool): if r_value in ['yes', 'no']:
if param is True and r_value not in ['yes', 'enable']: if param and r_value != 'yes':
return "enable" return "enable"
elif param is False and r_value not in ['no', 'disable']: elif not param and r_value != 'no':
return "disable" return "disable"
else: else:
if r_value is None: if param and not r_value:
return "enable" return "enable"
else: elif not param and r_value:
return "disable" return "disable"
def api_query(self, path="/", method="GET", data=None): def api_query(self, path="/", method="GET", data=None):

View file

@ -313,6 +313,7 @@
os: CentOS 6 x64 os: CentOS 6 x64
plan: "{{ vultr_server_plan_2 }}" plan: "{{ vultr_server_plan_2 }}"
auto_backup_enabled: yes auto_backup_enabled: yes
private_network_enabled: yes
region: Amsterdam region: Amsterdam
force: yes force: yes
register: result register: result
@ -327,6 +328,7 @@
- result.vultr_server.plan == vultr_server_plan_1 - result.vultr_server.plan == vultr_server_plan_1
- result.vultr_server.region == 'Amsterdam' - result.vultr_server.region == 'Amsterdam'
- result.vultr_server.auto_backup_enabled == false - result.vultr_server.auto_backup_enabled == false
- result.vultr_server.internal_ip == ''
- name: test update server with force - name: test update server with force
vultr_server: vultr_server:
@ -334,6 +336,7 @@
os: CentOS 6 x64 os: CentOS 6 x64
plan: "{{ vultr_server_plan_2 }}" plan: "{{ vultr_server_plan_2 }}"
auto_backup_enabled: yes auto_backup_enabled: yes
private_network_enabled: yes
region: Amsterdam region: Amsterdam
force: yes force: yes
register: result register: result
@ -347,15 +350,17 @@
- result.vultr_server.plan == vultr_server_plan_2 - result.vultr_server.plan == vultr_server_plan_2
- result.vultr_server.region == 'Amsterdam' - result.vultr_server.region == 'Amsterdam'
- result.vultr_server.auto_backup_enabled == true - result.vultr_server.auto_backup_enabled == true
- result.vultr_server.internal_ip != ''
- name: test update server idempotence with force - name: test update server idempotence with force
vultr_server: vultr_server:
name: "{{ vultr_server_name }}" name: "{{ vultr_server_name }}"
os: CentOS 6 x64 os: CentOS 6 x64
plan: "{{ vultr_server_plan_2 }}" plan: "{{ vultr_server_plan_2 }}"
auto_backup_enabled: true auto_backup_enabled: yes
private_network_enabled: yes
region: Amsterdam region: Amsterdam
force: true force: yes
register: result register: result
- name: verify test update server idempotence with force - name: verify test update server idempotence with force
assert: assert:
@ -367,13 +372,14 @@
- result.vultr_server.plan == vultr_server_plan_2 - result.vultr_server.plan == vultr_server_plan_2
- result.vultr_server.region == 'Amsterdam' - result.vultr_server.region == 'Amsterdam'
- result.vultr_server.auto_backup_enabled == true - result.vultr_server.auto_backup_enabled == true
- result.vultr_server.internal_ip != ''
- name: test update server to stopped in check mode - name: test update server to stopped in check mode
vultr_server: vultr_server:
name: "{{ vultr_server_name }}" name: "{{ vultr_server_name }}"
os: CentOS 6 x64 os: CentOS 6 x64
plan: "{{ vultr_server_plan_2 }}" plan: "{{ vultr_server_plan_2 }}"
ipv6_enabled: true ipv6_enabled: yes
region: Amsterdam region: Amsterdam
state: stopped state: stopped
register: result register: result
@ -394,7 +400,7 @@
name: "{{ vultr_server_name }}" name: "{{ vultr_server_name }}"
os: CentOS 6 x64 os: CentOS 6 x64
plan: "{{ vultr_server_plan_2 }}" plan: "{{ vultr_server_plan_2 }}"
ipv6_enabled: true ipv6_enabled: yes
region: Amsterdam region: Amsterdam
state: stopped state: stopped
register: result register: result
@ -414,6 +420,7 @@
name: "{{ vultr_server_name }}" name: "{{ vultr_server_name }}"
os: CentOS 6 x64 os: CentOS 6 x64
plan: "{{ vultr_server_plan_2 }}" plan: "{{ vultr_server_plan_2 }}"
ipv6_enabled: yes
region: Amsterdam region: Amsterdam
state: stopped state: stopped
register: result register: result