Code Monkey home page Code Monkey logo

home.base's Introduction

My Home system - Base

This repo contains the IaC for my home system. It's based on KVM/libvirt VM(s). Applications are running in containers using the Docker runtime (for now). Application stacks (docker-compose) are being synchronized with git repository (home.apps) using Portainer.

What's behind this

I tried to create an infrastructure for my home system to be as simple as possible but still to have some level of automation. Before i endedup with this simple design i was elaborating RKE2, K3s and Nomad... but since at work i am managing large K8s sclusters, to have a complex cluster also at home was my last intention (in addition to few hardware limitations).

How it works

The IaC is located in the code directory. Most likely you will not need to change it. The directory env contains the variables for environments where you want to deploy this system. The content looks like this:

├── example               <<< # the name of the environment
│   ├── group_vars        <<< # group wars dir
│   │   └── all.yml       <<< # group wars file for all nodes
│   ├── hosts.ini         <<< # Ansible inventory file (will be generated during the run)
│   ├── backend.hcl       <<< # Terraform backend config (encrypted)
│   ├── secrets.tfvars    <<< # Terraform secret variables (encrypted)
│   └── terraform.tfvars  <<< # Terraform variables

don't forget to export ANSIBLE_VAULT_PASSWORD_FILE

To deploy the system, run:

ansible-playbook -i env/example/hosts.ini site.yml --extra-vars "deployment=present"

To only configure the system, and do not tun terraform apply (but still it will run the terraform plan):

ansible-playbook -i env/example/hosts.ini site.yml --extra-vars "only_tf_plan=true"

To destroy the system, run:

ansible-playbook -i env/example/hosts.ini site.yml --extra-vars "deployment=absent"

To update Terraform cache, run:

ansible-playbook -i env/example/hosts.ini site.yml --tags decrypt
cd code/terraform/
terraform init -backend-config=../../env/example/decrypted.backend.hcl -reconfigure

To manually run the terraform (prep steps are the same as above):

terraform plan -var-file=../../env/prod/terraform.tfvars -var-file=../../env/prod/decrypted.secrets.tfvars

Some facts:

  • Secrets are encrypted using Ansible-vault (so you need to provide --ask-vault-pass option or ANSIBLE_VAULT_PASSWORD_FILE environment variable)
  • I am using Terraform cloud to store the state file

Deployment workflow

Design

Compute nodes

  • Mini PCs
    • Prod - 4xCPU Intel i3, 8 GB RAM, 120GB SSD, 4TB external HDD, 60GB USB flash drive
    • Dev - 2xCPU Pentium-D, 8 GB RAM, 120GB SSD
  • Ubuntu 20.04 LTS
  • KVM/libvirt 4.0.0

TO DO list

  • Automated backup of heimdall, Home Assistant and Portainer configs
  • Use the second compute node for dev environment
  • CI/CD using Github Actions

home.base's People

Contributors

monolithprojects avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

dzeykop

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.