Coder Social home page Coder Social logo

shaderecker / ansible-pihole Goto Github PK

View Code? Open in Web Editor NEW
126.0 7.0 33.0 78 KB

Bootstrap a Raspberry Pi with Ansible and install Docker + Pi-hole

Shell 12.12% YAML 80.12% Jinja 7.75%
ansible ansible-playbook pihole sync keepalived high-availability docker raspberry-pi

ansible-pihole's People

Contributors

relaxdiego avatar shaderecker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-pihole's Issues

Question: ports? / reverse proxy

Thank you for this project! It was immensely helpful getting started with Pi-hole quickly while having peace of mind that I won't have to spend time if I need to fix something later.

I want to add a service to my RPi that should be available as a custom domain, so I need to setup a reverse proxy. However, I noticed that I don't understand how this project achieves the Pi-hole docker container to be available from outside. I don't see the ports recommended in the README of docker-pi-hole reflected in the corresponding main.yml of roles/pihole/tasks (starting line 31). I tried to look around a bit but I'm lost.

Would you mind explaining to me where I need to point incoming connections to a reverse proxy instead of Pi-hole directly? I would probably either use traefik in docker or have a look at running nginx on the host, I'm not sure yet. Thanks!

lighttpd error 403 instead of 200

I've tried updating my pi-hole instances, but I'm receiving lighthttpd errors. I'm not sure if pi-hole has any breaking changes in their latest updates, but I haven't changed anything myself except for trying to update them.
I've also formatted 1 Pi and tried to bootstrap it, but I'm getting the same result.

image

Anybody who can help me out?

update-pihole.yaml failing with: Error connecting: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))"}

Hello, I am trying to run the update-pihole.yaml on some piholes I had configured prior to finding your tool. I did not deploy these piholes with this tool.

When I try to run update it fails in task:

TASK [pihole : Start/Update pihole container] **********************************

fatal: [pihole-2]: FAILED! => {"changed": false, "msg": "Error connecting: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))"}

The prior tasks appear to work fine, ssh connection looks okay, any thoughts? Just looking for a simple way to keep piholes up to date with Ansible. I am already using rsync on the two to keep them synchronized, so I don't think I need ha mode, was just going to run update on each one.

Implement catch for IPv6 interface

As of #3 the playbook crashes when Ansible is not able to reach Google over IPv6 to determine the default IPv6 interface.
Implement a catch/default around ansible_default_ipv6.interface in the needed parts.

pihole role:

keepalive role:

Put sane default value (eth0) in roles/pihole/defaults/main.yaml & roles/keepalived/defaults/main.yaml (interface can be adjusted there if needed).

Fails on Zero-WH

OK, I used Ansible today for the first time. Had to install and configure a lot since ansible doc is not quite there yet.
But there should be a bit more info here in this repo, too especially about the config options in inventory.yaml. My Zero was called zero-1L initially. In the inventory, it was pihole-1. I assigned the real name for the ansible_host, but I was not aware that the hostname would be changed to pihole-1 and therefore the machine be restarted during the ansible run, which then of course hangs.
When the Zero returns, all ssh settings are gone since this is a different machine now. Perhaps it makes sense to document the hosts: setting so that ansible noobs know that this will be the new hostname after the first run gets to this point.
Also, the various hardening steps should be optional. I am not sure what you mean by locking the password to the ansible user, so I created another user apart from pi, so that this playbook does not mess with my login. Then I needed to add a become_pass, which ultimately failed and I had to grant passwordless sudo to my ansible user.
After one hour of upgrading the OS, Zero is finally ready to install docker, which of course fails spectacularly with a megabyte of error messages.
I used a fresh Zero-WH with a 32GB SD and a Raspbian Lite (buster 32bit) downloaded today.
If you create and test this repo on a machine that has run Ansible for decades, you might not be aware of all dependencies and prerequisites. The same applies for the user: They should have some experience with Ansible before running any of this.

