Have you tried the body section with the the curly braces?  Like so:
body: 
               "id": "{{ customer_id }}",
               "name": "{{ customer_name }}",
               "disabledFeatures": 
["visualize","dev_tools","advancedSettings","indexPatterns","savedObjectsManagement","timelion","graph","monitoring","ml","apm","maps","canvas","infrastructure","logs","siem","uptime"]

I have a playbook using URI module with a json body and mine works without 
those.

On Wednesday, December 4, 2019 at 4:41:41 PM UTC-6, Robert Heppe wrote:
>
> Hi all,
> I have a working curl command that I've been trying to get into an ansible 
> playbook in a testing environment.  I've found several posts on various 
> forums for similar situations, but not the one I'm working with, so my 
> attempts are still erroring.  I have the curl below, which when run on the 
> cli works correctly.
>
> curl -X POST -k -u xxxx:xxxx "https://x.x.x.x:5601/api/spaces/space"; -H 
> 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'
> {
>   "id": "some_id",
>   "name": "some_name",
>   "disabledFeatures": 
> ["visualize","dev_tools","advancedSettings","indexPatterns","savedObjectsManagement","timelion","graph","monitoring","ml","apm","maps","canvas","infrastructure","logs","siem","uptime"]
> }
> '
>
> However, I have tried many variations of it in a playbook without 
> success.  Can anyone suggestions modifications to this playbook?
>
> ---
>  - hosts: "{{ region }}-ki01"
>    become: true
>    tasks:
>      - name: Create Kibana Space for client "{{ customer_name }}"
>        uri:
>          url: "https://{{ region }}-ki01:5601/api/spaces/space"
>          user: xxxx
>          password: xxxx
>          validate_certs: no
>          method: POST
>          body: {
>                "id": "{{ customer_id }}",
>                "name": "{{ customer_name }}",
>                "disabledFeatures": 
> ["visualize","dev_tools","advancedSettings","indexPatterns","savedObjectsManagement","timelion","graph","monitoring","ml","apm","maps","canvas","infrastructure","logs","siem","uptime"]
>               }
>          body_format: json
>          headers:
>            kbn-xsrf: "true"
>            Content-Type: "application/json"
>
> The output I'm getting right now is this:
>
> [centos@jumphost playbooks]$ ansible-playbook kibana_spaces_test.yml 
> --extra-vars "region=us1 customer_id=some_id customer_name=some_name"
>
> PLAY [us1-ki01] 
> **********************************************************************************************************************************************
>
> TASK [Gathering Facts] 
> ***************************************************************************************************************************************
> ok: [us1-ki01]
>
> TASK [Create Kibana Space for client "some_name"] 
> ********************************************************************************************************
> fatal: [us1-ki01]: FAILED! => {"changed": false, "content": "", "msg": 
> "Status code was not [200]: Request failed: <urlopen error [Errno -2] Name 
> or service not known>", "redirected": false, "status": -1, "url": "
> https://us1-ki01:5601/api/spaces/space"}
>  [WARNING]: Could not create retry file 
> '/etc/ansible/roles/proficio-ansible/playbooks/kibana_spaces_test.retry'.  
>        [Errno 13] Permission denied:
> u'/etc/ansible/roles/proficio-ansible/playbooks/kibana_spaces_test.retry'
>
>
> PLAY RECAP 
> ***************************************************************************************************************************************************
> us1-ki01                   : ok=1    changed=0    unreachable=0    failed=1
>
>
>
> Thanks,
> Robert
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b5fca020-e38c-405a-8f39-77170cc19211%40googlegroups.com.

Reply via email to