• Stars
    star
    827
  • Rank 54,718 (Top 2 %)
  • Language
  • Created almost 4 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Dive Into Ansible Lab

Dive Into Ansible Course Lab

Follow GitHub Stars

✨ This repository provides a local lab configuration for DiveInto.com's 'Dive Into Ansible' course ✨

The related code repository is available at - https://github.com/spurin/diveintoansible

The full video course relating to this lab is available on -

πŸ†˜ If you experience any problems with the lab or the course, please reach out to me direct, James Spurin, or flag an issue in the repositories. I'd much rather know about an issue and in doing so, help yourself and others who encounter similar problems, Thanks!

πŸš€ New Update: The diveintoansible-lab can now also be executed in the cloud using Google's Free Cloud Shell Tier. For this, a standard Google account is required. The lab setup process in Cloud Shell can be started with a single click and a setup tutorial will appear on the right hand side. Please see https://diveinto.com/p/playground

❗ The steps that follow below are for a local running lab instance which is the recommend approach. Whilst the new Google Cloud Shell based lab is convenient and is great for spinning up an Ansible lab in a matter of minutes or for adhoc experimentation, a locally running lab has improved latency and you'll also benefit from data persistence (any custom playbooks you create will remain on your system between lab restarts) -

Installation of Docker and Docker-Compose

The lab environment, makes use of Docker with Docker Compose. If you're on Windows or Mac, you can install the convenient Docker Desktop to make both Docker and Docker-Compose available

Linux, will require the installation of Docker and Docker Compose. Be aware, when installing docker-compose via apt or yum/dnf, you may install an older version that is incompatible with the lab. It is recommended that you install a version >= 1.29.1. A standalone binary can be downloaded from the Github releases page

Download and Preparation

I recommend that the lab environment is downloaded to your respective home directory, i.e. -

  • Mac - /Users/james/diveintoansible-lab
  • Windows - C:\Users\james\diveintoansible-lab
  • Linux - /home/james/diveintoansible-lab

Mac or Linux

You should be able to clone the repository accordingly from a terminal whilst in your home directory with the following command -

git clone https://github.com/spurin/diveintoansible-lab.git

Windows

If you don't have git installed, the lab can be downloaded using the following url - https://github.com/spurin/diveintoansible-lab/archive/master.zip

After unzipping the archive, you must ensure that a single diveintoansible-lab folder is copied into your home directory (not multiple folders, i.e. diveintoansible-lab-master/diveintoansible-lab or diveintoansible-lab/diveintoansible-lab). See the next section on Validation.

Validation (IMPORTANT)

Please verify that all of the lab files, are in the expected locations after either cloning, or extracting the zip file, for your corresponding OS and User. They should be similar to the following and all files should exist (the config files are required to setup the ansible user upon startup) -

Mac OS X

/Users/james/diveintoansible-lab/.env
/Users/james/diveintoansible-lab/DiveIntoAnsible_Cover.png
/Users/james/diveintoansible-lab/README.md
/Users/james/diveintoansible-lab/docker-compose.yaml
/Users/james/diveintoansible-lab/config/guest_name
/Users/james/diveintoansible-lab/config/guest_passwd
/Users/james/diveintoansible-lab/config/guest_shell
/Users/james/diveintoansible-lab/config/root_passwd

Windows

C:\Users\James\diveintoansible-lab\.env
C:\Users\James\diveintoansible-lab\DiveIntoAnsible_Cover.png
C:\Users\James\diveintoansible-lab\README.md
C:\Users\James\diveintoansible-lab\docker-compose.yaml
C:\Users\James\diveintoansible-lab\config\guest_name
C:\Users\James\diveintoansible-lab\config\guest_passwd
C:\Users\James\diveintoansible-lab\config\guest_shell
C:\Users\James\diveintoansible-lab\config\root_passwd

Linux

/home/james/diveintoansible-lab/.env
/home/james/diveintoansible-lab/DiveIntoAnsible_Cover.png
/home/james/diveintoansible-lab/README.md
/home/james/diveintoansible-lab/docker-compose.yaml
/home/james/diveintoansible-lab/config/guest_name
/home/james/diveintoansible-lab/config/guest_passwd
/home/james/diveintoansible-lab/config/guest_shell
/home/james/diveintoansible-lab/config/root_passwd

