Bootstrap is a cross-platform bootstrapping tool written in Go that automates the provisioning and configuration of servers. It replaces the original Bash-based bootstrap script with a more maintainable, robust, and portable Go implementation.
-
OS-Agnostic Prerequisite Checks:
Automatically verifies and installs required tools (e.g. sudo, curl, Git, rsync, jq, Ansible, GitHub CLI). -
GitHub CLI Integration:
Installs and authenticates GitHub CLI (gh), manages SSH keys for different roles (e.g. keyserver), and updates keys on GitHub as needed. -
Ansible Integration:
Runsansible-pullwith the appropriate SSH key and vault password support, making it easy to bootstrap servers with Ansible-based configurations. -
One-Shot Post-Reboot Service:
Optionally sets up a one-shot systemd service (using the--mise-installflag) that runs a command (e.g./home/linuxbrew/.linuxbrew/bin/mise install) once after reboot. -
Modular and Extensible:
Written in Go for better error handling, maintainability, and ease of adding new features compared to a complex Bash script.
Clone the repository and build the executable:
git clone https://github.com/sparkleHazard/bootstrap.git
cd bootstrap
go build -o bootstrap .This will produce a binary named bootstrap that you can run on your server.
Usage
Bootstrap can be run directly on the target host. It accepts several command-line arguments to control its behavior. For example:
sudo ./bootstrap --role=webserver --verbose --mise-install--role=ROLESpecify the server role to provision (e.g. base, keyserver, webserver). Default: base--verboseEnable verbose output for detailed logging.--mise-installSet up a one-shot systemd service to run /home/linuxbrew/.linuxbrew/bin/mise install once after reboot.--helpDisplay usage information.
Certain configuration options (such as repository URL, vault password file location, and command paths) are defined within the source code as variables. You can adjust these in the main source file as needed for your environment.
Bootstrap is designed to integrate seamlessly with Ansible:
- It ensures prerequisites are met and the environment is configured.
- It invokes ansible-pull with proper SSH keys and vault support to apply configuration from an Ansible repository.
- It supports both pull (ansible-pull) and push (ansible-playbook) models.
For more details on how to integrate Ansible with your provisioning, see the Ansible documentation.
flowchart TD
A[User triggers bootstrap via curl piped into bash] --> B[Download and execute bootstrap binary]
B --> C[Parse command-line arguments]
C --> D[Ensure ~/.ssh exists and prerequisites are installed]
D --> E{Determine role}
E -- keyserver --> F[Generate and register GitHub SSH key]
E -- other --> G[Fetch GitHub SSH key via rsync]
F --> H[Run ansible-pull for keyserver configuration]
G --> I[Run ansible-pull for standard configuration]
H --> J[Optionally set up one-shot service for 'mise install']
I --> J
J --> K[End bootstrapping process]
Contributions are welcome! Please submit issues or pull requests for:
- Bug fixes and improvements
- New features and role enhancements
- Documentation updates
For major changes, please open an issue first to discuss your ideas.
Our project follows Semantic Versioning. Version numbers follow the format vMAJOR.MINOR.PATCH.
- MAJOR: Increment when you make incompatible API changes.
- MINOR: Increment when you add functionality in a backward-compatible manner.
- PATCH: Increment when you make backward-compatible bug fixes.
-
Make sure your local repository is up to date:
git pull
-
Tag the current commit:
git tag -a v1.0.0 -m "Release version 1.0.0" -
Push the tag to GitHub:
git push origin v1.0.0
Please update the CHANGELOG.md with a summary of changes for each release. We follow Keep a Changelog format.
When a new version tag is pushed, our CI/CD pipeline automatically builds the binaries for all supported platforms and creates a GitHub Release with the release assets and changelog. Refer to our GitHub Actions workflows for further details.
This project is licensed under the MIT License. See the LICENSE file for details.
- Customization: Adjust the repository URL, file paths, and any configuration variables in the source as needed.
- Testing: Make sure to test the binary in your target environments to ensure it works as expected.
- Documentation: Update the README as new features or configuration options are added.
Let me know if you need further modifications or additional details!