Display path of return variable of module find

45 views
Skip to first unread message

coussi....@gmail.com

unread,
Apr 22, 2021, 4:31:05 AM4/22/21
to Ansible Project

Hi,

I want to get into a variable the list of file present in a directory.
- nameAffichage du contenu de chaque Oracle_Home sqlNet
  find
    paths"{{ item.item }}/network/admin"
  registertmp_oracle_sqlnet_content
  with_items"{{ tmp_oracle_sqlnet_dir.results }}"
  whenitem.stat.exists

I get the list into tmp_oracle_sqlnet_content variable.

Here the results :
{
    "msg": {
        "results": [
            {
                "files": [
                    {
                        "uid": 500,
                        "woth": false,
                        "mtime": 1355715796,
                        "inode": 134880,
                        "isgid": false,
                        "size": 381,
                        "roth": true,
                        "isuid": false,
                        "isreg": true,
                        "pw_name": "oracle",
                        "gid": 500,
                        "ischr": false,
                        "wusr": true,
                        "xoth": false,
                        "rusr": true,
                        "nlink": 1,
                        "issock": false,
                        "rgrp": true,
                        "gr_name": "oinstall",
                        "path": "/soft/oracle/product/11.2/client/network/admin/shrept.lst",


Now i tried to list the file in a debug message.
debug:
    msg"{{ item.path }}"
  with_items"{{ tmp_oracle_sqlnet_content.files }}"

Ansible say that thisvariable has no files attributs :
{
    "msg": "'dict object' has no attribute 'files'",
    "_ansible_no_log": false
}


Can you help me please?

Thanks for you help,

Matt

coussi....@gmail.com

unread,
Apr 22, 2021, 9:56:34 AM4/22/21
to Ansible Project
Hi,

When i try this it works :

- nameRecuperation du contenu de /tmp
  find
    paths"/tmp"
  registertmp_directory_content

debug:
    msg"{{ item.path }}"
  with_items"{{ tmp_directory_content.files }}"

I don't understand what's the difference with this : ?

nameAffichage du contenu de chaque Oracle_Home sqlNet
  find
    paths"{{ item.item }}/network/admin"
  registertmp_oracle_sqlnet_content
  with_items"{{ tmp_oracle_sqlnet_dir.results }}"
  whenitem.stat.exists

debug:
    msg"{{ item.path }}"
  with_items"{{ tmp_oracle_sqlnet_content.files }}"


Thanks for your help,

Matt
Reply all
Reply to author
Forward
0 new messages