Tricks of the Trades

Ansible - Local Playbook Execution

Ansible Logo

Preamble

There are a several ways to run Ansible on a local system that I could find whilst searching the net. In this I’m covering three of the ones that were the most popular or the most prevalent. The first two seem great for their different contexts, and the third is not as necessary but worth considering perhaps.

Being able to do this can be very useful for setting up your own machines or workstations (dotfiles anyone?) at least in the event that you don’t want to use traditional scripting. Also when creating playbooks that involve interacting with developer API’s this is an important component - see the “more information” section at the end, for a link to an example of this.

Ansible - Playbook Server Provisioning (5)

Ansible Logo

Preamble

One of the many purposes of Ansible is to easily, quickly, and efficiently provision new server infrastructure. The use of configuration management tools in server provisioning can be quite essential, as it provides a very flexible solution in regards to deploying and managing new hosts. This post goes through a very simple example playbook that uses Ansible roles to break up and organise the provisioning process. If you haven’t used Ansible to setup a server before this is a good place to start. The idea can then be expanded upon to add more individual components or specific ideas.

The Playbook is intended for Linux hosts running Debian 8 (Jessie) and is tested using a suitable Vagrant VM. After the testing, towards the end of the post, the playbook is then deployed to several newly created Debian 8 droplets on Digital Ocean.

How to Install and Get Started with Vagrant in 2017

Vagrant Logo

Preamble

Despite its age and familiarity to most nowadays I couldn’t find a straight forward post on how to install and get started using Vagrant. So here’s my notes on doing so in blog post format. Be aware that this is well trodden ground and the Vagrant documentation on their website has a similar set of steps and content. The official site, if not this will get you where you need to be when it comes to getting started with Vagrant.

Official Vagrant Website - Getting Started

Ansible - Playbook Concepts (4)

Ansible Logo

Preamble

Playbooks are written in YAML like the configuration files and are the basis for Ansible’s configuration management and en-masse multi-machine deployment.

These are very powerful not only for declaring server configurations but also to orchestrate steps of any manual ordered process, even when the different steps must bounce back and forth between sets of machines in any order, as playbooks can launch tasks synchronously or asynchronously as required.

While it’s suitable to use the /usr/bin/ansible program for ad-hoc commands and tasks. Playbooks are better kept in source control and used to push out larger configurations, or assure the configurations of your remote systems are still in check.

Ansible - Ad Hoc Commands and Modules (3)

Ansible Logo

Preamble

Several ad hoc commands were shown in the previous post but no real detail was given as to what they can fully offer. These ad hoc commands are often cited as being a good starter point for learning what’s possible with Ansible; without having to dive straight into writing a playbook. Most of them incorporate the use of a module into their structure, so this post introduces modules too. Both from the point of view of an ad hoc command, and within the context of a task. Towards the end, the “special” Ansible module types are shown.