This is the content from my talk at Ansible Barcelona meetup on 15th October 2015.
-
Install LXC tools for your GNU/Linux distribution and setup network configuration (e.g. Arch Linux or Ubuntu)
-
Clone this repo:
> git clone git@github:enricostano/ansible-lxc-demo.git
-
Modify the shared filesystem part of the
provisioning/ubuntu.custom.conf
file to reflect the actual path of your directories -
From the
provisioning
directory run:> sudo lxc-create --name project_1_dev -f ubuntu.custom.conf -t /usr/share/lxc/templates/lxc-ubuntu -- --release trusty > sudo lxc-start --name project_1_dev > sudo lxc-ls --fancy
The last command should show you the list of existing LXC containers in your machine, something like the following:
NAME STATE IPV4 IPV6 GROUPS AUTOSTART ----------------------------------------------------------- project_1_dev RUNNING 10.0.3.106 - - NO
Fix your network configuration if you don't get an IP address for your container.
-
Copy your SSH key into the default container user:
> ssh-copy-id [email protected]
-
Install Ansible for your GNU/Linux distribution
-
Add the container IP to the list of Ansible's hosts:
# /etc/ansible/hosts [development] 10.0.3.106
-
Enter through SSH into the container:
> ssh [email protected]
-
From inside the container install Ansible's dependency Python 2.7 (remember that the default ubuntu password is
ubuntu
):> sudo apt-get install python2.7 > sudo ln -s /usr/bin/python2.7 /usr/bin/python
-
Exit the container using CTRL^D and run the Ansible playbook from the
provisioning
directory. It will ask for the ubuntu sudo password:> ansible-playbook development.yml
-
Enter through SSH into the container:
> ssh [email protected]
-
Enter the
backend
directory and install the application dependencies:> bundle install
-
Run the application:
> bundle exec rails s --binding 10.0.3.106
-
Open a browser and visit the following URL:
10.0.3.106:3000
-
Enter through SSH into the container:
> ssh [email protected]
-
Enter the
frontend
directory and install the application dependencies:> npm install
-
Run the application:
> node app.js
-
Open a browser and visit the following URL:
10.0.3.106:8000