I have a prepared ansible playbook to install Jenkins on new VMs:
prepare filesystem
technical account(s)
base repository
required OS packages
Jenkins base configuration for systemd mainly
base plugins
Is there a way to dump active Jenkins to a code? I would like to copy current configuration to a code, not necessarily ansible.
I would like to easily install Jenkins on VMs with a similar configuration. What’s the best way to go about it?
Most of the time you wouldn’t want to duplicate Jenkins installations. Why? Because some tasks are scheduled, and you probably don’t want the same job schedules to run multiple times (on muliple jenkins installations).
If you want to create a backup of jobs then you just need to copy config.xml from each job (this will not include artifacts etc).
If you want a create a backup of jenkins configuration then you’ll need to backup main config.xml as well as other files (probably except for workspace and jobs).
If you want to run multiple instances of Jenkins then you probably want to create Nodes. In which case Jenkins will install most things for you (e.g. will install Java so you can execute Maven build and tests).