Skip to content

Instantly share code, notes, and snippets.

@jlaska
Last active March 4, 2019 20:15
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlaska/14bc829af01526add07efcaa83582aaf to your computer and use it in GitHub Desktop.
Save jlaska/14bc829af01526add07efcaa83582aaf to your computer and use it in GitHub Desktop.
Holiday Themed Ansible Cows
[defaults]
cow_selection = random
cow_whitelist = ansible_lights,ansible_reindeer,ansible_tree
- name: "Install Ansible Holiday Themed Cows"
hosts: localhost
gather_facts: true
vars:
barn: "{{ lookup('env', 'HOME') }}/.cowsay"
pasture_cfg: "{{ lookup('env', 'HOME') }}/.bashrc"
ansible_cfg: 'https://gist.githubusercontent.com/jlaska/14bc829af01526add07efcaa83582aaf/raw/313ec9e621f0122c2b9b7721b2b566a0313eb350/.ansible.cfg'
cow_breeds:
- 'https://gist.githubusercontent.com/jlaska/14bc829af01526add07efcaa83582aaf/raw/bba72b3333bd2196af2175ae84918d5833d18b02/ansible_lights.cow'
- 'https://gist.githubusercontent.com/jlaska/14bc829af01526add07efcaa83582aaf/raw/bba72b3333bd2196af2175ae84918d5833d18b02/ansible_reindeer.cow'
- 'https://gist.githubusercontent.com/jlaska/14bc829af01526add07efcaa83582aaf/raw/bba72b3333bd2196af2175ae84918d5833d18b02/ansible_tree.cow'
tasks:
- name: 'Build the barn for the cows'
file:
state: 'directory'
path: '{{ barn }}'
mode: 0750
- name: 'Corral the cows into the barn'
get_url:
url: '{{ item }}'
dest: '{{ barn }}'
with_items: '{{ cow_breeds }}'
- name: 'Install cowsay'
package:
name: 'cowsay'
state: present
- name: 'Brand the cows'
get_url:
url: '{{ ansible_cfg }}'
dest: "{{ lookup('env', 'HOME') }}"
mode: 0640
- name: 'Configure the pasture'
lineinfile:
dest: '{{ pasture_cfg }}'
regexp: '^export COWPATH=.*'
line: 'export COWPATH="{{ barn }}"'
$the_cow = <<"EOC";
.--._.--.---._.--.---._.--.---._.--.---._.-._.--._.--
_(A)_ _(A)_ _(A)_ _(A)_ _(A)_ _(A)_
[___] [___] [___] [___] [___] [___]
/:' \\ /:' \\ /:' \\ /:' \\ /:' \\ /:' \\
|:: | |:: | |:: | |:: | |:: | |:: |
\\::. / \\::. / \\::. / \\::. / \\::. / \\::. /
\\::./ \\::./ \\::./ \\::./ \\::./ \\::./
'=' '=' '=' '=' '=' '='
EOC
$the_cow = <<"EOC";
$thoughts
|\\ . . /|
._\\\\/ \\//_.
',\\_, ,_/,'
\\.' './
_\\\\/ \\//_
'-.\\, ,/.-'
\\\\ //
_.-`"""`-._
,-'-' _ _ '-'-,
'--\\ o o /'-'
| |
/ \\
| (A) |
\\ _|_ /
'---'
EOC
$the_cow = <<"EOC";
. . . * . . .
. . . # . .
. . ##"(A)"## . .
. . "#:. .:##"##:. .:#" . .
. . "####"(A)"####" .
. "#:. .:#"###"#:. .:#" . .
. "###"(A)"######"(A)"###" . .
. "#:. "####"(A)"####" .:#" . .
. . "#######""##"##""#######"
."##"#"(A)"#####"(A)"#"##" .
. "#:. ... .:##"###"###"##:. ... .:#" .
. "###"(A)"##"##"(A)"#"##"##"(A)"###" .
. . "#####""#######""#####" . .
. " 000 " . .
. . . 000 . . .
.. .. ..................O000O.................. .. ..
EOC
#!/usr/bin/env bash
is_ansible_installed() {
type -p ansible-playbook > /dev/null
}
is_ansible_installed
if [ $? -ne 0 ]; then
echo "Please install ansible before proceeding"
exit 1
fi
# Download the playbook
curl --silent -O "https://gist.githubusercontent.com/jlaska/14bc829af01526add07efcaa83582aaf/raw/017ed110d08a2bdc212607d711759f022f19c0b5/ansible_holiday_cowsay.yml"
# Run the playbook
ansible-playbook -i localhost, -c local ansible_holiday_cowsay.yml
# Remove the playbook
rm -f ansible_holiday_cowsay.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment