Coder Social home page Coder Social logo

ansible_homelab's Introduction

Ansible homelab

Ansible playbooks to quickly setup a homelab. These playbooks are designed to be run on a fresh install of Ubuntu 20.04/22.04. The playbook will update the system, install Docker, and then deploy the Docker containers.

Usage

  • Clone the repo to your local machine
git clone https://github.com/rishavnandi/ansible_homelab.git
  • Update the inventory file with the IP address of your server and the user you want to use to connect to the server and add the path to your ssh key, incase you are not using ssh keys (you should always use ssh keys for security) then you can replace the ansible_ssh_private_key_file with ansible_ssh_pass and add the password for the user.

  • Also update the group_vars/vars.yml file with the correct variables for your setup, for the pgid and puid, you can find the correct values by running the id command on your server and using the values for the uid and gid fields.

  • Run the playbook

ansible-playbook main.yml

Docker install issue on Ubuntu 22.04

If you are running Ubuntu 22.04, you might run into an issue where the Docker install fails. This is because of a dumb issue with Ubuntu 22.04 "Jammy" itself. The playbooks are designed to work around this issue, you just need to run the playbook twice. The first time it will fail, but it will have fixed the issue for the second run. I am working on a fix for this, but for now, this is the workaround.

  rescue:
    - name: Fix the dumb Ubuntu Jammy error
      ansible.builtin.replace:
        path: /etc/systemd/system/multi-user.target.wants/docker.service
        regexp: "fd://"
        replace: "unix://"
      when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('22.04', '>=')

Removing unwanted apps

If you don't want to run some of the apps, you can easily remove them from the main.yml file since all the containers are stored as tasks in the tasks folder and are included in the main.yml file.

Info about the apps

If you want to learn more about any of the apps, you can check out the awesome selfhosted repo.

Included Terraform script

I have included a Terraform script that I use to quickly spin up an AWS instance to run the playbook on. You can use this script to spin up an instance, or you can use it as a reference to create your own Terraform script. You can find more info about using Terraform with AWS here: https://learn.hashicorp.com/tutorials/terraform/aws-build

Goals

  • Add support for Ubuntu 22.04
  • Add SSH hardening
  • Find a permanent fix for the Docker install issue on Ubuntu 22.04
  • Use Ansible to automate some more stuff so there is no need to enter the IP address and PUID/PGID manually
  • Add support for Fedora
  • Add more apps

Credits

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.