Skip to content

Commit

Permalink
Fix unexpected return data bug in the kubernetes module
Browse files Browse the repository at this point in the history
  • Loading branch information
raman-babich committed Dec 24, 2023
1 parent 55c40a2 commit e18ca2b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 42 deletions.
5 changes: 5 additions & 0 deletions changelogs/fragments/322-k8s-module-kubeconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bugfixes:
- digital_ocean_kubernetes - module didn't return kubeconfig properly, return documentation was
invalid. Fixed version returns data with the same structure all the time, also it is aligned
with M(community.digitalocean.digital_ocean_kubernetes_info) documentation return data now.
(https://github.com/ansible-collections/community.digitalocean/issues/322).
83 changes: 42 additions & 41 deletions plugins/modules/digital_ocean_kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,51 +212,50 @@
- name: do-nyc1-hacktoberfest-admin
user:
token: REDACTED
kubernetes_cluster:
auto_upgrade: false
cluster_subnet: 10.244.0.0/16
created_at: '2020-09-27T00:55:37Z'
endpoint: https://REDACTED.k8s.ondigitalocean.com
auto_upgrade: false
cluster_subnet: 10.244.0.0/16
created_at: '2020-09-27T00:55:37Z'
endpoint: https://REDACTED.k8s.ondigitalocean.com
id: REDACTED
ipv4: REDACTED
maintenance_policy:
day: any
duration: 4h0m0s
start_time: '15:00'
name: hacktoberfest
node_pools:
- auto_scale: false
count: 1
id: REDACTED
ipv4: REDACTED
maintenance_policy:
day: any
duration: 4h0m0s
start_time: '15:00'
name: hacktoberfest
node_pools:
- auto_scale: false
count: 1
labels: null
max_nodes: 0
min_nodes: 0
name: hacktoberfest-workers
nodes:
- created_at: '2020-09-27T00:55:37Z'
droplet_id: '209555245'
id: REDACTED
labels: null
max_nodes: 0
min_nodes: 0
name: hacktoberfest-workers
nodes:
- created_at: '2020-09-27T00:55:37Z'
droplet_id: '209555245'
id: REDACTED
name: hacktoberfest-workers-3tdq1
status:
state: running
updated_at: '2020-09-27T00:58:36Z'
size: s-1vcpu-2gb
tags:
- k8s
- k8s:REDACTED
- k8s:worker
taints: []
region: nyc1
service_subnet: 10.245.0.0/16
status:
state: running
surge_upgrade: false
name: hacktoberfest-workers-3tdq1
status:
state: running
updated_at: '2020-09-27T00:58:36Z'
size: s-1vcpu-2gb
tags:
- k8s
- k8s:REDACTED
updated_at: '2020-09-27T01:00:37Z'
version: 1.18.8-do.1
vpc_uuid: REDACTED
- k8s:worker
taints: []
region: nyc1
service_subnet: 10.245.0.0/16
status:
state: running
surge_upgrade: false
tags:
- k8s
- k8s:REDACTED
updated_at: '2020-09-27T01:00:37Z'
version: 1.18.8-do.1
vpc_uuid: REDACTED
"""


Expand Down Expand Up @@ -396,7 +395,9 @@ def create(self):
json_data = self.ensure_running()
# Add the kubeconfig to the return
if self.return_kubeconfig:
json_data["kubeconfig"] = self.get_kubernetes_kubeconfig()
json_data["kubernetes_cluster"][
"kubeconfig"
] = self.get_kubernetes_kubeconfig()
self.module.exit_json(changed=True, data=json_data["kubernetes_cluster"])

def delete(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
version: "{{ cluster_version }}"
region: "{{ do_region }}"
node_pools: "{{ cluster_node_pools }}"
return_kubeconfig: false
return_kubeconfig: true
wait_timeout: 600
register: result

Expand All @@ -74,6 +74,8 @@
that:
- result.changed
- result.data.name == cluster_name
- result.data.kubeconfig is defined
- result.data.kubeconfig | length > 0

- name: Gather information about the Kubernetes cluster
community.digitalocean.digital_ocean_kubernetes_info:
Expand Down

0 comments on commit e18ca2b

Please sign in to comment.