Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unexpected return data bug in the kubernetes module #331

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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