mustardamus / ansible-stash

A collection of Ansible configurations, Makefile and Bash scripts to make it ridiculously easy to set up your web-presence in a reproducable and extendable manner.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ansible-stash

This is a collection of Ansible configurations, Makefile and Bash scripts to make it ridiculously easy to set up your web-presence in a reproducable and extendable manner.

It includes setting up a secure base for a server, a website with deploy and rollback functionality, a secure chat and email forwarding.

All can be tested before going live with a local staging server running Ubuntu, provided by VirtualBox and Vagrant.

Installation

make install

Conventions

Strings

# Incorrect

setting: {{ var }}
setting: '{{ var }}'
setting: "pure string"
setting: string with a {{ var }}
setting: /a/path/to/somewhere

# Correct

setting: "{{ var }}"
setting: pure string
setting: "string with a {{ var }}"
setting: "/a/path/to/somewhere"

Booleans

# Incorrect

Yes yes No no True TRUE False FALSE

# Correct

true false

Conditionals

# Incorrect

when: thing
when: thing is true
when: thing is false
when: some_long_role_variable == true and some_other_very_long_variable == false or exceeds_80_characters == true

# Correct

when: thing == true # explicitly check for `true`
when: thing == false
when: >
  some_long_role_variable == true and
  some_other_very_long_variable == false or
  exceeds_80_characters == false

Task naming

# Incorrect

name: It's like a sentence describing what it does
name: references to the role name, like 'start Nginx'

- name: set fact
  set_fact:
    thing: true

- name: get stat
  register: output
  stat:
    path: "/to/some/path"

# Correct

name: lowercase and kept short
name: start service

- set_fact:
    thing: true

- register: output
  stat:
    path: "/to/some/path"

Task arguments order

# Incorrect

- name: install package
  apt:
    name: thing
    state: present
  register: output
  when: something == true

# Correct

- name: install package
  when: something == true
  register: output
  apt:
    name: thing
    state: present

Long strings, commands

# Incorrect

command: executable --with --some "very long arguments" --exceeding {{ var }} --characters

# Correct

command: >
  executable \
  --with \
  --some "very long arguments" \
  --exceeding {{ var }} \
  --characters

Recurring conditionals

# Incorrect

- name: install some package
  when: thing == true
  apt:
    name: some
    state: present

- name: install other package
  when: thing == true
  apt:
    name: other
    state: present

# Correct

- name: install packages
  when: thing == true
  include_tasks: install_packages.yml

# install_packages.yml
- name: install some package
  apt:
    name: some
    state: present

- name: install other package
  apt:
    name: other
    state: present

Role variable names

# Incorrect

some_variable

# Correct

role_name_some_variable # prefixed role name

Sub-function for roles

# Incorrect

sub_function_is_triggered: true

# Correct

sub_function_is_triggered: false # must be explicitely set by the playbook

About

A collection of Ansible configurations, Makefile and Bash scripts to make it ridiculously easy to set up your web-presence in a reproducable and extendable manner.


Languages

Language:Jinja 95.9%Language:Makefile 2.2%Language:Shell 1.9%