gsoft-inc / ansible-role-azure-devops-agent

An Ansible role that installs and configures a Linux machine to be used as an Azure DevOps build or deployment agent.
59 stars 72 forks source link

Agent is reinstalled every time the playbook is run #9

Closed krknopp closed 4 years ago

krknopp commented 4 years ago

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.

yohanb commented 4 years ago

@krknopp yeah it's expected. It was the easiest way to apply changes, no matter the current state of the agent.

marchenm commented 4 years ago

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.

yohanb commented 4 years ago

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. ✌️

krknopp commented 4 years ago

@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.

yohanb commented 4 years ago

@krknopp no it fell off my radar 😕 I can have a look at it tomorrow!

krknopp commented 4 years ago

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.

yohanb commented 4 years ago

@krknopp please see PR that's open with the suggested fix :)

krknopp commented 4 years ago

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!