let`s say I have some tasks below
first I want to detect a folder exists or not in all developer`s
home_dir
and register to eus_exist , and i will do something to whom did not
have
the folder( D/eus)
- name: detect if D/eus exists
tags: eus
stat:
path: "{{ item.home }}"
register: eus_exist
with_items: "{{ developers }}"
- name: debug eus_exist
tags: eus
debug:
var:
neo_exist.results
and the debug messages like this
在此輸入代碼...
"neo_exist": {
"changed": false,
"msg": "All items completed",
"results": [
{
"_ansible_ignore_errors": null,
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": false,
"failed": false,
"invocation": {
"module_args": {
"checksum_algorithm": "sha1",
"follow": false,
"get_attributes": true,
"get_checksum": true,
"get_md5": null,
"get_mime": true,
"path": "/home/cch/D/eus"
}
},
"item": {
"dhome": "/home/cch/D",
"name": "cch",
"nb": "dc075.abc.com",
"neohome": "/home/cch/D/eus",
"ws": "qs055.abc.com"
},
"stat": {
"atime": 1536734130.8954637,
"attr_flags": "e",
"attributes": [
"extents"
],
"block_size": 4096,
"blocks": 8,
"charset": "binary",
"ctime": 1536734058.8687162,
"dev": 66308,
"device_type": 0,
"executable": true,
"exists": true,
"gid": 19000,
"gr_name": "em",
"inode": 1315032,
"isblk": false,
"ischr": false,
"isdir": true,
"isfifo": false,
"isgid": false,
"islnk": false,
"isreg": false,
"issock": false,
"isuid": false,
"mimetype": "inode/directory",
"mode": "0755",
"mtime": 1536734058.8687162,
"nlink": 15,
"path": "/home/cch/D/eus",
"pw_name": "cch",
"readable": true,
"rgrp": true,
"roth": true,
"rusr": true,
"size": 4096,
"uid": 5000,
"version": "4154610742",
"wgrp": false,
"woth": false,
"writeable": true,
"wusr": true,
"xgrp": true,
"xoth": true,
"xusr": true
}
},