fatal: [pihole-1]: FAILED! => {"cache_update_time": 1633473556, "cache_updated": false, "changed": false, "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\" install 'docker-ce' 'python3-setuptools' 'python3-pip' -o APT::Install-Recommends=no' failed: E: Sub-process /usr/bin/dpkg returned an error code (1)\n", "rc": 100, "stderr": "E: Sub-process /usr/bin/dpkg returned an error code (1)\n", "stderr_lines": ["E: Sub-process /usr/bin/dpkg returned an error code (1)"], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following additional packages will be installed:\n containerd.io docker-ce-cli python-pip-whl python3-distutils python3-lib2to3\nSuggested packages:\n cgroupfs-mount | cgroup-lite python-setuptools-doc\nRecommended packages:\n apparmor docker-ce-rootless-extras git libltdl7 python3-dev python3-wheel\nThe following NEW packages will be installed:\n containerd.io docker-ce docker-ce-cli python-pip-whl python3-distutils\n python3-lib2to3 python3-pip python3-setuptools\n0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 64.9 MB of archives.\nAfter this operation, 274 MB of additional disk space will be used.\nGet:1 http://archive.raspberrypi.org/debian buster/main armhf python-pip-whl all 18.1-5+rpt1 [1591 kB]\nGet:2 http://mirror1.hs-esslingen.de/pub/Mirrors/archive.raspbian.org/raspbian buster/main armhf python3-lib2to3 all 3.7.3-1 [76.7 kB]\nGet:5 https://download.docker.com/linux/raspbian buster/stable armhf containerd.io armhf 1.4.11-1 [15.4 MB]\nGet:6 http://archive.raspberrypi.org/debian buster/main armhf python3-pip all 18.1-5+rpt1 [171 kB]\nGet:3 http://ftp.halifax.rwth-aachen.de/raspbian/raspbian buster/main armhf python3-distutils all 3.7.3-1 [142 kB]\nGet:4 http://ftp.gwdg.de/pub/linux/debian/raspbian/raspbian buster/main armhf python3-setuptools all 40.8.0-1 [306 kB]\nGet:7 https://download.docker.com/linux/raspbian buster/stable armhf docker-ce-cli armhf 5:20.10.9~3-0~raspbian-buster [34.0 MB]\nGet:8 https://download.docker.com/linux/raspbian buster/stable armhf docker-ce armhf 5:20.10.9~3-0~raspbian-buster [13.2 MB]\nFetched 64.9 MB in 56s (1154 kB/s)\nSelecting previously unselected package containerd.io.\r\n(Reading database ... \r(Reading database ... 5%\r(Reading database ... 10%\r(Reading database ... 15%\r(Reading database ... 20%\r(Reading database ... 25%\r(Reading database ... 30%\r(Reading database ... 35%\r(Reading database ... 40%\r(Reading database ... 45%\r(Reading database ... 50%\r(Reading database ... 55%\r(Reading database ... 60%\r(Reading database ... 65%\r(Reading database ... 70%\r(Reading database ... 75%\r(Reading database ... 80%\r(Reading database ... 85%\r(Reading database ... 90%\r(Reading database ... 95%\r(Reading database ... 100%\r(Reading database ... 40997 files and directories currently installed.)\r\nPreparing to unpack .../0-containerd.io_1.4.11-1_armhf.deb ...\r\nUnpacking containerd.io (1.4.11-1) ...\r\nSelecting previously unselected package docker-ce-cli.\r\nPreparing to unpack .../1-docker-ce-cli_5%3a20.10.9~3-0~raspbian-buster_armhf.deb ...\r\nUnpacking docker-ce-cli (5:20.10.9~3-0~raspbian-buster) ...\r\nSelecting previously unselected package docker-ce.\r\nPreparing to unpack .../2-docker-ce_5%3a20.10.9~3-0~raspbian-buster_armhf.deb ...\r\nUnpacking docker-ce (5:20.10.9~3-0~raspbian-buster) ...\r\nSelecting previously unselected package python-pip-whl.\r\nPreparing to unpack .../3-python-pip-whl_18.1-5+rpt1_all.deb ...\r\nUnpacking python-pip-whl (18.1-5+rpt1) ...\r\nSelecting previously unselected package python3-lib2to3.\r\nPreparing to unpack .../4-python3-lib2to3_3.7.3-1_all.deb ...\r\nUnpacking python3-lib2to3 (3.7.3-1) ...\r\nSelecting previously unselected package python3-distutils.\r\nPreparing to unpack .../5-python3-distutils_3.7.3-1_all.deb ...\r\nUnpacking python3-distutils (3.7.3-1) ...\r\nSelecting previously unselected package python3-pip.\r\nPreparing to unpack .../6-python3-pip_18.1-5+rpt1_all.deb ...\r\nUnpacking python3-pip (18.1-5+rpt1) ...\r\nSelecting previously unselected package python3-setuptools.\r\nPreparing to unpack .../7-python3-setuptools_40.8.0-1_all.deb ...\r\nUnpacking python3-setuptools (40.8.0-1) ...\r\nSetting up containerd.io (1.4.11-1) ...\r\nCreated symlink /etc/systemd/system/multi-user.target.wants/containerd.service -> /lib/systemd/system/containerd.service.\r\nSetting up docker-ce-cli (5:20.10.9~3-0~raspbian-buster) ...\r\nSetting up python-pip-whl (18.1-5+rpt1) ...\r\nSetting up python3-lib2to3 (3.7.3-1) ...\r\nSetting up python3-distutils (3.7.3-1) ...\r\nSetting up python3-setuptools (40.8.0-1) ...\r\nSetting up docker-ce (5:20.10.9~3-0~raspbian-buster) ...\r\nCreated symlink /etc/systemd/system/multi-user.target.wants/docker.service -> /lib/systemd/system/docker.service.\r\nCreated symlink /etc/systemd/system/sockets.target.wants/docker.socket -> /lib/systemd/system/docker.socket.\r\nJob for docker.service failed because the control process exited with error code.\r\nSee \"systemctl status docker.service\" and \"journalctl -xe\" for details.\r\ninvoke-rc.d: initscript docker, action \"start\" failed.\r\n* docker.service - Docker Application Container Engine\r\n Loaded: loaded (\u001b]8;;file://pihole-1/lib/systemd/system/docker.service\u0007/lib/systemd/system/docker.service\u001b]8;;\u0007; enabled; vendor preset: enabled)\r\n Active: activating (auto-restart) (Result: exit-code) since Wed 2021-10-06 00:43:32 CEST; 141ms ago\r\n Docs: \u001b]8;;https://docs.docker.com\u0007https://docs.docker.com\u001b]8;;\u0007\r\n Process: 10471 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock \u001b[0;1;31m(code=exited, status=1/FAILURE)\u001b[0m\r\n Main PID: 10471 (code=exited, status=1/FAILURE)\r\n\r\nOct 06 00:43:31 pihole-1 systemd[1]: \u001b[0;1;31m\u001b[0;1;39m\u001b[0;1;31mFailed to start Docker Application Container Engine.\u001b[0m\r\ndpkg: error processing package docker-ce (--configure):\r\n installed docker-ce package post-installation script subprocess returned error exit status 1\r\nSetting up python3-pip (18.1-5+rpt1) ...\r\nProcessing triggers for man-db (2.8.5-2) ...\r\nProcessing triggers for systemd (241-7~deb10u8+rpi1) ...\r\nErrors were encountered while processing:\r\n docker-ce\r\n", "stdout_lines": ["Reading package lists...", "Building dependency tree...", "Reading state information...", "The following additional packages will be installed:", " containerd.io docker-ce-cli python-pip-whl python3-distutils python3-lib2to3", "Suggested packages:", " cgroupfs-mount | cgroup-lite python-setuptools-doc", "Recommended packages:", " apparmor docker-ce-rootless-extras git libltdl7 python3-dev python3-wheel", "The following NEW packages will be installed:", " containerd.io docker-ce docker-ce-cli python-pip-whl python3-distutils", " python3-lib2to3 python3-pip python3-setuptools", "0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.", "Need to get 64.9 MB of archives.", "After this operation, 274 MB of additional disk space will be used.", "Get:1 http://archive.raspberrypi.org/debian buster/main armhf python-pip-whl all 18.1-5+rpt1 [1591 kB]", "Get:2 http://mirror1.hs-esslingen.de/pub/Mirrors/archive.raspbian.org/raspbian buster/main armhf python3-lib2to3 all 3.7.3-1 [76.7 kB]", "Get:5 https://download.docker.com/linux/raspbian buster/stable armhf containerd.io armhf 1.4.11-1 [15.4 MB]", "Get:6 http://archive.raspberrypi.org/debian buster/main armhf python3-pip all 18.1-5+rpt1 [171 kB]", "Get:3 http://ftp.halifax.rwth-aachen.de/raspbian/raspbian buster/main armhf python3-distutils all 3.7.3-1 [142 kB]", "Get:4 http://ftp.gwdg.de/pub/linux/debian/raspbian/raspbian buster/main armhf python3-setuptools all 40.8.0-1 [306 kB]", "Get:7 https://download.docker.com/linux/raspbian buster/stable armhf docker-ce-cli armhf 5:20.10.9~3-0~raspbian-buster [34.0 MB]", "Get:8 https://download.docker.com/linux/raspbian buster/stable armhf docker-ce armhf 5:20.10.9~3-0~raspbian-buster [13.2 MB]", "Fetched 64.9 MB in 56s (1154 kB/s)", "Selecting previously unselected package containerd.io.", "(Reading database ... ", "(Reading database ... 5%", "(Reading database ... 10%", "(Reading database ... 15%", "(Reading database ... 20%", "(Reading database ... 25%", "(Reading database ... 30%", "(Reading database ... 35%", "(Reading database ... 40%", "(Reading database ... 45%", "(Reading database ... 50%", "(Reading database ... 55%", "(Reading database ... 60%", "(Reading database ... 65%", "(Reading database ... 70%", "(Reading database ... 75%", "(Reading database ... 80%", "(Reading database ... 85%", "(Reading database ... 90%", "(Reading database ... 95%", "(Reading database ... 100%", "(Reading database ... 40997 files and directories currently installed.)", "Preparing to unpack .../0-containerd.io_1.4.11-1_armhf.deb ...", "Unpacking containerd.io (1.4.11-1) ...", "Selecting previously unselected package docker-ce-cli.", "Preparing to unpack .../1-docker-ce-cli_5%3a20.10.9~3-0~raspbian-buster_armhf.deb ...", "Unpacking docker-ce-cli (5:20.10.9~3-0~raspbian-buster) ...", "Selecting previously unselected package docker-ce.", "Preparing to unpack .../2-docker-ce_5%3a20.10.9~3-0~raspbian-buster_armhf.deb ...", "Unpacking docker-ce (5:20.10.9~3-0~raspbian-buster) ...", "Selecting previously unselected package python-pip-whl.", "Preparing to unpack .../3-python-pip-whl_18.1-5+rpt1_all.deb ...", "Unpacking python-pip-whl (18.1-5+rpt1) ...", "Selecting previously unselected package python3-lib2to3.", "Preparing to unpack .../4-python3-lib2to3_3.7.3-1_all.deb ...", "Unpacking python3-lib2to3 (3.7.3-1) ...", "Selecting previously unselected package python3-distutils.", "Preparing to unpack .../5-python3-distutils_3.7.3-1_all.deb ...", "Unpacking python3-distutils (3.7.3-1) ...", "Selecting previously unselected package python3-pip.", "Preparing to unpack .../6-python3-pip_18.1-5+rpt1_all.deb ...", "Unpacking python3-pip (18.1-5+rpt1) ...", "Selecting previously unselected package python3-setuptools.", "Preparing to unpack .../7-python3-setuptools_40.8.0-1_all.deb ...", "Unpacking python3-setuptools (40.8.0-1) ...", "Setting up containerd.io (1.4.11-1) ...", "Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service -> /lib/systemd/system/containerd.service.", "Setting up docker-ce-cli (5:20.10.9~3-0~raspbian-buster) ...", "Setting up python-pip-whl (18.1-5+rpt1) ...", "Setting up python3-lib2to3 (3.7.3-1) ...", "Setting up python3-distutils (3.7.3-1) ...", "Setting up python3-setuptools (40.8.0-1) ...", "Setting up docker-ce (5:20.10.9~3-0~raspbian-buster) ...", "Created symlink /etc/systemd/system/multi-user.target.wants/docker.service -> /lib/systemd/system/docker.service.", "Created symlink /etc/systemd/system/sockets.target.wants/docker.socket -> /lib/systemd/system/docker.socket.", "Job for docker.service failed because the control process exited with error code.", "See \"systemctl status docker.service\" and \"journalctl -xe\" for details.", "invoke-rc.d: initscript docker, action \"start\" failed.", "* docker.service - Docker Application Container Engine", " Loaded: loaded (\u001b]8;;file://pihole-1/lib/systemd/system/docker.service\u0007/lib/systemd/system/docker.service\u001b]8;;\u0007; enabled; vendor preset: enabled)", " Active: activating (auto-restart) (Result: exit-code) since Wed 2021-10-06 00:43:32 CEST; 141ms ago", " Docs: \u001b]8;;https://docs.docker.com\u0007https://docs.docker.com\u001b]8;;\u0007", " Process: 10471 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock \u001b[0;1;31m(code=exited, status=1/FAILURE)\u001b[0m", " Main PID: 10471 (code=exited, status=1/FAILURE)", "", "Oct 06 00:43:31 pihole-1 systemd[1]: \u001b[0;1;31m\u001b[0;1;39m\u001b[0;1;31mFailed to start Docker Application Container Engine.\u001b[0m", "dpkg: error processing package docker-ce (--configure):", " installed docker-ce package post-installation script subprocess returned error exit status 1", "Setting up python3-pip (18.1-5+rpt1) ...", "Processing triggers for man-db (2.8.5-2) ...", "Processing triggers for systemd (241-7~deb10u8+rpi1) ...", "Errors were encountered while processing:", " docker-ce"]}

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.