Cannot login ansible
Closed this issue ยท 43 comments
In my WIN 10 PC, instead of:
http://localhost:1000
I must type:
http://127.0.0.1:1000
Hi @zdimitris,
In your docker-compose.yaml file, make the following edits to add LOCALHOST_OVERRIDE -
portal:
hostname: portal
container_name: portal
image: spurin/diveintoansible:portal
environment:
- NGINX_ENTRYPOINT_QUIET_LOGS=1
- LOCALHOST_OVERRIDE=127.0.0.1
depends_on:
- centos1
- centos2
- centos3
- ubuntu1
- ubuntu2
- ubuntu3
ports:
- "1000:80"
networks:
- diveinto.io
Do a ctrl-c on the running environment and then do a docker-compose up, this will fix your issue ๐
Thanks @spurin
However, I fould a mistake in the configuration and I restarted. But now I have a problem:
Creating ubuntu3 ... done
Creating ubuntu1 ... done
Creating centos2 ... done
Creating ubuntu2 ... done
Creating centos1 ... done
Creating ubuntu-c ... done
Creating centos3 ... done
Creating docker ... done
Creating portal ... done
Attaching to ubuntu3, ubuntu1, centos2, docker, centos3, ubuntu2, centos1, ubuntu-c, portal
ubuntu-c exited with code 255
ubuntu1 exited with code 255
ubuntu2 exited with code 255
ubuntu3 exited with code 255
portal | 2021/03/09 16:43:01 [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
My .env is as follows:
# sshd ports
UBUNTUC_PORT_SSHD=2221
UBUNTU1_PORT_SSHD=2222
UBUNTU2_PORT_SSHD=2223
UBUNTU3_PORT_SSHD=2224
CENTOS1_PORT_SSHD=2225
CENTOS2_PORT_SSHD=2226
CENTOS3_PORT_SSHD=2227
# ttyd (web terminal) ports
UBUNTUC_PORT_TTYD=7681
UBUNTU1_PORT_TTYD=7682
UBUNTU2_PORT_TTYD=7683
UBUNTU3_PORT_TTYD=7684
CENTOS1_PORT_TTYD=7685
CENTOS2_PORT_TTYD=7686
CENTOS3_PORT_TTYD=7687
# Shared config volume
CONFIG=/mnt/c/Users/dimit/diveintoansible-lab/config/
# Shared home directories
ANSIBLE_HOME=/mnt/c/Users/dimit/diveintoansible-lab/ansible_home
I am having a login issue as well. My system is WSL Ubuntu does this make a difference? The container starts up fine and I can get to the webpage fine its just logging in with ansible/password. I double checked the files in the config folder too.
# sshd ports
UBUNTUC_PORT_SSHD=2221
UBUNTU1_PORT_SSHD=2222
UBUNTU2_PORT_SSHD=2223
UBUNTU3_PORT_SSHD=2224
CENTOS1_PORT_SSHD=2225
CENTOS2_PORT_SSHD=2226
CENTOS3_PORT_SSHD=2227
# ttyd (web terminal) ports
UBUNTUC_PORT_TTYD=7681
UBUNTU1_PORT_TTYD=7682
UBUNTU2_PORT_TTYD=7683
UBUNTU3_PORT_TTYD=7684
CENTOS1_PORT_TTYD=7685
CENTOS2_PORT_TTYD=7686
CENTOS3_PORT_TTYD=7687
# Shared config volume
CONFIG=/home/headinga/diveintoansible-lab/config
# Shared home directories
ANSIBLE_HOME=/home/headinga/diveintoansible-lab/ansible_home
I solved my issue and maybe there is an easier way to do it.
First mount the c drive to WSL Ubuntu: sudo mount --bind /mnt/c /c
Then update the .env file to point to the WSL file directory through the windows file system.
# Shared config volume
CONFIG=/c/Users/headinga/AppData/Local/Packages/CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc/LocalState/rootfs/home/headinga/diveintoansible-lab/config
# Shared home directories
ANSIBLE_HOME=/c/Users/headinga/AppData/Local/Packages/CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc/LocalState/rootfs/home/headinga/diveintoansible-lab/ansible_home
Hi @druw900
First of all, I agree with you regarding the mapping between WIN/UBUNTU.
However, I followed another path and I run the command:
docker-compose up
from git bash (windows 10 with WSL 2).
However, I cannot log in to Ubuntu-C (http://127.0.0.1:7681/) with ansible:password
Hi @druw900
First of all, I agree with you regarding the mapping between WIN/UBUNTU.However, I followed another path and I run the command:
docker-compose up
from git bash (windows 10 with WSL 2).
However, I cannot log in to Ubuntu-C (http://127.0.0.1:7681/) with ansible:password
Did you mount your C drive? Personally I have to do it every time I open WSL Ubuntu.
How did you find the drive
CONFIG=/c/Users/headinga/AppData/Local/Packages/CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc/LocalState/rootfs/home/headinga/diveintoansible-lab/config
I cannot go further than the .../Canonical... I cannot reach .../LocalState/...
How did you find the drive
CONFIG=/c/Users/headinga/AppData/Local/Packages/CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc/LocalState/rootfs/home/headinga/diveintoansible-lab/configI cannot go further than the .../Canonical... I cannot reach .../LocalState/...
Your directories may be different. In explorer go to ../Packages and start browsing from there until you find your WSL filesystem.
Hi @druw900
I have always mounted the C drive to my WSL 2 Ubuntu 20.04
I found the correct mounting point and I changed the paths to:
# Shared config volume
CONFIG=/mnt/c/Users/dimit/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/home/dimitris/diveintoansible-lab/config
# Shared home directories
ANSIBLE_HOME=/mnt/c/Users/dimit/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/home/dimitris/diveintoansible-lab/ansible_home
But I'm getting again an error as follows:
/mnt/c/Users/dimit/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/home/dimitris/diveintoansible-lab$ docker-compose up
Creating centos3 ... done
Creating ubuntu1 ... done
Creating ubuntu2 ... done
Creating docker ... done
Creating centos2 ... done
Creating ubuntu3 ... done
Creating ubuntu-c ... done
Creating centos1 ... done
Creating portal ... done
Attaching to centos3, docker, ubuntu2, ubuntu1, centos1, centos2, ubuntu3, ubuntu-c, portal
ubuntu-c exited with code 255
ubuntu1 exited with code 255
ubuntu2 exited with code 255
ubuntu3 exited with code 255
portal | 2021/03/09 21:11:01 [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
Hi @zdimitris
This is a very interesting one as I've personally, never seen the mount path as long as this! You seem very knowledgable about WSL so would you mind sharing with me as much information as possible about your setup? Windows version (with patch) and anything else which could be of use.
From the output, the portal is a red herring here as it's the containers that are crashing which in turn, then causes the portal to fail.
For the next steps for troubleshooting, I think we'll need to run the containers outside of docker compose but let's get the system info first so we can avoid any other known gotchas.
Thanks
James Spurin
@zdimitris
I had the same error using docker in WSL2. Running the following got the docker-compose working.
sudo mkdir /sys/fs/cgroup/systemd
sudo mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd
Thanks, @spurin and @delta9000, for your replies.
@delta9000 I will check the solution you propose at the weekend. Unfortunately, I have a high workload now, so I cannot do it right away.
@spurin, I will collect the information I have for WSL 2 and let you know, but again in the WE. As a workaround, I used AWS to try my playbooks. But, I want to install a fully functional local deployment for understanding in-depth your solution. It interests me very much. It's very resourceful -congratulations.
Hi @zdimitris,
Just checking in. Hows it all going? Anything I can help with regarding the issue?
@spurin I am using WSL2 as well. I had the same problem for Ubuntu pods. Centos work just fine.
Soluton provided by @delta9000 works pretty well, the only problem is you need to run those commands everytime you want to turn the containers on again. I am still tetsing ans see if there is a more permanent solution, but so far it is what it is.
@Jgerardopine add cgroup /sys/fs/cgroup/systemd cgroup none,name=systemd,X-mount.mkdir
to your /etc/fstab
and it should automount on wsl "boot"
Run wsl.exe --shutdown
from an elevated cmd or powershell prompt to restart wsl2 to verify the mount works.
@spurin After reading all the comments here and trying all suggestions, I was able to reach the lab interface successfully but was unable to log in with ansible:password.
Below is my .env
file:
# sshd ports
UBUNTUC_PORT_SSHD=2221
UBUNTU1_PORT_SSHD=2222
UBUNTU2_PORT_SSHD=2223
UBUNTU3_PORT_SSHD=2224
CENTOS1_PORT_SSHD=2225
CENTOS2_PORT_SSHD=2226
CENTOS3_PORT_SSHD=2227
# ttyd (web terminal) ports
UBUNTUC_PORT_TTYD=7681
UBUNTU1_PORT_TTYD=7682
UBUNTU2_PORT_TTYD=7683
UBUNTU3_PORT_TTYD=7684
CENTOS1_PORT_TTYD=7685
CENTOS2_PORT_TTYD=7686
CENTOS3_PORT_TTYD=7687
# Shared config volume
CONFIG=/Users/ubuntu/diveintoansible-lab/config
# Shared home directories
ANSIBLE_HOME=/Users/ubuntu/diveintoansible-lab/ansible_home
@spurin I'm running ubuntu 20.04 on top of WSL2
Hi @olivetech101
Youโll need to use the format in the readme of /host_mnt/c/users
Could you give this a try, if youโre still having problems open a new issue and Iโll work through fully with you ๐
@spurin Thanks for the swift reply, will try this over the weekend and update it here. Thanks again.
I installed this lab on aws ec2 ubuntu but I am not able to connect to the ubuntu c or any other one from the home page
You'll need to open up a security group to your IP address. Then, edit the docker-compose.yaml file and in the portal section, add the following to the environment section:
- LOCALHOST_OVERRIDE=1.2.3.4
Replacing the ip with that of your virtual machine. Restart the lab and then you're good ๐
As an alternative, if you wanted to do this in the cloud at no cost, and without having to edit anything, have a look at the new gcp cloudshell setup. You only need a Google account and it's a one click launch -
https://github.com/spurin/diveintoansible-lab-gcp-cloudshell
@spurin, I have unsuccessfully login in ubuntu-c.
I have tried many ways to change my configuration:
CONFIG=/mnt/c/users//diveintoansible-lab/config <- containers are launched and website runs Ok, but no login possible
ANSIBLE_HOME=/mnt/c/users//diveintoansible-lab/ansible_home
CONFIG=/host_mnt/c/users//diveintoansible-lab/config <- website does not launch, receive an error
ANSIBLE_HOME=/host_mnt/c/users/isanchez/diveintoansible-lab/ansible_home <- website does not launch, receive an error
I tried ansible/password, ansible/Password and ansible/ansible, none of these have worked.
Hi @soldetres
Sorry to hear you're having difficulties. Can you please try the following and let me know how you get on -
ANSIBLE_HOME=./ansible_home
CONFIG=./config
Hi I am facing below error on a MAC Book, any workaround for the same ?
Attaching to centos1, centos2, centos3, docker, portal, ubuntu-c, ubuntu1, ubuntu2, ubuntu3
ubuntu3 exited with code 255
ubuntu-c exited with code 255
ubuntu2 exited with code 255
ubuntu1 exited with code 255
portal | 2021/12/13 14:17:06 [emerg] 1#1: host not found in upstream "ubuntu1" in /etc/nginx/conf.d/default.conf:45
portal | nginx: [emerg] host not found in upstream "ubuntu1" in /etc/nginx/conf.d/default.conf:45
portal exited with code 1
Hi @soldetres
Sorry to hear you're having difficulties. Can you please try the following and let me know how you get on -
ANSIBLE_HOME=./ansible_home CONFIG=./config
The solution worked for me. @spurin I propose you update the README.md and course instructions for Windows, so that it becomes clear that if you are running the lab in Docker Desktop on Windows, then you must configure ANSIBLE_HOME and CONFIG as stated above.
Hi @PerFoldager
Thanks for your message and sorry to hear you've had problems. The .env config is by default, as it's mentioned in this comment since the last update and I've also commented that this should only be changed, if problems are experienced.
I'm not sure how you've had this issue?
Would be great to know so I can avoid it for others going forward.
Thanks
James
I run into this same issue and tried almost everything I could find from google search but nothing worked. (searched for two days)
This is the only thing that worked, found it here : docker/for-win#9972 (comment)
- Right click the docker icon in the bottom right of the taskbar (it might be in the hidden icons tray)
- Click troubleshoot
- Clean/Purge Data
- Select all 3 and click delete
Restart docker
Hi @samapraku
Appreciate the context shared. What exactly was the issue you were seeing?
This thread seems to have a lot of troubleshooting from different issues so it's unclear as to what the problem was.
Thanks
@spurin I was getting this same issue #17 (comment)
the ubuntu containers and portal could not start
Thanks @samapraku
Had the lab previously worked for you or was this the first time encountering the issue?
It used to work for me. Unfortunately I don't remember when and what caused it to stop working
Thanks @samapraku
This helps. In this scenario, the most probable explanation I can think of is the Docker update.
Recently, Docker changed their base Linux image from one that uses cgroups v1 to v2 which causes the problems being seen.
Where you flushed the images with the approach you mentioned, I think that you've forced a pull of the new images (which work with cgroups v2).
Should you encounter this again, or if you want to ensure you're running the latest, you can do the following -
-
Remove any running containers, this can either be done in the Docker console or by doing a docker-compose rm, in the diveintoansible-lab
-
Download the latest version of the lab or, specifically copy the latest docker-compose.yaml and .env (which now, no longer needs to be updated with paths etc and supports both cgroups v1 and v2)
-
Run a docker-compose pull (to force pull the latest images)
And then, when you start the lab it should be good! ๐
Can you explain in detail how you got access?
Hi @bgrakmn
Need some more context on your question?
If it's a case of just logging in, the username and passwords are
ansible/password
And
root/password
If it's not this, please provide more information ๐
@spurin Hi, I've got a login problem as well. I tried the command docker-compose rm, changed the .env file according to my OS in the README file, then docker-compose up but I still have the same problem. Any ideas?
Thank you.
Hi, you should no longer need to edit the .env file, can you try reverting it to the default, doing a docker compose down, remove ansible_home and then do a docker compose up
No, still the same I can't log in. The default .env is like below right?
Shared config volume
CONFIG=./config
Shared home directories
ANSIBLE_HOME=./ansible_home
@spurin Problem solved!