bradleyd / devops_for_the_desperate

The companion code for the book DevOps for the Desperate
120 stars 67 forks source link

Issue with running ansible playbook command for setting up qemu on Apple Silicon. #29

Closed jlee7x2 closed 1 year ago

jlee7x2 commented 1 year ago

Hello, I am on an M1 Apple Silicon device and encountered the following error when trying to configure qemu.

Commands: In a separate tab,

qemu-system-aarch64 -cpu cortex-a72 -smp cpus=4,sockets=1,cores=4,threads=1 -machine virt,highmem=off -accel hvf -accel tcg,tb-size=2048 -m 3G -initrd initrd.img-5.10.0-11-arm64 -kernel vmlinuz-5.10.0-11-arm64 -append "root=/dev/vda2 console=ttyAMA0" -drive if=virtio,file=debian-dftd-aarch64.qcow2,format=qcow2,id=hd -net user,hostfwd=tcp::10022-:22,hostfwd=tcp::20375-:2375,hostfwd=tcp::5001-:5000 -net nic -device intel-hda -device hda-duplex -nographic

Then,

ansible-playbook ./ansible/site.yml -i hosts -c paramiko --ask-pass --ask-become-pass -u dftd

which results in the following error:

% ansible-playbook ./ansible/site.yml -i hosts -c paramiko --ask-pass --ask-become-pass -u dftd

SSH password: 
BECOME password[defaults to SSH password]: 

PLAY [dftd] ************************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************
[WARNING]: Platform linux on host 127.0.0.1 is using the discovered Python interpreter at /usr/bin/python3.9, but
future installation of another Python interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible-core/2.15/reference_appendices/interpreter_discovery.html for more information.
ok: [127.0.0.1]

TASK [Install ufw] *****************************************************************************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "Failed to update apt cache: unknown reason"}

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

Any ideas?

jlee7x2 commented 1 year ago

From within the host, I ran sudo apt-get update,

dftd@debian:~$ sudo apt-get update
Hit:1 http://security.debian.org/debian-security bullseye-security InRelease
Hit:2 https://download.docker.com/linux/debian bullseye InRelease              
Err:3 http://debian.gtisc.gatech.edu/debian bullseye InRelease                 
  Could not connect to debian.gtisc.gatech.edu:80 (2610:148:1f10:3::89). - connect (113: No route to host) Could not connect to debian.gtisc.gatech.edu:80 (128.61.240.89), connection timed out
Err:4 http://debian.gtisc.gatech.edu/debian bullseye-updates InRelease
  Unable to connect to debian.gtisc.gatech.edu:http:
Reading package lists... Done
W: Failed to fetch http://debian.gtisc.gatech.edu/debian/dists/bullseye/InRelease  Could not connect to debian.gtisc.gatech.edu:80 (2610:148:1f10:3::89). - connect (113: No route to host) Could not connect to debian.gtisc.gatech.edu:80 (128.61.240.89), connection timed out
W: Failed to fetch http://debian.gtisc.gatech.edu/debian/dists/bullseye-updates/InRelease  Unable to connect to debian.gtisc.gatech.edu:http:
W: Some index files failed to download. They have been ignored, or old ones used instead.
dftd@debian:~$

per this helpful Reddit comment:

TL;DR the mirror (debian.gtisc.gatech.edu) is assumed to be offline/dead (times out) -- try this url instead (if you still need to use gatech) http://www.gtlib.gatech.edu/pub/debian/.

  Cannot initiate the connection to debian.gtisc.gatech.edu:80 (2610:148:1f10:3::89). - connect (101: Network is unreachable) Could not connect to debian.gtisc.gatech.edu:80 (128.61.240.89), connection timed out
According to Debian mirror report for debian.gtisc.gatech.edu seems to be having technical issues (it just reports: timeout)

https://mirror-master.debian.org/status/mirror-info/debian.gtisc.gatech.edu.html

Either use deb.debian.org or replace it with a different explicit mirror (or use the new gatech url posted above).

Not sure if this is relevant/helps.

bradleyd commented 1 year ago

Hey @jlee7x2 , thanks for supporting me and the book!

The debian mirror should work fine. Can you get to that link on your host machine? Your VM may not have access to the internet. From within the VM, can you ping google.com

ping google.com

If that says no route to host or something like it, than lets look at your default gateway.

ip route

Post back those results and I am sure we can figure out what is going on.

For good measure add

ip addr

Thanks

jlee7x2 commented 1 year ago

Hey @bradleyd, thanks for responding! Just set this up again from scratch and ran into the same issue. Indeed ping google.com failed with 100% packet loss within dftd@debian:

dftd@debian:~$ ip route
default via 10.0.2.2 dev enp0s1 
10.0.2.0/24 dev enp0s1 proto kernel scope link src 10.0.2.15 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 
dftd@debian:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s1
       valid_lft 85523sec preferred_lft 85523sec
    inet6 fec0::5054:ff:fe12:3456/64 scope site dynamic mngtmpaddr 
       valid_lft 86072sec preferred_lft 14072sec
    inet6 fe80::5054:ff:fe12:3456/64 scope link 
       valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:ea:6c:1b:a8 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
bradleyd commented 1 year ago

I am not sure what has changed tbh. Try changing the netdev line.

qemu-system-aarch64 -cpu cortex-a72 -smp cpus=4,sockets=1,cores=4,threads=1 -machine virt,highmem=off -accel hvf -accel tcg,tb-size=2048 -m 3G -initrd initrd.img-5.10.0-11-arm64 -kernel vmlinuz-5.10.0-11-arm64 -append "root=/dev/vda2 console=ttyAMA0" -drive if=virtio,file=debian-dftd-aarch64.qcow2,format=qcow2,id=hd -device e1000,mac=9E:1D:5A:C6:7F:35,netdev=net0 -netdev user,id=net0,hostfwd=tcp::10022-:22,hostfwd=tcp::20375-:2375,hostfwd=tcp::5001-:5000 -device intel-hda -device hda-duplex -nographic

You may have to adjust the mac address accordingly.

If you are still having issues with gatech mirror, edit /etc/apt/sources.list in vim

once in the editor, type shift + colon

then type this search and replace: %s/debian\.gtisc\.gatech\.edu/ftp\.us\.debian\.org/g press enter

then type shift + colon x then return

try running apt update again and see what happens.

Please let me know if this works and I will update the image and instructions.

Thanks

bradleyd commented 1 year ago

Going to close this, please reopen if you need more help.

admincatblue commented 4 months ago

Just wanted to note for anyone else that may come across this- I had the same issue as initially described, but was able to fix by changing the following lines in the /etc/apt/sources.list file on the VM:

Original lines:

deb http://debian.gtisc.gatech.edu/debian/ bullseye main
deb-src http://debian.gtisc.gatech.edu/debian/ bullseye main

deb http://debian.gtisc.gatech.edu/debian/ bullseye-updates main
deb-src http://debian.gtisc.gatech.edu/debian/ bullseye-updates main

Updated lines:

deb http://www.gtlib.gatech.edu/pub/debian/ bullseye main
deb-src http://www.gtlib.gatech.edu/pub/debian/ bullseye main

deb http://www.gtlib.gatech.edu/pub/debian/ bullseye-updates main
deb-src http://www.gtlib.gatech.edu/pub/debian/ bullseye-updates main