devops-coop / ansible-haproxy

Installs and configure HAProxy
Apache License 2.0
96 stars 97 forks source link

tasks are marked as changed always #42

Closed ozbillwang closed 8 years ago

ozbillwang commented 8 years ago

This galaxy roles work nicely that I can use directly without modification. Good job. 👍

But when repeatly run the ansible playbook, most tasks are still marked as changed

Any suggestions to get ride of it? I'd like to get all OK status in the end.

TASK [haproxy : Empty the folder if not already empty] *************************
changed: [10_1_1_2]

cmd: find /etc/haproxy/compiled -name *.cfg -exec rm -f {} ;

start: 2016-05-17 17:05:40.986202

end: 2016-05-17 17:05:40.992326

delta: 0:00:00.006124

TASK [haproxy : Build up the global config] ************************************
changed: [10_1_1_2]

TASK [haproxy : Build up the default config] ***********************************
changed: [10_1_1_2]

TASK [haproxy : Assemble the backends configuration file] **********************
changed: [10_1_1_2]

msg: OK

TASK [haproxy : Assemble the frontends configuration file] *********************
changed: [10_1_1_2]

msg: OK

TASK [haproxy : Assemble the listen sections configuration file] ***************
changed: [10_1_1_2]

msg: OK

TASK [haproxy : Assemble the userlists sections configuration file] ************
changed: [10_1_1_2]

msg: OK
PierrePaul commented 8 years ago

I don't think it would be 100% possible to have the correct status for each tasks. The module creates separate files for each section then join them together in a big readable file.

In the best case scenario, we could generate the last file in a temporary folder then compare the hash with the current file. before copying over (and trigger the 'CHANGED' state). You would still be left with 90% of task with the CHANGED state (all task related to each file generation).

Unless we go crazy with regex, I dont think there is a proper way to check if the files need to be regenerated again.

An official haproxy module has been created (see #23 - http://docs.ansible.com/ansible/haproxy_module.html ) but has limited options so far.