Jump to content

Hi guys,

 

I have setup my homelab with the following config:

 

i5 6500

MSI B250

240GB SSD Sandisk SATA

3X4TB Seagate ironwolf HDD set in RAID Z1

16GB 2133mhz RAM Crucial.

Seasonic 550W PSU.

 

I have installed proxmox as a hypervisor on this machine and 2 VMs - TRUENAS SCALE for running my NAS where I configured my seagate hard drives in RAID Z1 and a debian VM which has docker and a host of other containers.

For now, I am running portainer, wireguard, duckdns and immich on the debian VM. the machine seems to work fine and I further plan on installing jellyfin in this homelab setup.

 

I want to automate the entire deployment and setup process of this machine, right from installing proxmox to setup and configure all my containers. I want to leverage ansible and prepare a playbook to achieve the same. How should I get started with ansible, which IDE is best and how to develop my own playbook so that I can automate my homelab setup so that my future deployments become easier?

 

Any resources you can share will also be very helpful.

Link to comment
https://linustechtips.com/topic/1578645-getting-started-with-ansible-for-my-homelab/
Share on other sites

Link to post
Share on other sites

If you have no plans about more VMs, the upcoming 24.10 release of TrueNAS Scale would be worth waiting for. It will bring (back) native Docker support, and may make the deployment of custom services much easier (I have not taken a try to nightly builds yet though).

Also, since configurations vary drastically between builds, there may not be an Ansible Playbook readily available and suitable in each case. However, it seems straightforward to create a Playbook, and anyone familiar with admin shell commands should be pleasant to deal with it.

 

In my scenario, for example, TrueNAS Scale (pre-24.10) was installed as the host system, and Docker can only be obtained manually and re-installed after a system upgrade. While most of my configurations persisted, Docker would definitely be taken down. I decided to move the whole Docker dataset from the boot pool to another which persisted through an upgrade, and retrieve Docker after the upgrade. Then I may utilize the following Playbook:

- name: Retrieve Docker
  hosts: truenas  # Or its raw IP address
  remote_user: root
  vars:
    pkgs: docker.io  # The open-source implementation of Docker
    conf_dir: /path/to/locally-written-conf-dir
    magic_key: /usr/local/libexec/disable-rootfs-protection  # The hidden Python script unlocking APT access
  
  tasks:
  - name: Retrieve access to APT
    ansible.builtin.command: python {{ magic_key }}
  - name: Prepare conf files
    ansible.builtin.template:
      src: {{ conf_dir }}/docker-daemon.json
      dest: /etc/docker/daemon.json
  - name: Update APT
    ansible.builtin.command: apt update
  - name: Install Docker
    ansible.builtin.command: apt install -y {{ pkgs }}
    # ansible.builtin.apt is not used due to absense of python3-apt

It may not work in real world, and should be taken as reference only.

Link to post
Share on other sites

So for some of your points.

- IDE I tend to just use visual studio code. It has native support for Windows Subsystem for Linux. Unless you're running a Mac or Linux machine then you're going to need to use that as Ansible doesn't run on windows.

 

- Installing packages such as docker. There's loads of guides online such as this one https://docs.ansible.com/ansible/latest/collections/community/docker/docsite/scenario_guide.html I'd always recommend the docs.ansible.com pages as they have the actual pages.

 

Have you ever used Ansible before? I think depending on your skill would depend on the tips to give. Sure you can get a deployment working with one flat playbook. But the more 'proper' way of doing it is to create tasks, roles and link them all into a playbook but again it depends on how much time you want to put in!

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×