Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VM Bootstrap (Ubuntu / Debian)

This repository provides a simple, repeatable way to bootstrap new Ubuntu or Debian virtual machines using Ansible.

The goal is to eliminate manual “first 10 minutes” setup work by standardizing:

  • SNMP configuration (LibreNMS-compatible)
  • Checkmk agent installation
  • NFS mounts
  • Hostname resolution for NAS access

Once set up, onboarding a new VM is a single command.


What This Does

For each target VM, the bootstrap playbook:

  • Ensures nas resolves to a fixed IP via /etc/hosts
  • Installs baseline packages:
    • snmpd
    • nfs-common
    • git
  • Deploys a known-good snmpd.conf
  • Installs the LibreNMS distro helper script for SNMP
  • Installs the LibreNMS / Checkmk agent:
    • Clones the LibreNMS agent repo to /opt/librenms-agent
    • Installs check_mk_agent to /usr/bin
    • Installs and enables the check_mk.socket systemd unit
  • Creates and mounts a standard NFS mount:
    • nas:/pool/vol1
    • Safe boot options (_netdev, nofail, x-systemd.automount)

All steps are idempotent and safe to re-run.


Repository Layout

vm-bootstrap/
├── bootstrap.yml        # Main Ansible playbook
├── enroll               # Convenience script to enroll a new VM
├── inventory.ini        # Optional static inventory
├── files/
│   └── snmpd.conf       # SNMP configuration deployed to target hosts
└── README.md

Requirements

Control Machine (your laptop)

  • macOS
  • Homebrew
  • Ansible

Install Ansible:

brew install ansible

Verify:

ansible --version

Target VMs

  • Ubuntu or Debian
  • SSH access
  • A user with sudo privileges
  • SSH key-based authentication recommended

Installation

  1. Clone or copy this repository to your laptop:
git clone <this-repo>
cd vm-bootstrap
  1. Place your snmpd.conf in:
files/snmpd.conf
  1. Ensure the enroll script is executable:
chmod +x enroll

Usage

Enroll a new VM (recommended)

./enroll <ip> <user>

Example:

./enroll 192.168.1.38 zinger

This will:

  1. Verify SSH connectivity
  2. Run the Ansible bootstrap playbook

If run with no arguments, the script prints usage instructions.


Using a static inventory (optional)

Edit inventory.ini:

[newvms]
192.168.1.38 ansible_user=zinger

Run manually:

ansible-playbook -i inventory.ini bootstrap.yml --ask-become-pass

Customization

Common variables are defined near the top of bootstrap.yml:

nas_ip: "192.168.1.250"
nas_host: "nas"
nfs_src: "nas:/pool"
nfs_path: "/vol1"

Adjust these if your environment changes.


Notes

  • The playbook is hypervisor-agnostic (KVM, Proxmox, etc.)
  • Safe to re-run at any time to converge systems to the desired state
  • Designed for small homelab and infrastructure environments

Future Enhancements (Optional)

  • Passwordless sudo in VM templates
  • Cloud-init integration
  • Conversion to Ansible roles
  • Automatic enrollment via Proxmox or libvirt hooks

License

Internal / personal use. Modify freely.

About

Ansible script to install basic tools and configurations

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages