spurin / diveintoansible-lab

Dive Into Ansible Lab
850 stars 531 forks source link

WSL2 #54

Closed WindsOfHades closed 3 years ago

WindsOfHades commented 3 years ago

I did not manage to set the portal up on WSL2. It worked on my windows machine though. Do you happen to know what is the issue?

Starting centos1  ... done
Starting docker   ... done
Starting ubuntu3  ... done
Starting ubuntu-c ... done
Starting centos2  ... done
Starting centos3  ... done
Starting ubuntu1  ... done
Starting ubuntu2  ... done
Starting portal   ... done
Attaching to docker, centos1, ubuntu-c, ubuntu3, ubuntu2, centos2, centos3, ubuntu1, portal
ubuntu1 exited with code 255
ubuntu-c exited with code 255
ubuntu3 exited with code 255
ubuntu2 exited with code 255
portal      | 2021/08/22 11:22:50 [emerg] 1#1: host not found in upstream "ubuntu1" in /etc/nginx/conf.d/default.conf:46
portal      | nginx: [emerg] host not found in upstream "ubuntu1" in /etc/nginx/conf.d/default.conf:46
portal exited with code 1
spurin commented 3 years ago

Hi @WindsOfHades

Are you by any chance using the Ubuntu subsystem?

If so, the issue here is owing to this not having systemd. It’s a stripped down version of Ubuntu. The containers, all leverage systemd and when they try to use the parents subsystem, this is missing. We can work around this by just creating the required components that are needed.

Could you run the following, before doing the docker-compose up

sudo mkdir -p /sys/fs/cgroup/systemd

sudo mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd

Then try starting the lab. Please let me know how you get on πŸ‘

WindsOfHades commented 3 years ago

Thanks for the quick reply. It works now on WSL2 (Ubuntu) with the suggested mount command.

P.s. In case you have time, It would be great if you can explain how a lack of systemd in WSL simply resolved by a mount to an empty folder.

spurin commented 3 years ago

Hi @WindsOfHades

I'll be fully transparent on this, I do not know the specifics at a low level in why the systemd container kicks into life with this directory.

Like most of our journeys and troubles, the answer fortunately for this one was found on Google for another systemd container that was having the same problem.

Systemd in a container is kind of a necessary evil here with the course, but is super beneficial. When building the lab I tried different variations without it, and some alternatives that emulate systemd functionality. Nothing though really came close to the systemd experience, especially where you want Ansible to interact with Linux services natively as you'd expect.

The pros to it of course are us being able to have these images, that look 99% like a full OS in the convenience of a container. The negative though, are aspects like these and other bits of compatibility that sometimes arise on other Linux systems (for example, ones that use cgroups v2.

Fortunately (touchwood), so far for all issues that have been raised, there has been a resolution 😁

Wish I could give you more specifics. Really hope you enjoy the course!