/podlab

Build a simple lab ready for exercising with Ansible

Primary LanguageShellMIT LicenseMIT

podLAB

Build a simple lab using podman and systemd, ready for exercising with Ansible, inspired by @mrjackv ansible-nspawn

Requirements

  • systemd
  • podman
  • buildah
  • python
  • ssh-keygen, ssh
  • ansible

Usage

First run the setup

./setup

This script will generate an ssh-key pair, setup the podlab network and then download a centos:stream9 image and perform the following steps on it:

  • add podlab labels
  • install userful packages (see Included Pakcages)
  • add ansible user
  • add ansible ssh key
  • allow ansible to sudo without password
  • add a student user
  • allow root login

then start pods with the boot script, and you can set optionally the ansible gruop to which they will belong.

./boot [group]

You can also use the option -a to attach directly to the new container.

Finally you can run your playbooks like this:

ansible-playbook ./playbooks/example.yml

After you're done excercising, you can stop the lab with the command

./shutdown

You can also use the -c option to delete the image and the network. They will be created again next time tou run the setup script

What's inside?

A quick look at the files and directories included in podlab

.
├── playbooks
├── ansible.cfg
├── boot
├── inventory
├── LICENSE
├── podssh
├── README.md
├── setenv
├── setup
├── shutdown
└── ssh_config
  1. playbooks: A direcotry where you can place you playbooks. podLAB comes with a playbook named example.yml. You can run it with the command ansible-playbook playbooks/example.yml
  2. ansible.cfg: The configuration to tell ansible how to connect to podLAB containers
  3. boot: Runs a podLAB container (see usage)
  4. inventory: Inventory script for Ansible in Python, it will filter out any non-podLAB containers
  5. LICENSE: podlab's MIT license
  6. podssh: ssh script in podman's unshare net namespace environment, it allows to ssh to any container easily.
  7. README.md: This file :)
  8. setenv: podLABS configuration
  9. setup: Configures the environment for podLAB's usage (see usage)
  10. shutdown: Stops all podLAB's containers, and optionally clears images and networks (see usage)
  11. ssh_config: The ssh configuration file that allows ansible and manual ssh connection to containers

Included packages

- basesystem
- bash
- systemd
- openssh-server
- passwd
- sudo
- python3
- yum
- dnf
- findutils
- iproute
- NetworkManager
- iputils
- bind-utils
- procps-ng
- openssh-clients
- nc
- at
- hostname
- acl
- xz
- zip
- info
- wget
- bzip2
- file
- ed
- nano
- quota
- less
- which
- strace
- symlinks
- tcpdump
- time
- tree
- jq
- pinfo
- vim-enhanced
- words
- util-linux-user

License

MIT License