Read a text file over https address into variable

34 views
Skip to first unread message

Homayoun Najafizadeh

unread,
Jul 19, 2017, 7:05:41 PM7/19/17
to Ansible Project
Hi All,

Is there anyway I can download this path via Ansible?


As you can see the path is variable based on value in stable.txt file (at this point is '1.7.1').



Thanks

Dick Visser

unread,
Jul 20, 2017, 1:58:10 AM7/20/17
to ansible...@googlegroups.com
- name: Test playbook
hosts: localhost
gather_facts: false
become: false

tasks:
- uri:
url: https://storage.googleapis.com/kubernetes-release/release/stable.txt
return_content: yes
register: response

- set_fact:
version: "{{ response.content | trim }}"

- debug: var=version
> --
> 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.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6dafaf98-1d1d-46d8-9272-f84691d36fca%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Dick Visser
Sr. System & Network Engineer
GÉANT

Want to join us? We're hiring: https://www.geant.org/jobs

Brian Coca

unread,
Jul 20, 2017, 10:22:12 AM7/20/17
to Ansible Project
Or if you don't need any of the 'advanced' features of the uri module"

- set_fact:
version:"'{{lookup('url',
'https://storage.googleapis.com/kubernetes-release/release/stable.txt,
split_lilnes=False')}}"

---------------
Brian Coca
Reply all
Reply to author
Forward
0 new messages