infrastructure
infrastructure copied to clipboard
Add logging to Ansible Playbooks
A solution inspired by @gdams. Add a role to the playbooks which updates a file on the remote machine indicating that the playbook has run on the remote machine, including a timestamp.
This file should be able to be queried by test tools to determine when the last playbook run happened on the remote machine
Features:
- [x] Basic log (date and time)
- [x] Runs even when certain roles are specified with
-t
- [ ] Logs which roles were executed
- [ ] Runs log even when playbook fails (might require handlers)
- [x] Logs git hash (or equivalent) of playbook
I think the issue should be called "Use file on ansible target to track after each time playbook run"
Very basic implementation at https://github.com/adoptium/infrastructure/pull/2746. Once merged I will work on adding extra features
I think the issue should be called "Use file on ansible target to track after each time playbook run"
Feel free to change it 👍🏻 I'm terrible with issue titles
Assume this issue should cover non-Linux machine as well? #2746 is only linux part
I am also curious, if we run our playbook via AWX, does not AWX have API which other tools can query when was the last time it runs on any machine and so on?
Because to dump a file onto the machine so other tools to read this file , this requires high permission on that machine, than query AWX
Assume this issue should cover non-Linux machine as well? https://github.com/adoptium/infrastructure/pull/2746 is only linux part
That pr covers mac and solaris aswell. I will add the role to the windows and aix playbooks soon
I am also curious, if we run our playbook via AWX, does not AWX have API which other tools can query when was the last time it runs on any machine and so on?
One can also execute the playbooks from their workstation, so this ensures that in either circumstance a log file will be created
Because to dump a file onto the machine so other tools to read this file , this requires high permission on that machine, than query AWX
The file is currently in the jenkins home directory, which as far as I know, should be accessible to test tools. But we can change this in the future
I am also curious, if we run our playbook via AWX, does not AWX have API which other tools can query when was the last time it runs on any machine and so on?
One can also execute the playbooks from their workstation, so this ensures that in either circumstance a log file will be created
Is the current working process allowing the ones with ssh-key to these machines to run playbook directly from local env.? how could this prevent non-master branch changes get onto such machines? looks like test tools not only need to know when was the last time ansbile was run but also which SHA ansible ran with.
how could this prevent non-master branch changes get onto such machines? looks like test tools not only need to know when was the last time ansbile was run but also which SHA ansible ran with.
That is why the final checkbox on this issue is "Logs git hash (or equivalent) of playbook"
@Haroon-Khel How is this different from https://github.com/adoptium/infrastructure/issues/2202?
@Haroon-Khel How is this different from #2202?
I'm going to close this. If anyone disagrees feel free to reopen.