Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Secrets are not created correctly the first time with underscore keys #33

Open
carbonin opened this issue Apr 12, 2018 · 0 comments
Open

Comments

@carbonin
Copy link

Using a key which contains an underscore does not initially create the correct data name.
On the first run a key like id_rsa will create secret data called idRsa, but if run again another entry in the secret will be created with the correct name.

13:52:38:~/Documents/scratch/ansible-k8s-bug$ oc project
Using project "project"
13:52:44:~/Documents/scratch/ansible-k8s-bug$ cat secret.yml 
- name: Secrets bug
  hosts: localhost
  gather_facts: no
  connection: local
  roles:
    - role: ansible-kubernetes-modules
  tasks:
  - name: Create Secret
    k8s_v1_secret:
      state: present
      force: false
      resource_definition:
        apiVersion: v1
        kind: Secret
        metadata:
          name: my-secret
          namespace: project
        type: Opaque
      data:
        id_rsa: secretthings
13:52:46:~/Documents/scratch/ansible-k8s-bug$ ansible-playbook secret.yml 
Using /home/ncarboni/Documents/scratch/ansible-k8s-bug/ansible.cfg as config file

PLAY [Secrets bug] ************************************************************************************************************************************************************************************************

TASK [ansible-kubernetes-modules : Install latest openshift client] ***********************************************************************************************************************************************
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional result was False"}

TASK [Create Secret] **********************************************************************************************************************************************************************************************
changed: [localhost] => {"api_version": "v1", "changed": true, "request": {"data": {"idRsa": "secretthings"}, "kind": "Secret", "metadata": {"name": "my-secret", "namespace": "project"}, "type": "Opaque"}, "secret": {"api_version": "v1", "data": {"idRsa": "secretthings"}, "kind": "Secret", "metadata": {"annotations": null, "cluster_name": null, "creation_timestamp": "2018-04-12T17:53:08+00:00", "deletion_grace_period_seconds": null, "deletion_timestamp": null, "finalizers": null, "generate_name": null, "generation": null, "initializers": null, "labels": null, "name": "my-secret", "namespace": "project", "owner_references": null, "resource_version": "2322147", "self_link": "/api/v1/namespaces/project/secrets/my-secret", "uid": "5c00a8f8-3e7a-11e8-908b-d094660d31fb"}, "string_data": null, "type": "Opaque"}}

PLAY RECAP ********************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=1    unreachable=0    failed=0   

13:53:28:~/Documents/scratch/ansible-k8s-bug$ oc describe secret my-secret
Name:		my-secret
Namespace:	project
Labels:		<none>
Annotations:	<none>

Type:	Opaque

Data
====
idRsa:	9 bytes
13:53:39:~/Documents/scratch/ansible-k8s-bug$ ansible-playbook secret.yml 
Using /home/ncarboni/Documents/scratch/ansible-k8s-bug/ansible.cfg as config file

PLAY [Secrets bug] ************************************************************************************************************************************************************************************************

TASK [ansible-kubernetes-modules : Install latest openshift client] ***********************************************************************************************************************************************
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional result was False"}

TASK [Create Secret] **********************************************************************************************************************************************************************************************
changed: [localhost] => {"api_version": "v1", "changed": true, "request": {"data": {"idRsa": "secretthings"}, "kind": "Secret", "metadata": {"name": "my-secret", "namespace": "project"}, "type": "Opaque"}, "secret": {"api_version": "v1", "data": {"idRsa": "secretthings", "id_rsa": "secretthings"}, "kind": "Secret", "metadata": {"annotations": null, "cluster_name": null, "creation_timestamp": "2018-04-12T17:53:08+00:00", "deletion_grace_period_seconds": null, "deletion_timestamp": null, "finalizers": null, "generate_name": null, "generation": null, "initializers": null, "labels": null, "name": "my-secret", "namespace": "project", "owner_references": null, "resource_version": "2322162", "self_link": "/api/v1/namespaces/project/secrets/my-secret", "uid": "5c00a8f8-3e7a-11e8-908b-d094660d31fb"}, "string_data": null, "type": "Opaque"}}

PLAY RECAP ********************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=1    unreachable=0    failed=0   

13:54:05:~/Documents/scratch/ansible-k8s-bug$ oc describe secret my-secret
Name:		my-secret
Namespace:	project
Labels:		<none>
Annotations:	<none>

Type:	Opaque

Data
====
idRsa:	9 bytes
id_rsa:	9 bytes

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant