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. I think I need stat for that (exists, isdir, gr_name, pw_name, mode) As a first step I try to get the value of pg_name with debug, but can not figure out how to adress that value - name: Get stats of a file ansible.builtin.stat: path: "{{ item }}" register: postgres loop: - /opt/db/data - name: return ownership is right ansible.builtin.debug: msg: "owned by postgres" when: postgres.stat.pw_name == 'postgres' output TASK [show content of 'postgres'] ************************************************************************************************************************************************ fatal: [dvzsn-rd5400.ref.eakte.rz-dvz.cn-mv.de]: FAILED! => {"msg": "The conditional check 'postgres.stat.pw_name == 'postgres'' failed. The error was: error while evaluating conditional (postgres.stat.pw_name == 'postgres'): 'dict object' has no attribute 'stat'. 'dict object' has no attribute 'stat'\n\nThe error appears to be in '/home/gwagner/repos/automation_postgres/playbooks/check_postgres_dir.yml': line 16, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: show content of 'postgres'\n ^ here\n"} what I am doing wrong?
-- 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-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1292803683.374335.1694003663225%40office.mailbox.org.