Skip to content

Instantly share code, notes, and snippets.

@pestophagous
Created April 1, 2020 17:33
Show Gist options
  • Save pestophagous/d76738a5056a4b85885793179eb798c5 to your computer and use it in GitHub Desktop.
Save pestophagous/d76738a5056a4b85885793179eb798c5 to your computer and use it in GitHub Desktop.
playbook from Apr 1 demo. (not intentionally an April fool's gag)
---
- hosts: localhost
connection: local # also run as: ansible-playbook -vv --connection=local playbook.yml
become: yes
vars:
plain_old_username: username
repos_install_dir: /opt/repositories/
tasks:
- name: "Update apt cache"
apt:
update_cache: yes
cache_valid_time: 3600
- name: "get disk availability"
register: main_disk_kb
become: false # to make extra sure we didn't change anything
changed_when: false # logically this shell cmd never changes anything
shell: df -P /usr/lib | tail -1 | tr -s ' ' | cut -d ' ' -f4
args:
executable: /bin/bash
- name: "Print some debug info"
debug:
msg: "main_disk_kb available is {{ main_disk_kb.stdout }}"
- name: "Fail if insufficient disk space"
fail: msg="You probably want more disk space. Either get some or comment out this fail."
when: "(main_disk_kb.stdout | int) < 15000000"
# - name: "apt ubuntu-desktop"
# async: 1800
# poll: 15 # this way we can at least see action with '-vvv'
# apt: # we assume update_cache was done earlier in book!
# name: "{{ item.name }}"
# state: "{{ item.state }}"
# with_items:
# - { state: "latest", name: "ubuntu-desktop" }
- name: "our build chain deps"
apt: # we assume update_cache was done earlier in book!
name: "{{ item.name }}"
state: "{{ item.state }}"
with_items:
- { state: "latest", name: "clang-format" }
- { state: "latest", name: "clang-tidy" }
- name: "nice-to-have apt stuff"
apt: # we assume update_cache was done earlier in book!
name: "{{ item.name }}"
state: "{{ item.state }}"
with_items:
- { state: "latest", name: "caffeine" }
- { state: "latest", name: "graphviz" }
- { state: "latest", name: "gtk-recordmydesktop" }
- { state: "latest", name: "htop" }
- { state: "latest", name: "imagemagick" }
- { state: "latest", name: "jq" }
- { state: "latest", name: "mediainfo" }
- { state: "latest", name: "source-highlight" }
- { state: "latest", name: "splitpatch" }
- { state: "latest", name: "sqlite" }
- { state: "latest", name: "stress" }
- { state: "latest", name: "tree" }
- { state: "latest", name: "wmctrl" }
- { state: "latest", name: "xclip" }
# (among others?) this is part of endless hist
- name: "Ensure installation directory exists"
file:
path: "{{ repos_install_dir }}"
state: directory
owner: "{{ plain_old_username }}"
group: "{{ plain_old_username }}"
mode: '0755'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment