ansible-collections / ansible-collections/google.cloud

gcp_container_cluster kubectl config malformed yaml

Open
#182 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
105
Forks
144
Avg merge
5d 10h
Merged PRs (30d)
4

Description

##### SUMMARY
When using the `gcp_container_cluster` module with the `kubectl_path` argument, the output yaml contains [PyYaml object tags](https://pyyaml.org/wiki/PyYAMLDocumentation#objects). The resulting yaml file is invalid when tags are present and cannot be properly read by `kubectl`

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
This bug is present in the `gcp_container_cluster` module.

##### ANSIBLE VERSION

```
ansible 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/tatemz/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.17 (default, Nov 7 2019, 10:07:09) [GCC 9.2.1 20191008]
```

##### CONFIGURATION

```

```

##### OS / ENVIRONMENT

##### STEPS TO REPRODUCE

```yaml
- name: Create a GKE cluster
gcp_container_cluster:
name: my-gke-cluster
initial_node_count: 1
location: us-central1-a
project: myproject-id
auth_kind: serviceaccount
service_account_file: "/path/to/service/account.json"
state: present
kubectl_path: "/tmp/kubectl.config"
```

##### EXPECTED RESULTS

The output Kube config should have valid cluster server endpoints.

```yaml
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: CERRT_DATA
server: 'https://12.345.678.90'
name: my-gke-cluster
...
```

##### ACTUAL RESULTS

The invalid output Kube config may look like below (note the `clusters[0].cluster.server`).

```yaml
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: CERRT_DATA
server: !!python/unicode 'https://12.345.678.90'
name: my-gke-cluster
...
```

Contributor guide

Open the contributing guide

Research direction

Start at the gcp_container_cluster module's kubectl_path handling and reproduce the issue with the playbook shown, inspecting the generated kubeconfig YAML. Done means the cluster server endpoint and other values are emitted as valid YAML without PyYAML object tags, so kubectl can read the file.

Written by the indexing model from the issue text.

Assessment

Tech stack
ansible, gcp, python
Domain
cloud, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.