spurin / diveintoansible-lab

Dive Into Ansible Lab
850 stars 531 forks source link

Cannot login into the ubuntu-c when run on a Docker-Desktop on windows 10. #44

Closed SurajNikam1994 closed 3 years ago

SurajNikam1994 commented 3 years ago

Hi,

I have installed Docker Desktop on Windows 10. When I run the "docker compose up" command, the containers start as usual, I am able to launch the portal at http://localhost:1000/ However when I try to login to ubuntu-c, it says that the credentials are incorrect. I am using user as "ansible" and password as "password".

My Docker desktop is running on wsl2. When I launch WSL it drops me in to an Ubuntu shell. Below are the steps that I performed.

  1. Clone the repo at /mnt/c/Users/Administrator/
  2. drop into the folder diveintoansible-lab/ and make a new directory "/mnt/c/Users/Administrator/diveintoansible-lab/ansible_home"
  3. edit the .env file as shown below.

    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/Administrator/diveintoansible-lab/config

Shared home directories

ANSIBLE_HOME=/mnt/c/Users/Administrator/diveintoansible-lab/ansible_home

  1. Open an elevated PowerShell session and drop into the folder "C:\Users\Administrator\diveintoansible-lab"
  2. Run "docker compose up"
  3. Once the containers are up and running, I launch http://localhost:1000 but the login always fails. <# ubuntu-c login: ansible Password:

Login incorrect ubuntu-c login:

>

I have also tried the same procedure without creating ansible_home folder but it yields same failures.

Please assist.

spurin commented 3 years ago

Hi @SurajNikam1994

We'll get this worked out. Firstly, are you running as the Administrator user or as another account?

For the entries in .env, could you put it as lowercase for both CONFIG and ANSIBLE_HOME and retry

SurajNikam1994 commented 3 years ago

Hi @spurin

Thanks for quick response.

I am running as Administrator user.

I have tried all the below combinations:

Shared config volume

CONFIG=/mnt/c/Users/administrator/diveintoansible-lab/config

Shared home directories

ANSIBLE_HOME=/mnt/c/Users/administrator/diveintoansible-lab/ansible_home


Shared config volume

CONFIG=/mnt/c/users/administrator/diveintoansible-lab/config

Shared home directories

ANSIBLE_HOME=/mnt/c/users/administrator/diveintoansible-lab/ansible_home


Shared config volume

CONFIG=/mnt/c/users/Administrator/diveintoansible-lab/config

Shared home directories

ANSIBLE_HOME=/mnt/c/users/Administrator/diveintoansible-lab/ansible_home


None of them worked.

When I dropped into the container ubuntu-c with docker exec, and checked the passwd, I did not find any user reference for ansible.

cloud-66 commented 3 years ago

I have the same problem. 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/james/diveintoansible-lab/config
CONFIG=/mnt/c/users/cloud/diveintoansible-lab/config

# Shared home directories
#ANSIBLE_HOME=/Users/james/diveintoansible-lab/ansible_home
ANSIBLE_HOME=/mnt/c/users/cloud/diveintoansible-lab/ansible_home

I'm running from docker desktop on Windows 10

изображение

изображение

spurin commented 3 years ago

Hi @cloud-66,

Can you please try running the following - when it displays ansible in the output, the entry after -v should be the format that you need to use in your .env file for both config and ansible_home -

docker run --rm -v /host_mnt/c/users/cloud/diveintoansible-lab/config:/config ubuntu cat /config/guest_name
docker run --rm -v /mnt/c/users/cloud/diveintoansible-lab/config:/config ubuntu cat /config/guest_name
docker run --rm -v /c/users/cloud/diveintoansible-lab/config:/config ubuntu cat /config/guest_name

Best Regards

James

Triton6 commented 3 years ago

Hi, I have installed docker on Amazon AMI ec2-instance and have got everything set up, I am able to access the lab console, post that when I try to log into the Ansible control host it is not happening, I get "localhost refused to connect." I have followed all the steps you had mentioned. I have also opened ports 1000, 7681 in my Sg Help me out. Thanks

spurin commented 3 years ago

Hi @Triton6

You’ll need to do an additional step as your server is remote. Edit your docker-compose.yaml and in the portal section, add the following as an environment variable -

- LOCALHOST_OVERRIDE=1.2.3.4

Replacing the IP address with that of your ec2 instance. Then, do a ctrl-c on the running lab and start it.

When it starts, all the links in the portal will be updated with your ip accordingly, rather than localhost.

In your port group, as long as you’ve got the other ip addresses (from the .env file) then you should be good to go 👍

Triton6 commented 3 years ago

Hello., I added the “ LOCALHOST_OVERRIDE=” as environment variable in the docker-compose.yam file.

Post that I could access the Ubuntu-C log in console, but when I enter the username and password, it is not letting me login. It gives me “Login Incorrect” error message. The password and the username that I am entering is same as given in the config file I.e., guest_user : ansible, and guest_password : password All the ports given in .env is opened too

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10

