OS and Application Configuration - cirelledo-csa/herd GitHub Wiki

[OS and Application Configuration]

Linux

Ansible

Our default automation tool for OS and Application Configuration is ansible.

Install

Ansible is written in python and can be installed with:

pip install ansible
  • Read the friendly manuals RTFM
  • Looking to build something new? search and see if there's an existing role you can adapt to suit your needs Ansible Galaxy:
ansible-galaxy search db2
  • Create/Use ansible roles to create standard images

Quick start

run ansible locally and get list of ansible variables

ansible -i "localhost," all -m setup -c local

run ping host

ansible -i "$host," all -m setup -u $user --key-file $key_file

run ansible on a host as a user and get list of ansible variables

ansible -i "$host," all -m setup -u $user --key-file $key_file

list host but don't do anything

ansible -i $inventory all -m setup -u $user --key-file $key_file -f 15 -t /tmp/setup --list-hosts

limit hosts

ansible -i $inventory all -m setup -u $user --key-file $key_file -f 15 -t /tmp/setup --limit $hostname

run ansible with 15 concurrent sessions on an inventory and save results per host

ansible -i $inventory all -m setup -u $user --key-file $key_file -f 15 -t /tmp/setup

run adhoc raw command on a host

ansible -i "$host," all -m raw -a uptime -u $user --key-file $key_file
    ```

### Creating Roles with Molecule

Need a custom ansible role? Use [molecule](https://molecule.readthedocs.io/en/latest/) to create small re-useable tested role(s).

#### Install

pip install molecule


#### Initialize

molecule init role -r cirelledo-csa.your-incredible-role -d docker


#### Test

cd cirelledo-csa.your-incredible-role molecule converge


#### Local Development

cd cirelledo-csa.your-incredible-role molecule converge #hack molecule converge #more hacking molecule converge


Molecule converge runs a persistent local docker container so that you don't
have to start from scratch. You can debug by doing:

docker exec -it $container bash


# Windows
???