Recent posts

Ansible Lists & Dicts Overview

April 18, 2017

Reference: Ansible All members of a list are lines beginning at the same indentation level starting with a -  (a dash and a space): --- # A list of tasty fruits fruits: - Apple - Orange - Strawberry - Mango A dictionary is represented in a simple key: value  form (the colon must be followed by a space): # An employee record ...

Ansible Inventory

April 18, 2017

Hostnames Reference: Ansible Variables & Inventory  inventory_hostname  is the name of the hostname as configured in Ansible’s inventory host file. This can be useful for when you don’t want to rely on the discovered hostname ansible_hostname  or for other mysterious reasons. If you have a long FQDN, inventory_hostname_short  also contains...

Ansible Installation

April 18, 2017

Reference: Ansible To configure the PPA on your machine and install Ansible run these commands: $ sudo apt-get install software-properties-common $ sudo apt-add-repository ppa:ansible/ansible $ sudo apt-get update $ sudo apt-get install ansible

Ansible Conditionals

April 18, 2017

Inline expressions Reference: Inline ‘if’ expressions It’s possible to use inline if-expressions: {{ 'Update' if files else 'Continue' }} Note: See the Jinja2 Filters section for more information. ‘if/else’ example Reference: cidr block’s git repo "{{ 'unknown' if ssh_output|failed else ssh_output['stdout'][0]|determine_os}}" Note: Se...

Ansible Built-in Variables

April 18, 2017

Ansible has built in variables which you can come in handy with some Playbooks. They can be viewed using the following Ad-Hoc command: ansible all -i 192.168.0.211, -m debug -a "msg=" or this Task: --- - name: Display vars debug: msg= Note that the latter provides much more information than the former. When the above Task is run, one of...