Skip to content
This repository was archived by the owner on Nov 19, 2025. It is now read-only.

Fix for state warning in ansible 2.6.5#24

Open
Spreadcat wants to merge 3 commits intoarillso:masterfrom
Spreadcat:master
Open

Fix for state warning in ansible 2.6.5#24
Spreadcat wants to merge 3 commits intoarillso:masterfrom
Spreadcat:master

Conversation

@Spreadcat
Copy link

This change fixes the warning in ansible 2.6.5 regarding the state parameter in the module file.

TASK [ansible_role_logrotate : Symlink for hourly rotation] ********************
 [WARNING]: The src option requires state to be 'link' or 'hard'.  This will
become an error in Ansible 2.10

Copy link
Contributor

@hadret hadret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach won't fly -- logrotate_use_hourly_rotation is a boolean and it's always defined in defaults/main.yml. It will result in always creating link, regardless of the boolean value. I think this approach would be better:

- name: Symlink for hourly rotation
  file:
    path: "/etc/cron.hourly/logrotate"
    src: "/etc/cron.daily/logrotate"
    state: link
  when: logrotate_use_hourly_rotation | bool

The caveat with this approach is the change of the behavior -- the symlink won't be cleaned up/removed on the logrotate_use_hourly_rotation change.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants