fusor / archived-ansibleapp-library

A collection of functional AnsibleApps
1 stars 4 forks source link

initial commit of curlcreds #40

Closed jmontleon closed 7 years ago

eriknelson commented 7 years ago

Something about the 2 steps of registering curl output and ehcoing it in the second step is stripping the quotations from the payload and ends up encoding invalid JSON:

{db_name:testdb,hostname:172.30.97.67,password:dbpasswd,port:5432,username:dbuser}

The broker actually decodes this okay but then blows up trying to unmarshal that into a struct.

I changed it to a single step and that seems to avoid the strip:

- name: encode credentials
  shell: 'curl {{ url }} | base64 -w 0'
  register: encoded_bind_credentials

- debug:
    msg: "<BIND_CREDENTIALS>{{ encoded_bind_credentials.stdout }}</BIND_CREDENTIALS>"

Produces: {"db_name":"testdb","hostname":"172.30.97.67","password":"dbpasswd","port":"5432","username":"dbuser"}

I don't know if this is poor ansible form, but Unmarshalling works ¯_(ツ)_/¯

jmrodri commented 7 years ago

@jmontleon please close this PR and migrate to apb-examples if necessary.