问题原文
原帖链接 · Rajiv Nakkana · CC BY-SA 4.0
In find I'm getting the following output, how to filter only the path?
find:
paths: /jv01
recurse: yes
file_type: directory
patterns: 'agent_13.3.0.0.0'
register: oem
- debug:
var: oem
"oem": {
"changed": false,
"examined": 24156,
"failed": false,
"files": [
{
"atime": 1545128921.5473044,
"ctime": 1545120358.3347161,
"dev": 64768,
"gid": 1027,
"inode": 67,
"isblk": false,
"ischr": false,
"isdir": true,
"isfifo": false,
"isgid": false,
"islnk": false,
"isreg": false,
"issock": false,
"isuid": false,
"mode": "0755",
"mtime": 1545120358.3347161,
"nlink": 28,
"path": "/jv01/oracle/agent_13.3.0.0.0",
"rgrp": true,
"roth": true,
"rusr": true,
"size": 4096,
"uid": 1027,
"wgrp": false,
"woth": false,
"wusr": true,
"xgrp": true,
"xoth": true,
"xusr": true
}
],
"matched": 1,
"msg": ""
}
}
社区高分解答
原帖链接 · Lucky · CC BY-SA 4.0
try Jinja2 filters
{{ oem.files | map(attribute='path') | list }}
be avare that this will create a list. If you dont want list you can use this
{{ oem.files | map(attribute='path') | join('') }}
but in case there are more files found, the output will be all paths of found files together.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
