首页 > 解决方案 > Ansible AWX:playbook 成功运行以在 localhost 中创建目录,但是当转到该位置时,该目录不可用

问题描述

我是ansible AWX的新手,我想在我的本地主机上为该创建剧本创建目录,如下所示,当我运行剧本时,它显示成功按摩并在本地主机上进行了更改,但是当我转到该位置时,目录在那里不可用。

剧本:

---
- hosts: localhost
  tasks:
   - name: Create Directory
     file:
       path: ~/newDir1
       mode: "0755"
       state: directory

输出:

TASK [Create Directory] ********************************************************
20:16:58
10
changed: [localhost]
PLAY RECAP *********************************************************************
20:17:00
localhost : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0 

位置通过输出获得:

{
    "path": "/var/lib/awx/newDir1",
    "changed": true,
    "diff": {
        "before": {
            "path": "/var/lib/awx/newDir1",
            "state": "absent"
        },
        "after": {
            "path": "/var/lib/awx/newDir1",
            "state": "directory"
        }
    },
    "uid": 975,
    "gid": 975,
    "owner": "awx",
    "group": "awx",
    "mode": "0755",
    "state": "directory",
    "secontext": "system_u:object_r:tmp_t:s0",
    "size": 6,
    "invocation": {
        "module_args": {
            "path": "/var/lib/awx/newDir1",
            "mode": "0755",
            "state": "directory",
            "recurse": false,
            "force": false,
            "follow": true,
            "modification_time_format": "%Y%m%d%H%M.%S",
            "access_time_format": "%Y%m%d%H%M.%S",
            "_original_basename": null,
            "_diff_peek": null,
            "src": null,
            "modification_time": null,
            "access_time": null,
            "owner": null,
            "group": null,
            "seuser": null,
            "serole": null,
            "selevel": null,
            "setype": null,
            "attributes": null,
            "content": null,
            "backup": null,
            "remote_src": null,
            "regexp": null,
            "delimiter": null,
            "directory_mode": null,
            "unsafe_writes": null
        }
    },
    "_ansible_no_log": false
}  

标签: ansible-awx

解决方案


推荐阅读