task to obtain the stats of /etc/foo.config and check that the file still belongs to the root - Ansible

0 votes

How do I write a task to obtain the stats of /etc/foo.config and check that the file still belongs to the root?

Apr 2 in Ansible by Neha
38 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Hey @Neha, you can use the stats module provided by Ansible. 

- stat:
    path: /etc/foo.conf
  register: st
- fail:
    msg: "Whoops! file ownership has changed"
  when: st.stat.pw_name != 'root'
answered Apr 2 by Alok

Related Questions In Ansible

0 votes
1 answer
0 votes
1 answer

Check status of an operation running in the background - Ansible

Hey @Neel, According to the documentation, Long running ...READ MORE

answered Mar 6 in Ansible by Yesha
11 views
0 votes
1 answer
+13 votes
2 answers
0 votes
1 answer
+1 vote
1 answer

Is it possible to append a large amount of text to a file using Ansible?

Here is concept which you can follow. blockinfile is ...READ MORE

answered Jul 30, 2018 in Ansible by Atul
• 10,190 points
1,385 views
0 votes
1 answer

How to encrypt and existing file using Ansible Vault?

Hey @Kyraa, to encrypt an existing file ...READ MORE

answered Jan 29 in Ansible by Kavya
133 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.