From: James @.> Sent: 17 July 2021 14:02 To: @.> Cc: @.>; @.> Subject: Re: [spurin/diveintoansible-lab] Cannot login into the ubuntu-c when run on a Docker-Desktop on windows 10. (#44)

Hi @Triton6https://github.com/Triton6

You’ll need to do an additional step as your server is remote. Edit your docker-compose.yaml and in the portal section, add the following as an environment variable -

Replacing the IP address with your own. Then, do a ctrl-c on the running lab and start it.

When it starts, all the links in the portal will be updated with your ip accordingly, rather than localhost.

In your port group, as long as you’ve got the other ip addresses (from the .env file) then you should be good to go 👍

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/spurin/diveintoansible-lab/issues/44#issuecomment-881857287, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AURGSGJHRCCNKM27H2RI5ELTYE525ANCNFSM47TGOLYA.

spurin commented 3 years ago

Hi @Triton6

Please share the contents of your .env file and I’ll advise from there 👍

Triton6 commented 3 years ago

Issue got fixed , Thanks for responding

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10

From: James @.> Sent: 17 July 2021 17:12 To: @.> Cc: @.>; @.> Subject: Re: [spurin/diveintoansible-lab] Cannot login into the ubuntu-c when run on a Docker-Desktop on windows 10. (#44)

Hi @Triton6https://github.com/Triton6

Please share the contents of your .env file and I’ll advise from there 👍

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/spurin/diveintoansible-lab/issues/44#issuecomment-881884980, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AURGSGLXNZHEV6WDEXOIGJTTYFUCNANCNFSM47TGOLYA.

anils0087 commented 3 years ago

Hi @spurin

I am running on windows10 and having the same error.

Shared config volume

CONFIG=\mnt\c\Users\shrav\diveintoansible-lab\config

Shared home directories

ANSIBLE_HOME=\mnt\c\Users\shrav\diveintoansible-lab\ansible_home

Tried on all possible ways and facing issues during login.

Can you please advise

Thanks Anil

spurin commented 3 years ago

Hi @anils0087

Can you please try the paths -

CONFIG=/host_mnt/c/users/shrav/diveintoansible-lab/config

ANSIBLE_HOME=/host_mnt/c/users/shrav/diveintoansible-lab/ansible_home

anils0087 commented 3 years ago

it did nt work

Shared config volume

CONFIG=/host_mnt/c/users/shrav/diveintoansible-lab/config

Shared home directories

ANSIBLE_HOME=/host_mnt/c/users/shrav/diveintoansible-lab/ansible_home

got the same logging error

spurin commented 3 years ago

Hi @anils0087

What was the logging error? Can you please share it. Also please share the output from the following 3 commands -

docker run --rm -v /host_mnt/c/users/shrav/diveintoansible-lab/config:/config ubuntu cat /config/guest_name

docker run --rm -v /mnt/c/users/shrav/diveintoansible-lab/config:/config ubuntu cat /config/guest_name

docker run --rm -v /c/users/shrav/diveintoansible-lab/config:/config ubuntu cat /config/guest_name

anils0087 commented 3 years ago

ubuntu-c login: ansible Password:

Login incorrect ubuntu-c login: ansible Password:

Login incorrect ubuntu-c login: ansible Password:

C:\Users\shrav\diveintoansible-lab>docker run --rm -v /host_mnt/c/users/shrav/diveintoansible-lab/config:/config ubuntu cat /config/guest_name ansible

C:\Users\shrav\diveintoansible-lab>docker run --rm -v /mnt/c/users/shrav/diveintoansible-lab/config:/config ubuntu cat /config/guest_name

C:\Users\shrav\diveintoansible-lab>docker run --rm -v /c/users/shrav/diveintoansible-lab/config:/config ubuntu cat /config/guest_name ansible

Shared config volume

CONFIG=/host_mnt/c/users/shrav/diveintoansible-lab/config

Shared home directories

ANSIBLE_HOME=/host_mnt/c/users/shrav/diveintoansible-lab/ansible_home cat: /config/guest_name: No such file or directory

Ran everything and it is the same.

spurin commented 3 years ago

The first one worked, it is the correct format as it displayed ansible when you ran the command, therefore please make sure your .env file has -

CONFIG=/host_mnt/c/users/shrav/diveintoansible-lab/config

ANSIBLE_HOME=/host_mnt/c/users/shrav/diveintoansible-lab/ansible_home

Ctrl-c the running lab, then do -

docker-compose rm docker-compose up

anils0087 commented 3 years ago

it worked now, the file i am working on is pointing to other directory "master".

i edited the file under the -lab directory and this time it worked.

Thanks for the quick responses.

spurin commented 3 years ago

Awesome, thanks for confirming @anils0087 and hope you enjoy the course 👍