If the file content is JSON data you need to read it like JSON data.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Mar 22, 2023, at 10:17 AM, Dick Visser <[email protected]> wrote:



On Wed, 22 Mar 2023 at 15:02, Hiero-nymo 
<[email protected]<mailto:[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<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.ansible.com%2Fansible%2Flatest%2Fcollections%2Fansible%2Fbuiltin%2Fslurp_module.html&data=05%7C01%7Cwalter.rowe%40nist.gov%7C50bd5e2d62424cfa073808db2ae03abf%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638150914773230897%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=zNtEovO7FkoMhq390F7D2arfpTy8BqBUY8nR2BKZuEU%3D&reserved=0>

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]<mailto:[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://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2Fd14aa8a7-fd9b-49f1-967e-cdeb38d3a506n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C50bd5e2d62424cfa073808db2ae03abf%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638150914773230897%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=HKxDKUz5G%2Bq4tKkiD0rM%2B0MvkNAavf51gXL5x6iiPQw%3D&reserved=0>.
--
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]<mailto:[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<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCAF8BbLYb2nGLxwcHamLCB5dqbBo469su5BWRE7%252B4HdU_o%253Dohow%2540mail.gmail.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C50bd5e2d62424cfa073808db2ae03abf%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638150914773230897%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=r9YMUqRdZUhvfcIXaRxpv6b5PxXkso15yanUHwgVJeo%3D&reserved=0>.

-- 
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/E709998A-F1CF-468C-97EF-280730F628D1%40nist.gov.

Reply via email to