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?