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
}
},
{
"_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/changp/D/eus"
}
},
"item": {
"dhome": "/home/changp/D",
"name": "changp",
"nb": "dc077.abc.com",
"neohome": "/home/changp/D/eus",
"ws": "qs051.abc.com"
},
"stat": {
"atime": 1536734131.3874035,
"attr_flags": "e",
"attributes": [
"extents"
],
"block_size": 4096,
"blocks": 8,
"charset": "binary",
"ctime": 1536734059.4326406,
"dev": 66308,
"device_type": 0,
"executable": true,
"exists": true,
"gid": 19000,
"gr_name": "em",
"inode": 1316335,
"isblk": false,
"ischr": false,
"isdir": true,
"isfifo": false,
"isgid": false,
"islnk": false,
"isreg": false,
"issock": false,
"isuid": false,
"mimetype": "inode/directory",
"mode": "0755",
"mtime": 1536734059.4326406,
"nlink": 15,
"path": "/home/changp/D/eus",
"pw_name": "changp",
"readable": true,
"rgrp": true,
"roth": true,
"rusr": true,
"size": 4096,
"uid": 2305,
"version": "4193002505",
"wgrp": false,
"woth": false,
"writeable": true,
"wusr": true,
"xgrp": true,
"xoth": true,
"xusr": true
}
},
{
"_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/hum/D/eus"
}
},
"item": {
"dhome": "/home/hum/D",
"name": "hum",
"nb": "dc079.abc.com",
"neohome": "/home/hum/D/eus",
"ws": "qs053.abc.com"
},
"stat": {
"atime": 1536734131.8113515,
"attr_flags": "e",
"attributes": [
"extents"
],
"block_size": 4096,
"blocks": 8,
"charset": "binary",
"ctime": 1536734060.000564,
"dev": 66308,
"device_type": 0,
"executable": true,
"exists": true,
"gid": 19000,
"gr_name": "em",
"inode": 1320061,
"isblk": false,
"ischr": false,
"isdir": true,
"isfifo": false,
"isgid": false,
"islnk": false,
"isreg": false,
"issock": false,
"isuid": false,
"mimetype": "inode/directory",
"mode": "0755",
"mtime": 1536734060.000564,
"nlink": 15,
"path": "/home/hum/D/eus",
"pw_name": "hum",
"readable": true,
"rgrp": true,
"roth": true,
"rusr": true,
"size": 4096,
"uid": 500,
"version": "1956100027",
"wgrp": false,
"woth": false,
"writeable": true,
"wusr": true,
"xgrp": true,
"xoth": true,
"xusr": true
}
},
{
"_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/yj/D/eus"
}
},
"item": {
"dhome": "/home/yj/D",
"name": "yj",
"nb": "dc076.abc.com",
"neohome": "/home/yj/D/eus",
"ws": "qs052.abc.com"
},
"stat": {
"atime": 1536734132.2352996,
"attr_flags": "e",
"attributes": [
"extents"
],
"block_size": 4096,
"blocks": 8,
"charset": "binary",
"ctime": 1536734060.5924847,
"dev": 66308,
"device_type": 0,
"executable": true,
"exists": true,
"gid": 19000,
"gr_name": "em",
"inode": 1320544,
"isblk": false,
"ischr": false,
"isdir": true,
"isfifo": false,
"isgid": false,
"islnk": false,
"isreg": false,
"issock": false,
"isuid": false,
"mimetype": "inode/directory",
"mode": "0755",
"mtime": 1536734060.5924847,
"nlink": 15,
"path": "/home/yj/D/eus",
"pw_name": "yj",
"readable": true,
"rgrp": true,
"roth": true,
"rusr": true,
"size": 4096,
"uid": 3100,
"version": "327852343",
"wgrp": false,
"woth": false,
"writeable": true,
"wusr": true,
"xgrp": true,
"xoth": true,
"xusr": true
}
},
{
"_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/ccw/D/eus"
}
},
"item": {
"dhome": "/home/ccw/D",
"name": "ccw",
"nb": "dc078.abc.com",
"neohome": "/home/ccw/D/eus",
"ws": "qs054.abc.com"
},
"stat": {
"atime": 1536744049.2088273,
"attr_flags": "e",
"attributes": [
"extents"
],
"block_size": 4096,
"blocks": 8,
"charset": "binary",
"ctime": 1536744050.2648327,
"dev": 66308,
"device_type": 0,
"executable": true,
"exists": true,
"gid": 19000,
"gr_name": "em",
"inode": 9830410,
"isblk": false,
"ischr": false,
"isdir": true,
"isfifo": false,
"isgid": false,
"islnk": false,
"isreg": false,
"issock": false,
"isuid": false,
"mimetype": "inode/directory",
"mode": "0755",
"mtime": 1536744050.2648327,
"nlink": 13,
"path": "/home/ccw/D/eus",
"pw_name": "ccw",
"readable": true,
"rgrp": true,
"roth": true,
"rusr": true,
"size": 4096,
"uid": 5002,
"version": "1130330133",
"wgrp": false,
"woth": false,
"writeable": true,
"wusr": true,
"xgrp": true,
"xoth": true,
"xusr": true I have no idea to use which attr to determine that folder exists or not.
any suggestions ??? thanks !