From redeploy2019: Ways we can deal with overload in a system. Note: some of these choices can be made by people, or agents, or both
From James Hamilton: Don’t let agents make choices you wouldn’t give to a junior engineer (the notion of what things a junior eng can do is possibly shifting as we get better at creating safety :))


Heredoc that converts newlines to spaces and ignores leading indent

a_long_line: >
    line 1
    line 2
    line 3

# Prints: line 1 line 2 line 3

Heredoc that preserves newlines and ignores leading indent

private_key: |
    line 1
    line 2
    line 3

# Prints:
line 1
line 2
line 3


Gathering facts is expensive
If you can skip this step, do so
I have a couple plays that looks at memory
Think about tuning the number of forks
5 is the default
Too many doesn't work (kinda heavy weight)
25-50 is probably good for a dedicated ansible server
5-25 for a dev machine
Use scp (default is sftp)
Increase ControlPersist (default 60s)

Sample ansible.cfg
gathering = smart
gather_subset = min
fact_caching = jsonfile
fact_caching_connection = ~/.ansible/cache
fact_caching_timeout = 3600

pipelining = True
scp_if_ssh = True
ssh_args = -C -o ControlMaster=auto -o ControlPersist=15m
Python3 is better than python2

Use ansible to update centos packages

List updates
> ansible -i "hosts / inventory file," all -m yum -a "list=updates"

Apply updates
> ansible -i "host / inventory file," all -m yum -a "name='*' state=latest"

Community knowledge

“Genius has an important role in developing mathematics, but actually the knowledge itself is the result of the activity of a community. It’s the real goal of knowledge to become the knowledge of the community, not the knowledge of one or two persons.”

André Joyal (Mathematician)


Powerful json message parsing on the command line

# Gets me all keys connected to the doc node
jq '. | keys' a.json

# Tells me how many sub docs are rooted at events
jq '.events | count' a.json

# Generate a csv from a json array
jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv' a.js.out

# Filter a list of json documents by the State field
# Like Java's stream programming model (and other languages?)
#   filter, map, reduce!
cat | jq '.BackupJobs | map(select(.State == "FAILED"))'