No. Lookups happen on the Ansible controller.
If the file is on the remote host(s), then prior to the task where you
need the data, do an *ansible.builtin.command* task which `*cat*`s the
file and registers the result. Then on the "*Download the patches*"
task, say
*loop: "{{ **/registered_cat/**.stdout_lines }}"*
Each item will then be one line from the file.
On 6/10/23 6:48 PM, Amit Kulkarni wrote:
Thanks Todd.
If i keep the text file on remote server will the above work?.
I can provide the full path for the file in lookup and it will get
picked up one by one
Regards
Amit
On Sat, Jun 10, 2023, 7:26 PM Todd Lewis <uto...@gmail.com> wrote:
I think you're looking for something like this:
*---****- name: Download the patches for sage****hosts:
app****vars:****my_dest: /busdata/qwm/mna1/geodev12/folders/GX/PATCH/****my_url:
https://raw.gitlabusercontent.michelin.com/na-sc/na-log/wms_nca/wms_na_patch/sagepatch/****tasks:****-
name: Download files from my_url****ansible.builtin.get_url:****url: "{{ my_url }}/{{ item
}}"****url_username:****url_password:****dest: "{{ my_dest }}/{{ item }}"****register:
download****until: download is succeeded****delay: 3****loop: "{{ lookup('ansible.builtin.file',
'patches.txt') |
split('\n') }}"*
If your "patches.txt" file is part of your source repo anyway, you
could list the patches in a "group_vars/app.yml" file and use the
containing variable directly. There are lots of other ways to do
it as well.
On 6/10/23 5:33 PM, Amit Kulkarni wrote:
Hello All,
I am trying to work my way through this playbook, here is what I
got so far, appreciate your input and let me know if this is
correct..
Problem now is patches.txt will also be in same in repos as the
actual files, so I am not sure how to provide the path to that file
Appreciate all your inputs here
---
- name: "Download the patches for sage"
hosts: app
vars:
my_dest: /busdata/qwm/mna1/geodev12/folders/GX/PATCH/
my_url:
"https://raw.gitlabusercontent.michelin.com/na-sc/na-log/wms_nca/wms_na_patch/sagepatch/"
tasks:
- get_url:
url: "{{ my_url }}/{{ item }}"
url_username:
url_password:
dest: "{{ my_dest }}/{{ item }}"
register: download
until: download is succeeded
delay: 3
debug:
var: item
with_lines: cat "./path/pateches.txt"
Regards
Amit
On Sat, Jun 10, 2023 at 3:31 PM Amit Kulkarni
<amit1811...@gmail.com> wrote:
.Hello All,
Can someone please help with below.
I need to read the filename from an external file in ansible
playbook, if someone has done something like this before
please let me know.
In the loop there are DAT files which will be changing every
time, so I need to keep those in an external file and read it
in the main playbook.
Appreciate your help.
---
- name: "Download the patches for sage"
hosts: app
vars:
my_dest: /busdata/qwm/mna1/geodev12/folders/GX/PATCH/
my_url:
"https://raw.gitlabusercontent.michelin.com/na-sc/na-log/wms_nca/wms_na_patch/sagepatch/"
tasks:
- get_url:
url: "{{ my_url }}/{{ item }}"
dest: "{{ my_dest }}/{{ item }}"
register: download
until: download is succeeded
delay: 3
my_file: "{{ item }}"
loop:
- SRC_WMS_V12_04_0017.dat
- SRC_WMS_V12_04_0018_txt.dat
- SRC_WMS_V12_04_0019.dat
- SRC_WMS_V12_04_0020.dat
On Fri, Jun 9, 2023 at 8:22 PM Amit Kulkarni
<amit1811...@gmail.com> wrote:
Thanks Abhijeet for your help
Is there any way I can move the loop out of the playbook
and make it read from the main playbook.
These are patch files and will be changing for each
patching cycle.
Let me know if this is possible.
Regards
Amit
On Fri, Jun 9, 2023 at 6:28 PM Abhijeet Kasurde
<akasu...@redhat.com> wrote:
Little syntax correction -
---
- name: "Download the patches for sage"
hosts: app
vars:
my_dest:
/busdata/qwm/mna1/geodev12/folders/GX/PATCH/
my_url:
"https://raw.gitlabusercontent.michelin.com/na-sc/na-log/wms_nca/wms_na_patch/sagepatch/"
tasks:
- get_url:
url: "{{ my_url }}/{{ item }}"
dest: "{{ my_dest }}/{{ item }}"
register: download
until: download is succeeded
delay: 3
loop:
- SRC_WMS_V12_04_0017.dat
- SRC_WMS_V12_04_0018_txt.dat
- SRC_WMS_V12_04_0019.dat
- SRC_WMS_V12_04_0020.dat
On Fri, Jun 9, 2023 at 1:20 PM Amit Kulkarni
<amit1811...@gmail.com> wrote:
Hello Abhijit,
Thanks for your help, I came up with another one,
if you could provide your input that would be great.
Please let me know is this looking ok, what I am
trying to do is t
---
- name: "Download the patches for sage"
hosts: app
vars:
my_dest:
/busdata/qwm/mna1/geodev12/folders/GX/PATCH/
my_url:
"https://raw.gitlabusercontent.michelin.com/na-sc/na-log/wms_nca/wms_na_patch/sagepatch/"
tasks:
- get_url:
url: "{{ my_url }}/{{ my_file }}"
dest: "{{ my_dest }}/{{ my_file }}"
register: download
until: download is succeeded
delay: 3
my_file: "{{ item }}"
loop:
- SRC_WMS_V12_04_0017.dat
- SRC_WMS_V12_04_0018_txt.dat
- SRC_WMS_V12_04_0019.dat
- SRC_WMS_V12_04_0020.dat
On Fri, Jun 9, 2023 at 3:38 PM Abhijeet Kasurde
<akasu...@redhat.com> wrote:
Use
dest:
"/busdata/qwm/mna1/geodev12/folders/GX/PATCH/{{
item | basename }}"
On Fri, Jun 9, 2023 at 12:23 PM Amit Kulkarni
<amit1811...@gmail.com> wrote:
Hello All,
I have the below playbook, I wanted to
download the files from gitlab on same
path with different names. I have below
playbook,
As can seen below source path is same but
file name is different, I need to have
src path defined and should mention only
file names in loop or may be i can read
these names from different file itself.
Appreciate any help with this
---
- name: Download the files from GITLAB
for Patching
hosts: app
tasks:
- get_url:
url: "{{ item }}"
dest:
/busdata/qwm/mna1/geodev12/folders/GX/PATCH/
url_username:
url_password:
register: download
until: download is succeeded
delay: 3
loop:
-
https://raw.gitlabusercontent.michelin.com/na-sc/na-log/wms_nca/wms_na_patch/sagepatch/SRC_WMS_V12_04_0017.dat
-
https://raw.gitlabusercontent.michelin.com/na-sc/na-log/wms_nca/wms_na_patch/sagepatch/SRC_WMS_V12_04_0018_txt.dat
-
https://raw.gitlabusercontent.michelin.com/na-sc/na-log/wms_nca/wms_na_patch/sagepatch/SRC_WMS_V12_04_0019.dat
-
https://raw.gitlabusercontent.michelin.com/na-sc/na-log/wms_nca/wms_na_patch/sagepatch/SRC_WMS_V12_04_0020.dat
--
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAON3ZR2d9hJ7PHdRW1ToRHQhXL9gm-Qa08aw0jb11vj2vWQH2A%40mail.gmail.com
<https://groups.google.com/d/msgid/ansible-project/CAON3ZR2d9hJ7PHdRW1ToRHQhXL9gm-Qa08aw0jb11vj2vWQH2A%40mail.gmail.com?utm_medium=email&utm_source=footer>.
--
Thanks,
Abhijeet Kasurde
--
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAFwWkHoj%3DVvJgTNzMkZaObw3GuZku1kdGEs-s2Lsi3aR3hauwg%40mail.gmail.com
<https://groups.google.com/d/msgid/ansible-project/CAFwWkHoj%3DVvJgTNzMkZaObw3GuZku1kdGEs-s2Lsi3aR3hauwg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
--
Thanks,
Abhijeet Kasurde
--
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAON3ZR3zT6XQJcxTNYzh16g6cBCcJv6Bn_iNK6pnFn-_LwEcSg%40mail.gmail.com
<https://groups.google.com/d/msgid/ansible-project/CAON3ZR3zT6XQJcxTNYzh16g6cBCcJv6Bn_iNK6pnFn-_LwEcSg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
--
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/2cdf03dc-9c7d-8af3-36a1-036d1d29f5e7%40gmail.com
<https://groups.google.com/d/msgid/ansible-project/2cdf03dc-9c7d-8af3-36a1-036d1d29f5e7%40gmail.com?utm_medium=email&utm_source=footer>.
--
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/443dca77-9da6-3a6b-a04e-b37b854b927f%40gmail.com.