Hi all!
This is my task that works:
- name: Stop services on ambari
uri:
url: http://{{ inventory_hostname }}:8080/api/v1/clusters/{{
hostvars[inventory_hostname].cluster_name }}/services/{{ service }}
method: PUT
force_basic_auth: yes
user: "{{ ambari_admin_user }}"
password: "{{ ambari_admin_password }}"
headers: '{"X-Requested-By":"ambari"}'
body: "{\"RequestInfo\":{ \"context\":\"Stop services via
REST\"},\"ServiceInfo\":{\"state\":\"INSTALLED\"}}"
status_code: 200,201,202
body_format: raw
timeout: 120
return_content: yes
register: returned_from_cluster
when: "'AMBARI-SERVER' in group_names"
I want to change the Stop services via REST part to Stop {{ service }} via
REST.
But the playbook fault with:
"msg": "Status code was -1 and not [200, 201, 202]: An unknown error
occurred: must be string or buffer, not dict"
I tried to run the playbook with -vvv and saw the diffenence.
This one without variable:
"body": "{\\"RequestInfo\\":{ \\"context\\":\\"Stop services via REST\\
"},\\"ServiceInfo\\":{\\"state\\":\\"INSTALLED\\"}}"
And this one with variable:
"body": {"RequestInfo": {"context": "Stop NIFI_REGISTRY via REST"},
"ServiceInfo": {"state": "INSTALLED"}}
How can I avoid this evaluation?
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/5e96cb18-fb91-4d82-ab30-cf37804afa44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.