Configuration

In earlier releases of Docker and with the variations between Operating Systems, we had to configure the .env file with specific CONFIG and ANSIBLE_HOME entries. This step should no longer be necessary

If you find that you cannot login as the ansible user with the password of password and the config files exist as per the Validation section, then update both of these entries according to your environment -

Mac OS X

# Shared config volume
CONFIG=/Users/james/diveintoansible-lab/config

# Shared home directories
ANSIBLE_HOME=/Users/james/diveintoansible-lab/ansible_home

Windows (n.b. 'users' and the username (in my case this is james) are in lowercase, this is important)

# Shared config volume
CONFIG=/host_mnt/c/users/james/diveintoansible-lab/config

# Shared home directories
ANSIBLE_HOME=/host_mnt/c/users/james/diveintoansible-lab/ansible_home

Linux

# Shared config volume
CONFIG=/home/james/diveintoansible-lab/config

# Shared home directories
ANSIBLE_HOME=/home/james/diveintoansible-lab/ansible_home

Running the lab

You should then be able to run the following in your command prompt or terminal, directly from the diveintoansible-lab directory -

docker-compose up

If all goes well, it should start the lab environment. The lab is ready for use when you see text similar to the following -

Attaching to docker, centos1, ubuntu2, ubuntu3, centos2, centos3, ubuntu-c, ubuntu1, portal

Keep this terminal open and running whilst using the course. In your browser, then browse to http://localhost:1000 and you should get the lab interface. If you find that you cannot login to the Ansible control host (ubuntu-c) as ansible and the password of password, then there is a fault with your configuration. If this is the case, it is important to perform the following actions before troubleshooting or changing your configuration. Press CTRL-C, then run the following -

docker-compose rm

Should you encounter issues at this stage that you cannot resolve, please contact me or, raise an issue in the repository with as much detail as possible (including copies of your .env file)

Troubleshooting Common Issues

1. Cannot log in as the ansible user

When the lab environment is configured and started, it reads the configuration directory and sets up the ansible user. This is based on the entry in config/guest_name. It expects the config directory to be provided as a volume using the CONFIG entry in the .env file. See the 'Configuration' section above as this will vary for Windows, Linux and Mac OS X.

If this entry is incorrect, it will not find the config directory and subsequently, the ansible user will not be created.

A convenient way of verifying that the path you're using is correct is by running a similar command to the following, substituing the path you're trying to use. If you see the output of 'ansible', the configuration path is as expected, if not, you'll need to tweak the configuration -

docker run --rm -v /Users/james/diveintoansible-lab/config:/config ubuntu cat /config/guest_name

This command passes the volume mount manually (-v for volume), the local path (/Users/james/diveintoansible-lab/config), the target mount point (:/config). Then, it runs a ubuntu container with a command to show the contents of /config/guest_name. Finally, --rm cleans up the container after it exits.

Lastly, the ANSIBLE_HOME entry within .env should use the same format.

Extra step for Linux users

Owing to the permissions model for Docker with Linux, there is one additional step that needs to be carried out. With the lab working and connectivity working as ansible, perform the following actions -

su - 
<enter the password of password when prompted>
chown ansible /shared
exit

Lab commands

To refresh the images with the latest course images -

docker-compose pull

To remove the lab

docker-compose rm

Container Sources for the Lab Images

The Dockerfiles used for the creation of these lab images are available from the following -


DiveIntoAnsible Cover

More Repositories

1

diveintoansible

Content for DiveInto.com's 'Dive Into Ansible' Course
Jinja
1,538
star
2

diveintokubernetes

Dive Into Kubernetes - Getting Started with Containers, Docker and Kubernetes
118
star
3

KCNA-Study-Group

Kubernetes and Cloud Native Associate - Study Group
111
star
4

masteringansible

Repository for course content for Packt Mastering Ansible Course
HTML
109
star
5

cncf-psi-k8s-linux-simulator

CNCF PSI Kubernetes Exam Linux Environment Simulator
93
star
6

xmldataset

xmldataset: xml parsing made easy πŸ—ƒοΈ
Python
77
star
7

kubernetes-v1.0-lab

