On Wed, 22 Mar 2023 at 15:02, Hiero-nymo <[email protected]> wrote:

> Hi everyone,
>
> I'm using the cat command with the command module to retrieve remote files
> content. With a loop within a find module I get filename and call a task,
> so like this:
> [...]
> - name: Read the content of all files
>   command: /usr/bin/cat {{ _files_folder.path }}/{{ file_item }}.yaml
>   register: file_contents
>   become: true
>   become_user: root
> [...]
> I receive a list of string (with stdout_lines) or a normal output (with
> stdout) but I need to have a list
>

You say you receive a list, and you also say you want to have a list.
So, what is the problem then...?

Also, you didn't say what you are actually trying to achieve. Do you need
the file content?  To do what?
In any case you could use the slurp module instead of command+cat:

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/slurp_module.html

If you have more context we may be able to help you better



because a the end I want to make a diff with another list of dict, like
> this:
> ok: [10.10.10.1] => {
>     "daten_content": [
>         {
>             "agents": [
>                 "aaa",
>                 "bbb"
>             ],
>             "community": {
>                 "from xyzzy"
>             },
>             "disableDimensions": true,
>             "Dimensions": {
>                 "HostGroup": "abc",
>                 "Type": "role",
>                 "env": "TEST"
>             },
>             "fields": [
> [...]
> Unfortunately I cannot retrieve what I need with a split or to pipe in
> list.
> As anyone an idea how to do that or using another module?
>
> --
> 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/d14aa8a7-fd9b-49f1-967e-cdeb38d3a506n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/d14aa8a7-fd9b-49f1-967e-cdeb38d3a506n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
-- 
Sent from Gmail Mobile

-- 
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/CAF8BbLYb2nGLxwcHamLCB5dqbBo469su5BWRE7%2B4HdU_o%3Dohow%40mail.gmail.com.

Reply via email to