nleiva / ansible-role-grafana_agent

Installs Grafana Cloud Agent on RedHat/CentOS or Debian/Ubuntu servers to collect observability data and send it to Grafana Cloud.
GNU General Public License v3.0
15 stars 19 forks source link

Role shows values as always changed due to recursive directory permissions #10

Closed bekriebel closed 2 years ago

bekriebel commented 2 years ago

Because the configuration directory is set to recursively set permissions to 0755: https://github.com/nleiva/ansible-role-grafana_agent/blob/da0febc2ad0f8710da422b7b6140d7b4b7f322fc/tasks/main.yml#L26 and the configuration file permissions are 0644: https://github.com/nleiva/ansible-role-grafana_agent/blob/da0febc2ad0f8710da422b7b6140d7b4b7f322fc/tasks/main.yml#L32

The role shows the directory and file tasks as changing every time the role is executed because the directory task sets the file permissions to 0755 and the template task sets them back to 0644. To fix this, the directory mode should be set using symbolic mode to set the directory to 0755 and files to 0644: mode: u=rwX,g=rX,o=rX. An example of this is here: https://stackoverflow.com/questions/28778738/ansible-mode-755-for-directories-and-644-for-files-recursively

bekriebel commented 2 years ago

I've confirmed that the change works locally.

nleiva commented 2 years ago

It this what you had in mind? https://github.com/nleiva/ansible-role-grafana_agent/commit/40b9a05e6f5f211e0c47c3426e5de6cfcd4a2a2a

bekriebel commented 2 years ago

Yep, that should do the trick 🙂