- name: Get stats of a file
ansible.builtin.stat:
path: /opt/db/data
register: postgres
- name: return ownership is right
ansible.builtin.debug:msg: "owned by postgres"
when: postgres.stat.pw_name == 'postgres'
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1292803683.374335.1694003663225%40office.mailbox.org.
TASK [what is postgres] ************************************************************************************************
ok: [localhost] => {
"postgres": {
"changed": false,
"msg": "All items completed",
"results": [
{
"ansible_loop_var": "item",
"changed": false,
"failed": false,
"invocation": {
"module_args": {
"checksum_algorithm": "sha1",
"follow": false,
"get_attributes": true,
"get_checksum": true,
"get_md5": false,
"get_mime": true,
"path": "/opt/db/data"
}
},
"item": "/opt/db/data",
"stat": {
"exists": false
}
}
],
"skipped": false
I want to check for existence of a folder and also the right owner, group and mode.When any of the conditions (exists, owner=postgres, group=postgres, mode=0755) does not meet requirements I want to stop and be notified of the reason.