netr0m / ansible-role-infra

Ansible role for infrastructure components such as DNS, VPN, uptime monitoring and more

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ansible Role: infra

CI

An Ansible role for infrastructure components as Docker containers. Handles tasks for deploying various services relating to self-hosting infrastructure.

Service Purpose Enabled by default
Pi-Hole DNS, Ad-block Yes
Graylog Log management Yes
Uptime-Kuma Uptime monitoring Yes
Vaultwarden Password management Yes
Authentik Identity management Yes
godns Dynamic DNS No
Wireguard Remote access VPN No
Unifi Unifi network management No

Installation

$ ansible-galaxy install git+https://github.com/netr0m/ansible-role-infra.git

Requirements

Requires the role netr0m.svc

Role Variables

Available variables are listed in docs/default-variables.md (see defaults/main.yml)

Minimal configuration [required]

Most of the defaults variables can be used as-is, but there are a few variables that must be set:

# Username of the user owning the files
svc_user_name: 'service_username'
# Group name of the group that should own the files
svc_group_name: 'service_groupname'

For this role

# If `infra_use_authentik` is true, then
# Secret key used for Authentik cookie signing
infra_authentik_secret_key: "some-long-random-string"
# Database password
infra_authentik_db_password: ""

# If `infra_use_graylog` is true, then
# Secret used to 'pepper' the passwords - make sure to change this BEFORE deploying.
infra_graylog_password_secret: "super-long-random-string-minimum-64-chars"
# Hash of the password used for the root user [run `echo -n yourpassword | shasum -a 256`]
infra_graylog_password_sha2: "sha256-sum-of-your-password"

Recommended configuration changes

Set the Pi-Hole admin portal password

# Password for Pihole web UI. Autogenerated if not set.
infra_pihole_password: donkeys-gamble-on-broadway55

Wireguard

# Enable Wireguard
infra_use_wireguard: true
# Set the external domain name
infra_domain_ext: mydomain.tld

# Peers to create. See https://github.com/linuxserver/docker-wireguard#parameters
infra_wireguard_peers:
  - laptop
  - desktop
  - phone

GODNS

# Optionally enable godns for DDNS (if you have dynamic DNS)
infra_use_godns: true
# DNS provider to use
infra_godns_provider: Cloudflare
# Email address for the DNS provider account
infra_godns_email: ~
# Password/Global API key (cloudflare) for the DNS provider account
infra_godns_password: ~
# Token for the DNS provider account
infra_godns_token: ~
# List of domains and subdomains to update
infra_godns_domains:
  - domain_name: "{{ infra_domain_ext }}"
    sub_domains:
      - "{{ infra_wireguard_container_hostname }}"

See netr0m.svc - Recommended configuration changes for recommended changes (automated HTTPS and more).

Dependencies

See ansible-requirements.yml for a list

Installation

ansible-galaxy collection install -r ansible-requirements.yml
ansible-galaxy role install -r ansible-requirements.yml

Example Playbook

---
- name: Example Playbook
  hosts: all
  become: true
  gather facts: true

  roles:
    - { role: netr0m.infra }
...

Development

This project uses pre-commit.

Currently, there are three hooks:

To run pre-commit manually, run pre-commit run -a

Requirements

To run pre-commit, you need three things:

  1. A virtual environment in the parent directory of this repository
  • $ python3 -m venv ../.venv
  • $ source ../.venv/bin/activate
  1. The Python dependencies (see requirements.txt)
  • $ pip install -r requirements.txt
  1. Pre-commit hooks installed
  • $ pre-commit install

Updating the 'variables' docs

This project provides a script for generating markdown files representing ansible (YAML) variable definitions.

An example can be seen in docs/default-variables.md, which is generated from the variables defined in defaults/main.yml.

Running the script

To run the generator, issue the following command. If no parameters are specified, this will generate a markdown file based on the variables in defaults/main.yml, and write it to docs/default-variables.md.

$ python3 generate-vars-md.py

# Display help message
$ python3 generate-vars-md.py --help

# Specify alternative input and output paths
$ python3 generate-vars-md.py --in-file vars/debian.yml --out-file docs/debian-vars.md --title "Debian Variables"

License

MIT

Author Information

This role was created in 2022 by netr0m

About

Ansible role for infrastructure components such as DNS, VPN, uptime monitoring and more

License:MIT License


Languages

Language:Jinja 65.2%Language:Python 23.1%Language:Shell 11.7%