geerlingguy / internet-pi

Raspberry Pi config for all things Internet.
MIT License
4.34k stars 451 forks source link

Can't run 'ansible-playbook main.yml' on Pi itself #20

Closed clumsyzombie closed 3 years ago

clumsyzombie commented 3 years ago

I have done everything else I am

pi@monitor-pihole:~/internet-monitoring $ ansible --version
ansible 2.9.23

but every time I go to run the play book I get the below issues.

First time I tried:

pi@monitor-pihole:~/internet-monitoring $ ansible-playbook main.yml                            

PLAY [internet_pi] ****************************************************************************************************************************************

TASK [Gathering Facts] ************************************************************************************************************************************
The authenticity of host '192.168.2.100 (192.168.2.100)' can't be established.
ECDSA key fingerprint is SHA256:T6yUqbdRb9Q6DYv7vDeH6zMc0M2qU06r8XadjvpuIzU.
Are you sure you want to continue connecting (yes/no)? yes
fatal: [192.168.2.100]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Warning: Permanently added '192.168.2.100' (ECDSA) to the list of known hosts.\r\npi@192.168.2.100: Permission denied (publickey,password).", "unreachable": true}

PLAY RECAP ************************************************************************************************************************************************
192.168.2.100              : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0   

pi@monitor-pihole:~/internet-monitoring $ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.100  netmask 255.255.255.0  broadcast 192.168.2.255`

2nd time I have tried to run it I got the below
`pi@monitor-pihole:~/internet-monitoring $ ansible-playbook main.yml                            

PLAY [internet_pi] ****************************************************************************************************************************************

TASK [Gathering Facts] ************************************************************************************************************************************
fatal: [192.168.2.100]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: pi@192.168.2.100: Permission denied (publickey,password).", "unreachable": true}

