opensour.cc developers' network - quick start guides to bootstrap examples

(Perfect for people with a short attention span, needing to get work done!)

Please note: this entry is incomplete, and somewhere between a preliminary draft and a stub.

Introduction

Not much is required to hit the ground running with Ansible. Generally speaking, the only configuration that you really need to make, is by adding at least 1 entry to the Ansible Inventory file.

General

Many of Ansible's settings can be modified via environment variables, including changing it's preference path to key files such as Ansible Inventory. Our preferred way of doing so is using the Localized Configuration methodology that we've devised for a Python-based installation.

Inventory

Static

  • Edit your Ansible "hosts" file and add an entry for your local machine that will be running Ansible:
    localhost    ansible_connection=local

Notes:

  • It's strongly advised that you read the Ansible documentation regarding host inventory.
  • If your localhost requires you to enter a password, you have 1 of 3 choices:
    1. When executing Ansible from the command line, use the command line argument to interactively ask you your sudo password: --ask-sudo-pass
    2. Use the ansible_become_pass inventory option - you probably shouldn't do this, unless you're absolutely sure that nobody but you will have access to your Ansible Inventory file.
    3. Set your account up in sudo to not require a password - in most cases, you don't want to do this.
      • sudo touch /etc/sudoers.d/90-local && chmod 440 /etc/sudoers.d/90-local
      • Edit /etc/sudoers.d/90-local
      • YourUserNameHere ALL=(ALL) NOPASSWD:ALL
      • Please make sure that you get this correct, as if you don't, important things could break (which is why visudo is a utility that many use).
      • If you're really sure that it's all correct, then save and exit.

Options

There are many options to choose from. We will only be highlighting the most common which we find for interfacing to our client machines via our freshly installed Ansible host machine:

  • Connection
    • ansible_connection
    • ansible_host
    • ansible_port
    • ansible_ssh_common_args
  • Authentication
    • ansible_user
    • ansible_ssh_pass
    • ansible_ssh_private_key_file
  • Administrator elevation
    • ansible_become_user
    • ansible_become_pass

Machines

As you saw above, a single host exists per line. An example of an inventory consisting of 10 additional servers, using default SSH key authentication, with comments, and groups, might look like:

localhost         ansible_connection=local
 
# Justice League
superman          ansible_ssh_host=superman.justiceleague.example        ansible_become_user=kalel    ansible_become_pass='lois'
batman            ansible_ssh_host=batman.justiceleague.example          ansible_become_user=bruce    ansible_become_pass='selina'
wonderwoman       ansible_ssh_host=wonderwoman.justiceleague.example     ansible_become_user=diana    ansible_become_pass='clarkandbruce'
flash             ansible_ssh_host=flash.justiceleague.example           ansible_become_user=barry    ansible_become_pass='iris'
greenlantern      ansible_ssh_host=greenlantern.justiceleague.example    ansible_become_user=hal      ansible_become_pass='carol'
 
# The Avengers
ironman           ansible_ssh_host=ironman.avengers.example              ansible_become_user=tony     ansible_become_pass='pepper'
captainamerica    ansible_ssh_host=captainamerica.avengers.example       ansible_become_user=steve    ansible_become_pass='peggy'
hulk              ansible_ssh_host=hulk.avengers.example                 ansible_become_user=bruce    ansible_become_pass='betty'
thor              ansible_ssh_host=thor.avengers.example                 ansible_become_user=thor     ansible_become_pass='jane'
antman            ansible_ssh_host=antman.avengers.example               ansible_become_user=hank     ansible_become_pass='janet'
 
[justiceleague]
superman
batman
wonderwoman
flash
greenlantern
 
[avengers]
ironman
captainamerica
hulk
thor
antman

Dynamic

See also

External links

Navigation
Print/export