unable to use a remote node file in uri module

21 views
Skip to first unread message

Vishal Bobade

unread,
Feb 13, 2020, 11:16:41 PM2/13/20
to Ansible Project
Hi, 

below is my task where in the "body" section in the below task - I am currently using a file and it is throwing error (I actually check the location file is present there) when I am trying to run a jenkins job. 

 [1;35m[WARNING]: Unable to find 'include/Browsers-CollectionDB.json' in expected paths (use [0m
 [1;35m-vvvvv to see paths) [0m
 [1;35m [0m
 [0;31mfatal: [10.181.56.199]: FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'file'. Error was a <class 'ansible.errors.AnsibleError'>, original message: could not locate file in lookup: 'include/Browsers-CollectionDB.json'"} [0


However when I try to actually paste data from the file and specify it in "body :" it works.
 
            body: "{{ lookup('file','include/Browsers-CollectionDB.json') }}"


- name: Populating browsers collection
        uri:
            url: "http://{{groups['default'][0]}}:8529/_db/collectionDB/_api/document/browsers"
            HEADER_Content-Type: "application-type: json"
            body: "{{ lookup('file','include/Browsers-CollectionDB.json') }}"
            user: "{{ARANGODB_USER}}"
            password: "{{ARANGODB_PASS}}"
            method: POST
            force_basic_auth: yes
            status_code: 200

Stefan Hornburg (Racke)

unread,
Feb 14, 2020, 4:19:42 AM2/14/20
to ansible...@googlegroups.com
On 2/14/20 5:16 AM, Vishal Bobade wrote:
> Hi, 
>
> below is my task where in the "body" section in the below task - I am currently using a file and it is throwing error (I
> actually check the location file is present there) when I am trying to run a jenkins job. 
>
> [1;35m[WARNING]: Unable to find 'include/Browsers-CollectionDB.json' in expected paths (use [0m
>
> [1;35m-vvvvv to see paths) [0m [1;35m [0m [0;31mfatal: [10.181.56.199]: FAILED! => {"msg": "An unhandled exception
> occurred while running the lookup plugin 'file'. Error was a <class 'ansible.errors.AnsibleError'>, original message:
> could not locate file in lookup: 'include/Browsers-CollectionDB.json'"} [0
>
>

1. The file is looked up on the controller, not on the target.

2. There is nothing wrong with following the advice above (-vvvvv to see paths).

Regards
Racke

>
> However when I try to actually paste data from the file and specify it in "body :" it works.
>  
>
> |body: "{{ lookup('file','include/Browsers-CollectionDB.json') }}"
> |
>
>
>
> |- name: Populating browsers collection uri: url:
> "http://{{groups['default'][0]}}:8529/_db/collectionDB/_api/document/browsers" HEADER_Content-Type: "application-type:
> json" *_body: "{{ lookup('file','include/Browsers-CollectionDB.json') }}" _* user: "{{ARANGODB_USER}}" password:
> "{{ARANGODB_PASS}}" method: POST force_basic_auth: yes status_code: 200|
>
> --
> 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
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2f7bb622-a963-454b-a694-a72580b18283%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/2f7bb622-a963-454b-a694-a72580b18283%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc
Reply all
Reply to author
Forward
0 new messages