Setting up an Ansible Test Environment in Ubuntu 16.04.4
-
#update and install LXC
sudo -i
apt-get update && apt-get install lxc
#create new containers
lxc-create -n db1 Ubuntu -d
lxc-create -n web Ubuntu -d
lxc-create -n web2 Ubuntu -d
Note: When you create your first container, in this case db1, you'll notice it takes awhile to pull everything you need. After it does that you'll experience a huge speed increase as it's referencing those files in/var/cache/lxc/trusty/*
.#list your containers
lxc-ls -f
#start the containers
lxc-start -n db1 -d
<-- always daemonize when first creating and initializing a container.
lxc-start -n web -d
lxc-start -n web2 -d
#list your containers
lxc-ls -f
Note: LXC sets up a virtual network device called LXCBR, or "LXC Bridge" and a DHCP server that hands out IP Addresses specifically for your LXC containers.#Attach to a container to run commands directly within that container
lxc-attach -n db1
#install ssh inside of the container. After installation, connect to the container via ssh.
sudo apt-get install openssh-server
#install python2 inside the container as a target machine requirement for Ansible playbooks
apt-get install python-minimal --no-install -recommends
Repeat the process for each remaining container.
lxc-attach -n web
apt-get install python-minimal --no-install -recommends
lxc-attach -n web2
apt-get install python-minimal --no-install -recommends
-
Helpful commands for initial setup:
lxc-start
-- starts the container
lxc-info
-- confirms the status of the container
lxc-ls
-- lists containers
lxc-attach
-- run commands from a specified container
lxc-stop
-- stops the container
lxc-destroy
-- destroys container -
Any reason for doing this on Ubuntu? Especially such a dated version?
-
@coliver The course I'm taking does it in this version of Ubuntu. No other reason than that.
-
I thought this version was only a month old?
-
@wirestyle22 said in Setting up an Ansible Test Environment in Ubuntu 16.04.4:
I thought this version was only a month old?
The PATCH is a month old, the VERSION is two years old.
-
@scottalanmiller said in Setting up an Ansible Test Environment in Ubuntu 16.04.4:
@wirestyle22 said in Setting up an Ansible Test Environment in Ubuntu 16.04.4:
I thought this version was only a month old?
The PATCH is a month old, the VERSION is two years old.
Gotcha. Still what I'm using in the course
-
For anyone interested, I recently setup Ansible AWX on Fedora 27 using this guide. Running as a local VM so didn't do anything with Nginx / reverse proxy.