Ansible –extra-vars

Note that this post uses NTC-Ansible. Installation instructions can be found here.

Often you will see variables defined in a Playbook, a Task and/or a variables file such as group_vars or host_vars, as shown below:

Continue reading

Installing Git on Windows

Installing Git on Windows is very similar to installing it on Linux. That might not come as a surprise though because the tools we’ll be using in this post are specifically designed to allow Windows users to utilise Linux packages without needing to install a VM.

Installation

The first thing you’ll need to do is download Git for Windows. Once you have done that, install it using all of the default settings. After completing the installation, you will find that you’ve now got three Git applications:

  • Git Bash
  • Git CMD
  • Git GUI

Continue reading

Installing Ansible on Windows

While Ansible is not supported on Windows, it is very easy to get it up and running. The Ansible documentation provides information on how to do it using  Windows Subsystem for Linux (Beta), I’ve run into issues trying to get WSL up and running so instead opted for Cygwin.

For those who are unfamiliar with Cygwin, it is “a large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows.”

Continue reading

What does a Compiler do?

If you’ve used Linux before and/or have coded using a language such as C, you will have come across a compiler. Though because they’re so easy to use, you might not have actually understood what it is they do.

In a nutshell, compilers simply (I say simply because what they do is actually very complex under the hood) check for syntax correctness, convert source code from “high level” languages to a low level (native) language which your CPU understands and perform optimisation among other things. Due to the conversion and optimisation of code, compiled applications run much faster than when other methods are used. The result of a compilation is a standalone executable application (e.g an .exe file in Windows) which does not depend on any other application in order to run.

Continue reading

Python: A Strong, Dynamically Typed Language

You’ve probably already heard that Python is a strong, dynamically typed language. But what does that actually mean? Let’s jump in and take a look.

Dynamically vs Statically Typed Languages

This StackOverflow Q&A gives us an idea on the difference between Statically and Dynamically Typed languages:

A language is statically typed if the type of a variable is known at compile time. For some languages this means that you as the programmer must specify what type each variable is (e.g.: Java, C, C++)

Continue reading

Python: Statements & Expression

In Learning Python (a must read for anyone interested in Python!), author Mark Lutz refers to statements and expressions frequently, but give a clear explanation of the two.

Rather than reinventing the wheel by providing my own definition and examples of the two, I found this Quora Q&A does that perfectly:

Answer #1

A statement is a complete line of code that performs some action, while an expression is any section of the code that evaluates to a value. Expressions can be combined “horizontally” into larger expressions using operators, while statements can only be combined “vertically” by writing one after another, or with block constructs. Every expression can be used as a statement (whose effect is to evaluate the expression and ignore the resulting value), but most statements cannot be used as expressions. Here’s a complete list of statements.

Continue reading

Python: The difference between Lists & Tuples

A common misconception is that the only difference between Lists and Tuples is that the former is mutable while the latter is immutable. While this is true, it is only one of the differences between them as per the Q&As quoted below.

Question #1

What’s the difference between lists and tuples?

Answer #1

(Answer link)

… This gives rise to differences in how they can or can’t be used (enforced a priori by syntax) and differences in how people choose to use them (encouraged as ‘best practices,’ a posteriori, this is what smart programers do). The main difference a posteriori in differentiating when tuples are used versus when lists are used lies in what meaning people give to the order of elements.

Continue reading

Installing NTC Ansible

I’ve written about NTC-Ansible a couple of times already and thought now would be a good time to run you through the installation process. The github page provides some great information on the process, but I’d like to add a few extra details in this post.

Note that there are two ways in which you can install custom modules. They work as well as one another so it’s up to you which you choose.

Continue reading

Ansible Minimum Viable Playbook (MVP)

Reference: Adam’s Tech Blog

The Minimum Viable Playbook (MVP) is the shortest, most useful Ansible playbook I have. Whenever I need to write some Ansible code and I’m not entirely sure I’m doing it right (which is often), I implement it first in the MVP so I can test it quickly. Here’s my latest iteration:

Continue reading

Ansible search( ) Test

Reference: Ansible

match  requires a complete match in the string, while search  only requires matching a subset of the string.

Example

As per the selectattr( )  page, the Jinja equalto( )  Test, as well as the Ansible match( )  and search( )  Tests all work in a similar fashion.

Using this dictionary:

Continue reading