Closed krknopp closed 4 years ago
@krknopp yeah it's expected. It was the easiest way to apply changes, no matter the current state of the agent.
one possible solution is adding a reconfigure
variable and adding it to the when statements for the uninstall and unconfigure tasks, and using the when: service_running.rc == 1 or reconfigure
statement to configure and install the agent. This way the role will be idempotent.
Additionally, you can write the variables to file and only reinstall when that file changes.
indeed, that could be a better way to be idempotent. I'll have time to test it out next week. If ever you want to submit a pr for the change, that would also be great. ✌️
@yohanb did you ever make any progress on this? I was going to try to work on it, as I really need it, but didn't want to duplicate any of your work.
@krknopp no it fell off my radar 😕 I can have a look at it tomorrow!
That'd be awesome. I have a feeling you'll be faster than I would be, but let me know if you don't think you'll have time.
@krknopp please see PR that's open with the suggested fix :)
Looks great! I ran it through my environment and both --check
and the actual run works. I tested with the variable on one of my agents to force a reinstall and it worked great too. I'd say merge it. And thanks!
Unless I'm missing something, every time this is run, the Agent is reinstalled. Is that expected? I had to write some logic in to prevent this from happening.