{"id":19817585,"url":"https://github.com/nirantak/infra-automation","last_synced_at":"2025-05-01T11:30:54.422Z","repository":{"id":102319022,"uuid":"454026109","full_name":"nirantak/infra-automation","owner":"nirantak","description":"Ansible playbooks to setup dev environments and home servers","archived":false,"fork":false,"pushed_at":"2024-08-17T12:04:14.000Z","size":816,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-18T12:57:56.187Z","etag":null,"topics":["ansible","macos","pi-hole","raspberrypi"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nirantak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-31T13:55:35.000Z","updated_at":"2024-08-17T12:04:17.000Z","dependencies_parsed_at":"2024-08-17T12:47:54.493Z","dependency_job_id":null,"html_url":"https://github.com/nirantak/infra-automation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirantak%2Finfra-automation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirantak%2Finfra-automation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirantak%2Finfra-automation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirantak%2Finfra-automation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nirantak","download_url":"https://codeload.github.com/nirantak/infra-automation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224253344,"owners_count":17280934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","macos","pi-hole","raspberrypi"],"created_at":"2024-11-12T10:13:05.740Z","updated_at":"2024-11-12T10:13:06.568Z","avatar_url":"https://github.com/nirantak.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Infra Automation\n\n\u003e _Ansible playbooks to setup dev environments and home servers_\n\n- [Infra Automation](#infra-automation)\n  - [Installation](#installation)\n  - [Playbooks](#playbooks)\n    - [rpi](#rpi)\n      - [Tailscale](#tailscale)\n        - [Next Steps for Tailscale](#next-steps-for-tailscale)\n      - [Pi-hole](#pi-hole)\n        - [Next Steps for Pi-hole](#next-steps-for-pi-hole)\n      - [Home Assistant](#home-assistant)\n  - [References](#references)\n\n## Installation\n\n```bash\ngit clone https://github.com/nirantak/infra-automation.git\ncd infra-automation\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -U -r requirements.txt\nansible-galaxy collection install -r requirements.yml\n\n# To set up pre-commit hooks, required for contributing code, run:\npre-commit install --install-hooks --overwrite\n\n# On macOS, if you need to use the `-k` flag with ansible-playbook, run:\nbrew install nirantak/tap/sshpass\n```\n\nUpdate the following files to your liking:\n\n- `inventory.ini` (replace IP address with your server's IP, or use `127.0.0.1` and add `connection=local` at the end if you're running it on the machine you're setting up).\n- `group_vars/\u003cgroup\u003e.yml` to update the config for any host group from the inventory.\n- `roles/raspberry_pi/files/sample.env` for any secrets to be passed to docker-compose.\n\n---\n\n## Playbooks\n\n### rpi\n\n\u003e _Raspberry Pi setup and config for all things Internet_\n\n- Download [Raspberry Pi OS Lite 64-bit](https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit) and flash it on a Micro SD Card using [Raspberry Pi Imager](https://www.raspberrypi.com/software/)\n  - Configure the WiFi and SSH setting in Raspberry Pi Imager.\n- Update the config file [group_vars/rpi.yml](group_vars/rpi.yml) as per your needs.\n- Update the inventory file [inventory.ini](inventory.ini) with the correct IP and username.\n- Once you are able to ssh into the rpi using your credentials, run the ansible playbook to set it up.\n\n```bash\n# To run the entire setup:\nansible-playbook playbooks/raspberry_pi.yml\n# Tested on Raspberry Pi OS\n# Use the `-k` flag in the command above if you have setup password based SSH.\n# This is not needed once key-based ssh is setup.\n\n# Or run select tasks or roles using tags:\nansible-playbook playbooks/raspberry_pi.yml -t ping\n```\n\n- **NOTE**: some setup requires manual steps, you can view those by running the `manual` ansible tag.\n\n```bash\n# List all manual steps required:\nansible-playbook playbooks/raspberry_pi.yml -t manual\n```\n\n#### Tailscale\n\n\u003e _[tailscale.com](https://tailscale.com)_\n\n- Tailscale can create a private network across all devices you have installed it on, allowing you to access your home server or Pi-hole DNS from anywhere even when away from your local home network.\n- It creates a peer to peer VPN network using WireGuard.\n- Create a tailscale account and then follow these steps:\n\n```bash\n# Run tasks for tailscale setup:\nansible-playbook playbooks/raspberry_pi.yml -t tailscale\n\n# Tailscale requires manual login via the browser, so the above command may not set everything up.\n# Run the following command and then login via the link displayed:\nsudo tailscale up --qr\n\n# Once login is complete, run ansible with this tag to update configuration that requires tailscale:\nansible-playbook playbooks/raspberry_pi.yml -t tailscale_configure\n```\n\n##### Next Steps for Tailscale\n\n- If you want to use Pi-hole DNS across your Tailnet, go to [Tailscale's DNS settings](https://login.tailscale.com/admin/dns) and set these configs:\n  - Set `Global nameservers` to the Tailscale IPv4 address of your Pi-hole server (get it by running `tailscale status`).\n  - Enable `Override local DNS`.\n\n#### Pi-hole\n\n\u003e _[pi-hole.net](https://pi-hole.net)_\n\nInstalls the Pi-hole for network-wide ad-blocking and local DNS. Make sure to update your network router config to direct all DNS queries through your Raspberry Pi if you want to use Pi-hole effectively.\n\n**Pi-hole**: Access the Pi-hole dahsboard using any of the following links and use the `pihole_password` you configured in your `rpi.yml` file.\n\n- The pihole_domain setup (eg: [dns.pie.run](http://dns.pie.run/admin))\n- The IP/hostname address of the server with the configured pihole_port (eg: [pi.hole:8080](https://pi.hole:8080/admin))\n\n![Pi-hole Dashboard](.github/images/pi-hole.png)\n\n##### Next Steps for Pi-hole\n\n- Set the IP address of the Pi-hole as the DNS server in your WiFi router or device's network settings.\n- Also follow the [steps mentioned above](#next-steps-for-tailscale) to set Pi-hole as the DNS server for your Tailnet, so that ads are blocked when you are away from your home network.\n  - This way, when you are connected to your WiFi, the configured DNS server will ensure that Pi-hole is being used even when you are not connected to Tailscale.\n  - And when you connect to Tailscale either in the same WiFi network or away, it will override the DNS server setting, and you will always be connected to Pi-hole.\n\n#### Home Assistant\n\n\u003e _[home-assistant.io](https://www.home-assistant.io)_\n\n---\n\n## References\n\n- [geerlingguy/internet-pi](https://github.com/geerlingguy/internet-pi)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnirantak%2Finfra-automation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnirantak%2Finfra-automation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnirantak%2Finfra-automation/lists"}