Ansible roles for my LXC homelab setup
Go to file
Jeffrey Serio a4c332d36e Add dnf-automatic package 2023-07-15 00:35:26 -05:00
cloud-init Add dnf-automatic package 2023-07-15 00:35:26 -05:00
roles Add debian-archive and update roles 2023-06-10 16:55:21 -05:00
LICENSE Initial commit 2023-06-01 12:02:20 -05:00
README.org Add debian-archive and update roles 2023-06-10 16:55:21 -05:00
hosts.ini Add debian-archive and update roles 2023-06-10 16:55:21 -05:00
setup.yml Add debian-archive and update roles 2023-06-10 16:55:21 -05:00

README.org

ansible-homelab

I use these roles to automate the setup of my LXC homelab. They are highly tailored to my use-case and would require substantial review and editing for anyone else to use them.

Example

Initialize an instance:

lxc init images:debian/12/cloud debian-archive --storage lxd-pool

Configure the instance for cloud-init:

lxc config set debian-archive cloud-init.user-data - <<- EOF
#cloud-config
users:
  - name: debian
    ssh_authorized_keys:
      - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIOmibToJQ8JZpSFLH3482oxvpD56QAfu4ndoofbew5t jas@si.local
    sudo: 'ALL=(ALL) NOPASSWD: ALL'
    shell: /bin/bash
    lock_passwd: true
apt:
  sources_list: |
    deb http://deb.debian.org/debian $RELEASE main
    deb http://deb.debian.org/debian $RELEASE-updates main
    deb http://deb.debian.org/debian-security/ $RELEASE-security main
    deb http://deb.debian.org/debian $RELEASE-backports
package_update: true
package_upgrade: true
packages:
  - curl
  - debian-keyring
  - debsig-verify
  - git
  - nodejs
  - npm
  - notmuch
  - offlineimap3
  - pass
  - python3-dev
  - python3-pip
  - ripgrep
  - ssh
  - wget
  - xauth
  - youtube-dl
rsyslog:
  configs:
    - content: "*.* @10.0.0.41:514"
      filename: 99-forward.conf
  remotes:
    moonshadow: 10.0.0.41
timezone: America/Chicago
EOF

Start the instance, then check the cloud-init status:

lxc start debian-archive
lxc exec debian-archive -- cloud-init status --wait

SSH into the new instance to accept the host key:

ssh debian@10.227.115.42

Once that's done, you should be able to SSH directly to the debian user, and Ansible will be ready to run.

Add the instance's IP address to hosts.ini:

[homelab]
10.227.115.42

Run the setup.yml playbook for all roles, or choose specific roles with tags:

ansible-playbook -i hosts.ini setup.yml -u debian -b
ansible-playbook -i hosts.ini setup.yml --tags debian-archive -u debian -b