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
115 views

1 answer to this question.

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
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
39 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
264 views
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,240 points
3,282 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
657 views