I have a few VMs and PMs around the house that I’d setup over time and I’d now like to rebuild some, not to mention just simplify the whole lot.
How the hell do I get from a working system to an equivalent ansible playbook without many (MANY) iterations of trial & error - and potentially destroying the running system??
Ducking around didn’t really show much so I’m either missing a concept / keyword, or, no-one does this.
Pointers?
TIA
I went through this about 6 months ago.
Just build playbooks from basic to specific. I did so in three parts:
- Container creation
- Basic settings common to all my hosts
- Specific service config & software
Ansible assumes you have a hierarchy of roles to apply for each service, so layering playbooks this way should help
I would copy the existing system onto a new system:
- Update system to the latest packages
- Create a new base system using the same distro
- Check which packages are not on the new system, add them to your playbook
- Install packages on new system
- This will take some time. Run a find of all files and pass them to md5sum or sha512sum to get a list of files with their checksum. Compare the list from the old system to the new system.
- Update your playbook with these findings. Template is probably the way to go, Lineinfile might be good as well, use copy if nothimg else works.
- Check firewall settings and update your playbook.
Anyhow this will take some iterations, but while you have a copy of your ‘production’ system, you can test on your ‘test’ machine until you have the same functionality.
Hmm, that’s not a bad shout actually…
I can fire up VMs to replicate the real system and maybe (depending on space) keep them as a testbed for future mods.
Thanks, good idea.