4 ms·
Ansible is good at putting configuration files in the right place and setting their appropriate values to what you want — provided it’s relatively simple, other
by Xophmeister 6y ago
Ansible is good at putting configuration files in the right place and setting their appropriate values to what you want — provided it’s relatively simple, otherwise prepare yourself for complex templates — or installing software from a package manager, etc., etc. As soon as you go outside what its modules provide, it gets more difficult. Modules themselves are actually easy to write, provided you maintain Ansible’s (completely reasonable) maxim of idempotency. Sometimes, however, idempotency is hard to enforce.
The best example I’ve come across is building software from source. When there’s no package, you have to do this. Some may argue that this is not Ansible’s job, but I don’t see how it’s different from `apt install`, nor where else it would fit into the pipeline. Anyway, the way I solved this for example was by pinning the idempotency on the existence of build artefacts. Those are often software-specific, so it’s quite fiddly/non-general to find the right artefact.
- snuxoll 6y agoYou should be building packages for the software, of course. If it’s some random internal app you’re chucking into a container it’s one thing, but if you’re deploying it across VMs or physical hosts you probably should put the effort into writing a rpmspec or whatever the hell Debian does (this is a large reason why I don’t do Debian-based systems, I have never been able to properly wrap my head around dpkg builds - there’s too much magic in debhelper and not enough documentation).
- notabee 6y agoI'd be interested in how you solved this, if you don't mind sharing. I tried writing a role to build source RPMs and it kind of works after doing some really dirty regex tricks, but only barely. I kept feeling that there must be a better way that I wasn't seeing.
- Xophmeister 6y agoDon’t say I didn’t warn you ;) This is not used any more — and the repo’s history looks messed up — but it was my solution to the “configure, make, make install” dance in Ansible: https://github.com/wtsi-hgi/hgi-systems/blob/master/ansible/roles/irods-client/tasks/jansson.yml https://github.com/wtsi-hgi/hgi-systems/blob/master/ansible/... The replies to my original post say this is not something Ansible should be doing. Fair enough :P I was young!
- aprdm 6y agoAnsible should be distributing the software artifact not building it. Package it as a deb as part of the CI in say jenkins and then apt install it with ansible.