Skip to content

jsf0/ansible-clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ansible-clone

This Python script will create an Ansible playbook that duplicates an existing Linux or BSD system. It will figure out all the currently installed packages and running services, and will include the contents of any config files you provide it. It will then create a playbook that will install all of these packages, enable the same services, and copy those file contents to the same paths.

The idea is that once you have a system configured the way you like it, you just run this tool and it will create a playbook that you can use to configure another system in the same way.

Similarly, you can use a playbook generated by ansible-clone to start managing a server's configuration with Ansible if it previously was not under any configuration management tool.

Currently it supports generating playbooks on the following operating systems:

  • OpenBSD
  • FreeBSD
  • Debian
  • Ubuntu
  • Linux Mint
  • Arch Linux
  • CentOS
  • Fedora
  • RHEL

usage

To use ansible-clone, you provide it with an INI file containing the paths to any files whose contents you want in the playbook, and the path to the playbook you will create:

ansible-clone -c config_file_paths.ini -f playbook.yml

This command above will load the file config_file_paths.ini and include the contents of all the config files found there in the playbook. The playbook will be written to playbook.yml

The file config_file_paths.ini here should look something like this:

[spectrwm.conf]
path = /home/joe/.spectrwm.conf

[pf.conf]
path = /etc/pf.conf

The contents of the files at these paths will be included in the resulting playbook.

ansible-clone will automatically detect all installed packages and currently-enabled services, and include those in the playbook as well. You should be able to run this playbook on a fresh OS install, and configure the new system exactly like the old one.

Supporting new operating systems

Support for new running this on other operating systems can be added fairly easily. You will need to modify the following functions:

get_installed_packages()

get_enabled_services()

TODO

  • Write a man page
  • Fix all the roff formatting in that man page that I will have messed up the first time
  • Add some command line flags to optionally disable each function (e.g, ignore packages, services, or config files)
  • Implement support for Linux. Will need to include various package managers, and systemctl to grab service info
  • Add support for including variables such as IP address, hostname, etc.
  • Add a Makefile

Releases

No releases published

Packages

No packages published

Languages