Last active
May 22, 2020 10:23
-
-
Save mbrother2/c0180a19bd87503ea75aa83fade480d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@centos7 ansible]# cat ansible_check_owner.yml | |
--- | |
- name: Test stat | |
connection: local | |
hosts: 127.0.0.1 | |
tasks: | |
- name: Get stat of file | |
stat: | |
path: /root/a1.txt | |
register: check_owner | |
- name: Show infor | |
debug: | |
msg: | |
- "Owner: {{ check_owner.stat.pw_name }}" | |
- "Group: {{ check_owner.stat.gr_name }}" | |
- "Mode: {{ check_owner.stat.mode }}" | |
[root@centos7 ansible]# ansible-playbook ansible_check_owner.yml | |
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' | |
PLAY [Test stat] ******************************************************************************************************************************************************************************************************************************** | |
TASK [Gathering Facts] ************************************************************************************************************************************************************************************************************************** | |
ok: [127.0.0.1] | |
TASK [Get stat of file] ************************************************************************************************************************************************************************************************************************* | |
ok: [127.0.0.1] | |
TASK [Show infor] ******************************************************************************************************************************************************************************************************************************* | |
ok: [127.0.0.1] => { | |
"msg": [ | |
"Owner: root", | |
"Group: root", | |
"Mode: 0644" | |
] | |
} | |
PLAY RECAP ************************************************************************************************************************************************************************************************************************************** | |
127.0.0.1 : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment