Comments (9)
Thanks @MartynKeigher
Yep, I'm going to give the $PWD approach a try across the different platforms. I originally created the examples for 3 operating systems (Windows/Linux/Mac) but have found with variants being used, there are more ... for example
Linux as Ubuntu, Linux as Fedora/Arch (where it uses cgroups v2)
Windows with WSL1, Windows with WSL2, Windows with WSL2 + Ubuntu as the Subsystem
Mac x86, Mac M1
I'm pretty confident that the approach you've used will work well on Linux/Mac, it's the Windows variants that have the /mnt/c/users syntax which I'll need to verify. Fingers crossed as this will be a big win, will push it as a course update if it works out!
Thanks again for your time on this and, for teaching me about the $PWD! Enjoy the course and weekend!
from diveintoansible-lab.
We'll get this resolved. Can you please share with me the contents of your .env file. Also, tell me, this Ubuntu-VM that you're using, how is it running? There will be an additional step that you will need if this is a remote system (i.e. one you access remotely via ip).
Thanks
from diveintoansible-lab.
To give a bit more context as you asked me to elaborate. In the Docker Compose file, we have entries such as the following -
services:
ubuntu-c:
hostname: ubuntu-c
container_name: ubuntu-c
image: spurin/diveintoansible:ansible
ports:
- ${UBUNTUC_PORT_SSHD}:22
- ${UBUNTUC_PORT_TTYD}:7681
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- ${CONFIG}:/config
- ${ANSIBLE_HOME}/shared:/shared
- ${ANSIBLE_HOME}/ubuntu-c/ansible:/home/ansible
- ${ANSIBLE_HOME}/ubuntu-c/root:/root
networks:
- diveinto.io
Note how these are using the environment variables of ${CONFIG} and ${ANSIBLE_HOME}, these variables are read from the .env file.
What should happen, if it's working as expected. When the lab environment starts, it will mount those volumes accordingly with directories on your local system. This in turn, presents the config directory to the container as /config, this folder has details of what users etc to create.
When the container image starts up, if the /config directory exists, it reads the data in here and creates users (like the ansible user, along with a password).
If the /config mount isn't working as expected, when it starts up, it doesn't create the ansible user.
Let's take a look at the .env file and see if we can work out what is wrong.
Cheers
from diveintoansible-lab.
Something else worth adding ... as you're running in a VM rather than your local system, you may be seeing a nuance of Docker where for example, it's running as root and then it's trying to access config from a user directory. As well as seeing your .env file, it will be useful if you can share with me how you're running the docker-compose up. Am confident we'll be able to get this working by the way :) :)
from diveintoansible-lab.
OK - I got it to work and it was 100%... permissions! Naturally... lol!
Instead of pulling your content down, I manually created the 4 config files, the docker-compose & the .env
I also made slight changes to the docker-compose (volume & network properties) and now it works like a champ!
Here is my working copy of the docker-compose:
version: "3"
services:
ubuntu-c:
hostname: ubuntu-c
container_name: ubuntu-c
image: spurin/diveintoansible:ansible
ports:
- ${UBUNTUC_PORT_SSHD}:22
- ${UBUNTUC_PORT_TTYD}:7681
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- $PWD/config:/config
- $PWD/home/shared:/shared
- $PWD/home/ubuntu-c/ansible:/home/ansible
- $PWD/home/ubuntu-c/root:/root
networks:
- ansible
ubuntu1:
hostname: ubuntu1
container_name: ubuntu1
image: spurin/diveintoansible:ubuntu
ports:
- ${UBUNTU1_PORT_SSHD}:22
- ${UBUNTU1_PORT_TTYD}:7681
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- $PWD/config:/config
- $PWD/home/shared:/shared
- $PWD/home/ubuntu1/ansible:/home/ansible
- $PWD/home/ubuntu1/root:/root
networks:
- ansible
ubuntu2:
hostname: ubuntu2
container_name: ubuntu2
image: spurin/diveintoansible:ubuntu
ports:
- ${UBUNTU2_PORT_SSHD}:22
- ${UBUNTU2_PORT_TTYD}:7681
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- $PWD/config:/config
- $PWD/home/shared:/shared
- $PWD/home/ubuntu2/ansible:/home/ansible
- $PWD/home/ubuntu2/root:/root
networks:
- ansible
ubuntu3:
hostname: ubuntu3
container_name: ubuntu3
image: spurin/diveintoansible:ubuntu
ports:
- ${UBUNTU3_PORT_SSHD}:22
- ${UBUNTU3_PORT_TTYD}:7681
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- $PWD/config:/config
- $PWD/home/shared:/shared
- $PWD/home/ubuntu3/ansible:/home/ansible
- $PWD/home/ubuntu3/root:/root
networks:
- ansible
centos1:
hostname: centos1
container_name: centos1
image: spurin/diveintoansible:centos
#image: spurin/diveintoansible:centos-sshd-2222
ports:
- ${CENTOS1_PORT_SSHD}:22
#- ${CENTOS1_PORT_SSHD}:2222
- ${CENTOS1_PORT_TTYD}:7681
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- $PWD/config:/config
- $PWD/home/shared:/shared
- $PWD/home/centos1/ansible:/home/ansible
- $PWD/home/centos1/root:/root
networks:
- ansible
centos2:
hostname: centos2
container_name: centos2
image: spurin/diveintoansible:centos
ports:
- ${CENTOS2_PORT_SSHD}:22
- ${CENTOS2_PORT_TTYD}:7681
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- $PWD/config:/config
- $PWD/home/shared:/shared
- $PWD/home/centos2/ansible:/home/ansible
- $PWD/home/centos2/root:/root
networks:
- ansible
centos3:
hostname: centos3
container_name: centos3
image: spurin/diveintoansible:centos
ports:
- ${CENTOS3_PORT_SSHD}:22
- ${CENTOS3_PORT_TTYD}:7681
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- $PWD/config:/config
- $PWD/home/shared:/shared
- $PWD/home/centos3/ansible:/home/ansible
- $PWD/home/centos3/root:/root
networks:
- ansible
# Docker in Docker
#
# Usage: on host that wishes to use docker
#
# sudo apt-get update
# sudo apt -y install docker.io
# export DOCKER_HOST=tcp://docker:2375
# docker ps -a
#
docker:
hostname: docker
container_name: docker
image: spurin/diveintoansible:dind
privileged: yes
volumes:
- $PWD/home/shared:/shared
networks:
- ansible
portal:
hostname: portal
container_name: portal
image: spurin/diveintoansible:portal
environment:
- NGINX_ENTRYPOINT_QUIET_LOGS=1
- LOCALHOST_OVERRIDE=10.10.58.102
depends_on:
- centos1
- centos2
- centos3
- ubuntu1
- ubuntu2
- ubuntu3
ports:
- "1000:80"
networks:
- ansible
networks:
ansible:
external: false
NOTE: My $PWD
is /home/martyn/docker/ansible-lab
I left all commented-out lines in place (in docker-compose.yml) as I don't know if they have some relevance for later on in the course, and there 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
With these in place, it doesn't look like I need to do the 'extra steps required' on linux.
With all that said.. I do appreciate the quick response to my issue, but for now, all seems to be working just fine... and now I move forward with the course!
Thanks so much!
://mk
from diveintoansible-lab.
Hey @MartynKeigher
Interesting approach on the $PWD! I like it :-) :-) Will actually give this a try on the other operating systems to see if they honour it, might make things easier for people in general.
Great to see that you already have the LOCALHOST_OVERRIDE. Hope you enjoy the course and any other issues, just ping me. Depending on when you built your lab first, I updated Ansible yesterday to 4.1.0, docker-compose pull, will pull the latest one if you don't have it.
Thanks!
from diveintoansible-lab.
I like the fact that you keep this content up-to-date even after the initial course (on Udemy) was published!
I just started the course (pulled images) today... like 15 mins ago! Here is what I am seeing in ubuntu-c...
Is this what you are expecting? (I also pasted this image here to confirm my initial issue really is resolved!)
from diveintoansible-lab.
Thanks @MartynKeigher
Appreciate your comments, it's my aim to keep the course content up-to date going forward. I've put in some time in the background in creating an automated test framework which is under the 'tests' branch of the diveintoansible-lab, if this branch is run it essentially runs 161 tests at the moment, checking the lab etc and also that all of the playbooks execute without deprecation warnings.
Your environment is spot on by the way, the ansible --version is showing what is known as 'ansible-core'
If you run -
pip3 freeze | grep ansible
You'll see Ansible 4.1.0 (the current PyPi release) and core of 2.11.2 (which is the latest also).
Best Regards
James
from diveintoansible-lab.
Yup! Confirmed!
Cheers bud!
FYI: The $PWD/config
& $PWD/home
approach would remove the need for users to change the username from 'James' & would be one less thing for you to worry about_... and support!_ ;p
Enjoy the rest of your weekend!
://mk
from diveintoansible-lab.
Related Issues (20)
- You have reached your pull rate limit. HOT 4
- Cloud Shell Editor Error HOT 2
- Ansible user unable to connect to hosts HOT 2
- Ansible Playbooks Deep Dive Register and When - Rev 5 HOT 2
- docker_playbook.yaml fails with timeout HOT 4
- Permission problem HOT 1
- Support Windows clients in lab HOT 1
- Login incorrect HOT 1
- Unable to install sshpass HOT 1
- Words dont appear after writing HOT 10
- ssh-keygen -H -F 172.18.0.7 not printing. HOT 6
- Windows docker-compose up fails with 'Error response from daemon: Conflict. The container name "centos3" is already in use.... HOT 3
- /diveintoansible/ directory missing on ubuntu-c HOT 1
- Only docker-compose version seems to work
- Problem to open on the browser HOT 35
- Add cleanup script HOT 1
- Add ansible_home to .gitignore
- gitattributes is missing entries for md and png
- add editorconfig
- Permission denied error after running 'docker-compose up' (Windows 11) HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diveintoansible-lab.