SwanseaUniversityMedical / DARE-Teleport

0 stars 0 forks source link

Fix `argocd_deploy` role `templates/argocd-helm-repo.j2` to handle boolean #119

Open mikej888 opened 1 year ago

mikej888 commented 1 year ago

I updated a DARE-SeRP-Dev-Deployment-style teleport-values.yaml file with an OCI-enabled Helm chart:

...
    repos:
      ...
      - name: dareoci
        url: "https://harbor.ukserp.ac.uk/chartrepo/dare"
        type: "helm"
        enableOCI: true

Running the playbook failed:

$ ansible-playbook -i inventories/eidf-tre-teleport-remote.yaml 1-remote-vm-setup-and-deploy-epcc.yaml -v
...
TASK [dare.common.argocd_deploy : make helm repo secret] ***********************
fatal: [single_host]: FAILED! => {"changed": false, "msg": "Failed to create object: b'{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"Secret in version \\\\\"v1\\\\\" cannot be handled as a Secret: json: cannot unmarshal bool into Go struct field Secret.stringData of type string\",\"reason\":\"BadRequest\",\"code\":400}\\n'", "reason": "Bad Request"}

PLAY RECAP *********************************************************************
single_host                : ok=114  changed=49   unreachable=0    failed=1    skipped=42   rescued=0    ignored=1   

Wrapping the true value in quotes - 'true' or "true" - and rerunning the playbook likewise failed. However, using double-quotes - "'true'" - and rerunning the playbook succeeds.

An alternative is to edit ansible/roles/argocd_deploy/templates/argocd-helm-repo.j2 and update

{% if item.enableOCI is defined %}
  enableOCI: {{ item.enableOCI }}
{% endif %}

to

{% if item.enableOCI is defined %}
  enableOCI: '{{ item.enableOCI }}'
{% endif %}

Not wrapping the enableOCI value in quotes in the playbook succeeds if this latter fix is applied.