PLAY RECAP ************************************************************************************************************************************************
192.168.2.100              : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0 `  
geerlingguy commented 3 years ago

Are you trying to run the playbook on the Pi itself? If so there are a couple things you need to do slightly differently (and I can guide you through them... maybe get that added to the README too!)

Otherwise, make sure you can SSH into the Pi (ssh pi@192.168.2.100) if you're running from another computer.

clumsyzombie commented 3 years ago

Correct I am ssh in tot he pi right now and I downloaded all the file from your repository to my PI I just built. pi@monitor-pihole:~/internet-monitoring $ ls -la total 68 drwxr-xr-x 6 pi pi 4096 Jun 23 17:55 . drwxr-xr-x 8 pi pi 4096 Jun 23 18:01 .. -rw-r--r-- 1 pi pi 86 Jun 23 17:18 ansible.cfg -rw-r--r-- 1 pi pi 487 Jun 23 17:55 config.yml -rw-r--r-- 1 pi pi 504 Jun 23 17:18 example.config.yml -rw-r--r-- 1 pi pi 159 Jun 23 17:18 example.inventory.ini drwxr-xr-x 3 pi pi 4096 Jun 23 17:47 .github -rw-r--r-- 1 pi pi 25 Jun 23 17:18 .gitignore drwxr-xr-x 2 pi pi 4096 Jun 23 17:47 images -rw-r--r-- 1 pi pi 161 Jun 23 17:51 inventory.ini -rw-r--r-- 1 pi pi 1080 Jun 23 17:18 LICENSE -rw-r--r-- 1 pi pi 855 Jun 23 17:18 main.yml -rw-r--r-- 1 pi pi 2875 Jun 23 17:18 README.md -rw-r--r-- 1 pi pi 38 Jun 23 17:18 requirements.yml drwxr-xr-x 2 pi pi 4096 Jun 23 17:52 tasks drwxr-xr-x 2 pi pi 4096 Jun 23 17:47 templates -rw-r--r-- 1 pi pi 107 Jun 23 17:18 .yamllint

I have a Pi that I was just using for PiHole so I decided I would do your play book to just run it all on the Pi4 I have with 8 Gb ram So this pi use to do just pihole but I wipped it and said he I will just have it handing off my router and run your setup so I can just have it all in one place on the pi itself.

clumsyzombie commented 3 years ago

image

geerlingguy commented 3 years ago

Okay, so in this case, what you'd want to do is the following:

  1. In inventory.ini, change the line under [internet_pi] to read: localhost ansible_connection=local
  2. Try running main.yml again.

Hopefully that will work!

clumsyzombie commented 3 years ago

I am getting this right now. image

geerlingguy commented 3 years ago

@clumsyzombie - Before running the playbook, try deleting the directory: rm -rf /home/pi/internet-monitoring. Looks like it may have been cloned already?

clumsyzombie commented 3 years ago

So I did that and I am not able to access any web service's still on the pi after running it so I am not sure anything been copied over yet if I am getting errors. So by deleting that I am not able to issue ansible-playbook main.yml because that is in the same directory as everything so when you issue ansible-playbook main.yml does it copy everything to another place? Could it be that something is not copy over.

clumsyzombie commented 3 years ago

So I did resolve one error the error above was unable to resolve so I got DNS working now and I can resolve google.com and github.com now So I am getting this error now image

geerlingguy commented 3 years ago

@clumsyzombie - It looks like there are still DNS issues there; because Docker is trying to do a docker pull on the image but is not able to see the registry. It seems like it's trying to query DNS on the Pi itself, but check out https://github.com/geerlingguy/internet-pi/issues/8 as well.

clumsyzombie commented 3 years ago

@geerlingguy You might have a laugh about this I went into /etc/resolvconf.conf it already was not committed so I said what the heck let me commit it out. Everything ran because I have DNS setup already on the pie else where. I did that and it fully installed.

Now I am in Grafana and looking around and pihole is up and running I need to config it but I can access each.

geerlingguy commented 3 years ago

Excellent!

Nunya-9018 commented 3 years ago

im having the same issue what do i do

Nunya-9018 commented 3 years ago

nvm i figured it out

clumsyzombie commented 3 years ago

@geerlingguy

image

geerlingguy commented 3 years ago

@clumsyzombie - Beautiful! For the Speedtest Graph it will still take some time before it shows a more stable graph over a long period (and looks nicest at 6 hours or more zoomed out).

geerlingguy commented 3 years ago

It looks like the main issue's been resolved at this point; the other issue that can happen on first run is https://github.com/geerlingguy/internet-pi/issues/22 — so moving the rest of this discussion there.

netbob commented 3 years ago

I am getting this error when I run “ansible-playbook main.yml: pi@RPi4-PLEX:~/internet-pi $ ansible-playbook main.yml ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

The error appears to have been in '/home/pi/internet-pi/main.yml': line 15, column 7, but may be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

handlers:

Ive ssh’ed into my pi4 and everything seems good setup wise. The inventory.ini file contains the following: [internet_pi]

192.168.1.3 ansible_user=pi

Comment out the previous line and uncomment this to run inside Raspberry Pi.

127.0.0.1 ansible_connection=local ansible_user=pi

Nothing in main.yml seems to indicate a path. Thanks in advance, Nb

geerlingguy commented 3 years ago

@netbob - Please make sure you're running Ansible 2.9 or later (ansible --version to check).

netbob commented 3 years ago

@netbob - Please make sure you're running Ansible 2.9 or later (ansible --version to check).

Thanks! That worked so all runs well until it hits this portion: TASK [Ensure {{ ansible_user }} user is added to the docker group.] ****fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'ansible_user' is undefined\n\nThe error appears to be in '/home/pi/internet-pi/tasks/docker.yml': line 44, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Ensure {{ ansible_user }} user is added to the docker group.\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with_items:\n - {{ foo }}\n\nShould be written as:\n\n with_items:\n - \"{{ foo }}\"\n"}

PLAY RECAP *****localhost : ok=7 changed=2 unreachable=0 failed=1 skipped=2 rescued=0 ignored=0

pi@RPi4-PLEX:~/internet-pi $

geerlingguy commented 3 years ago

@netbob - Make sure your inventory file has the whole contents of the line that was fixed a few days back: https://github.com/geerlingguy/internet-pi/blob/master/example.inventory.ini#L5 (including the ansible_user=pi part).

netbob commented 3 years ago

@netbob - Make sure your inventory file has the whole contents of the line that was fixed a few days back: https://github.com/geerlingguy/internet-pi/blob/master/example.inventory.ini#L5 (including the ansible_user=pi part).

Adding the ansible_user=pi line worked for me. It works great, thanks for the assist Jeff.

PhucNguyen04 commented 1 year ago

@geerlingguyBạn có thể cười về điều này. Tôi đã vào /etc/resolvconf.conf nó chưa được cam kết nên tôi đã nói cái quái gì vậy, hãy để tôi cam kết nó. Mọi thứ đều chạy vì tôi đã thiết lập DNS ở chỗ khác. Tôi đã làm điều đó và nó đã được cài đặt đầy đủ.

Bây giờ tôi đang ở Grafana và nhìn xung quanh và thấy pihole đang hoạt động. Tôi cần định cấu hình nó nhưng tôi có thể truy cập từng cái.

Where did you go to /etc/resolvconf.conf file? image

danindiana commented 10 months ago
  1. localhost ansible_connection=local

It would save many persons time I imagine to add this point of note to the readme of the git.