Kubernetes v1.0 Lab Environment to Celebrate 10 Years of Kubernetes
74
star
8

docker-hexo

Docker container for running hexo with hexo admin πŸ‹
Dockerfile
52
star
9

diveintokcna

Dive Into Containers, Kubernetes and the Kubernetes Cloud Native Associate Certification
32
star
10

diveintokubernetes-introduction-resources

Commands executed during the Dive Into Kubernetes - Introduction Course
27
star
11

kubernetes-v0.1-lab

Kubernetes v0.1.0 with Prebuilt Binaries & Tutorial
Go
23
star
12

python-ipc-examples

Python Inter Process Communication Examples πŸ’¬
Python
20
star
13

k9s-dd-extension

This provides an extension integration with Docker Desktop to run k9s quickly and easily through the Docker Desktop interface.
TypeScript
19
star
14

diveintoansible-images

Dockerfiles for course lab images
13
star
15

diveintoansible-extension

Dive Into Ansible Lab - Docker Desktop Extension πŸ‹
CSS
12
star
16

container-systemd

✨ Popular linux distributions configured with systemd ✨
11
star
17

wsl-cgroupsv2

Guidance for running cgroupsv2 as a baseline with WSL and Docker Desktop
Shell
10
star
18

tobii-aoi-copy

Tobii Eye Tracker Area of Interest (AOI) Copy πŸ‘€
Python
9
star
19

container-systemd-sshd-ttyd

✨ Popular linux distributions configured with systemd, sshd and ttyd ✨
9
star
20

kubernetes-contributions

Sharing is caring, personal tracker for contributions that I have made or am working on with Kubernetes ☸️
8
star
21

london-iac

Ansible London-IAC Presentation 20210128
Shell
5
star
22

kubeconfig-creator

A convenient wrapper script for creating kubeconfig files based on RBAC groups
Shell
5
star
23

kubernetes-insider

An awesome Docker Desktop extension that provides rapid web access to Kubernetes infrastructure
TypeScript
5
star
24

fake-lb

βš–οΈ Lightweight, dummy load balancer designed for local testing in Kubernetes environments
Shell
4
star
25

argo-f-yourself

Testing Argo
3
star
26

webden-extension

Docker Desktop Extension for Chris Diana's Webden
Makefile
3
star
27

diveintoansible-lab-gcp-cloudshell

Preconfigured GCP Cloudshell Dive Into Ansible Lab
3
star
28

hello-app

Cross-architecture (cross-arch) build of the Google Cloud Engine 'hello-app' example
Go
3
star
29

rootshell

Container image for demonstrating setuid escalation
Dockerfile
2
star
30

showcase

James Spurin - Showcase
2
star
31

container-systemd-sshd-ttyd-commontools

✨ Popular linux distributions configured with systemd, ttyd, sshd and commontools ✨
2
star
32

CNCF-Kubernetes-Clusters-Need-Persistent-Data

Scripts used in the CNCF talk @ https://www.youtube.com/watch?v=xa5G-c8iYEo
Shell
2
star
33

nginx-with-tools

Nginx image that includes additional tools useful for network troubleshooting and web requests
Shell
2
star
34

webtop-k8s

Customised Webtop Image configured with kubectl, common tools and Firefox, preconfigured for kubernetes.io
Shell
2
star
35

ubuntu-curlimages-curl

Ubuntu container image that mimics curlimages/curl
Shell
1
star
36

cloudshell-troubleshooting

Test URL's for Google Cloud Shell Testing
1
star
37

spurin.github.io

spurin.com website 🌐
HTML
1
star
38

nginx-blue

Nginx container with a default html template with a blue background for demonstration purposes
Shell
1
star
39

nginx-red

Nginx container with a default html template with a red background for demonstration purposes
Shell
1
star
40

readiness-liveness-startup-probe-api

Source code for the spurin/readiness-liveness-startup-probe-api container image, designed to provide behind the scenes information when using Kubernetes probes
Python
1
star
41

container-k9s-ttyd-kubectl

Container image that bakes together k9s / ttyd and kubectl
Shell
1
star
42

redis-hacker-news-clone

Docker Compose wrapper for https://github.com/redis-developer/redis-hacker-news-demo
Shell
1
star