An interactive CLI tool for creating a cloud-config for cloud-init based on the current machine's configuration.
This tool is primarily meant as an exploratory tool to help users understand what cloud-init can do and how it can be used to automate the creation of virtual machines or cloud instances, by providing a starting point for the cloud-config file using a currently running machine as a reference which the user is likely already familiar with.
This CLI tool gathers information from your system and generates a cloud-config file that can be used with cloud-init to create a simple image similar to the original system.
- Gather and export Apt sources from sources.list and sources.list.d/
- Gather and export Snaps installed on the system
- Gather and export manually installed Apt packages
- Gather and export detailed operating system info
- Rename the current user to the default "ubuntu" user for VM or Cloud use
- Gather and export SSHD config info (root login, password auth, etc.)
- Gather and export SSH keys for the current user (public keys, authorized_keys)
- Gather and export User info such as what shell they use and if they have sudo rights or not
You can also install the snap binary directly from the terminal using the following command:
wget https://github.com/a-dubs/cc-builder/releases/download/v1.0.0/cc-builder_1.0.0_amd64.snap -O cc-builder.snap
sudo snap install --classic --dangerous cc-builder.snap
Until this tool is available in the Snap Store, you can install the snap binary manually.
Head over to the releases page and download the latest snap binary and save it as cc-builder.snap
.
Then, install the snap binary using the following command:
sudo snap install --classic --dangerous cc-builder.snap
-
Clone this repo
git clone https://github.com/a-dubs/cc-builder.git
-
Create and activate a virtual environment (optional but recommended)
- Install
pyvenv
(if not already installed)
sudo apt-get install python3-venv
- Create a virtual environment
python3 -m venv venv
- Activate the virtual environment
source venv/bin/activate
- Install
-
Install the dependencies
pip install .
-
Check if the CLI is working
cc-builder --help
To generate a cloud-config file, use the generate
command.
The generate
command has the following CLI usage:
Usage: cc-builder [OPTIONS]
Generate a cloud-init configuration file for the current machine.
If interactive mode is enabled, the script will prompt for the necessary information to
generate the cloud-init config file and step through each configuration module and show the
cloud-config portion generated by that module.
Only -f can be used with -i/--interactive
╭─ Options ─────────────────────────────────────────────────────────────────────────────────╮
│ --interactive -i Enable interactive mode. │
│ --quiet -q Enable quiet output. Only critical errors and │
│ essential information will be displayed. │
│ --output-path -o TEXT Path to output file. [default: cloud-config.yaml] │
│ --force -f Write over output file if it already exists. │
│ --enable-hostname Enable gathering the hostname of the machine. This │
│ will cause issues unless this exact machine is being │
│ redeployed using the generated cloud-init config. │
│ --gather-public-keys Enable gathering of all public key files in the ~/.ssh │
│ directory. This will allow you to use the same public │
│ keys on the new machine as the current machine. │
│ --password TEXT Set the password for the user. WARNING: This is │
│ incredibly insecure and is stored in plaintext in the │
│ cloud-init config. │
│ --disable-apt Disable the gathering and generation of apt config. │
│ --disable-snap Disable the gathering and generation of snap config. │
│ --disable-ssh Disable the gathering and generation of ssh config. │
│ --disable-user Disable the gathering and generation of user config. │
│ --rename-to-ubuntu-user Keep the current user config but rename it to the │
│ default 'ubuntu' user. │
│ --help -h Show this message and exit. │
│ --version Show the version and exit. │
╰───────────────────────────────────────────────────────────────────────────────────────────╯
This will output a cloud-config file named cloud-config.yaml with the default settings.
cc-builder
This will prompt the user for the necessary information to generate the cloud-config file and show the cloud-config portion generated by each module along the way.
cc-builder -i
This will output a cloud-config file named cc.yaml with the default settings.
If cc.yaml already exists, the tool will not overwrite it because the -f
flag is not passed.
cc-builder -o cc.yaml
This will output at cloud-config at the default path with default settings but will overwrite the cc.yaml file if it already exists.
cc-builder -o cc.yaml -f
This will output a cloud-config file named cc.yaml with the default settings.
But now, the tool will overwrite cc.yaml if it already exists.
cc-builder -o cc.yaml -f
This will gather all other configs except for the apt sources and packages installed on the system. And will overwrite the output file if it already exists.
cc-builder -f --disable-apt
This will prompt the user for the necessary information to generate the cloud-config file and show the cloud-config portion generated by each module along the way. It will not prompt for the output file path because it is already set to cc.yaml. And it will automatically overwrite cc.yaml if it already exists.
cc-builder -i -o cc.yaml -f
Please feel free to open an issue against this repo for any bugs or features you'd like to see addressed.
Thanks!