Last active
March 4, 2019 20:15
-
-
Save jlaska/14bc829af01526add07efcaa83582aaf to your computer and use it in GitHub Desktop.
Holiday Themed Ansible Cows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[defaults] | |
cow_selection = random | |
cow_whitelist = ansible_lights,ansible_reindeer,ansible_tree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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 }}"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$the_cow = <<"EOC"; | |
.--._.--.---._.--.---._.--.---._.--.---._.-._.--._.-- | |
_(A)_ _(A)_ _(A)_ _(A)_ _(A)_ _(A)_ | |
[___] [___] [___] [___] [___] [___] | |
/:' \\ /:' \\ /:' \\ /:' \\ /:' \\ /:' \\ | |
|:: | |:: | |:: | |:: | |:: | |:: | | |
\\::. / \\::. / \\::. / \\::. / \\::. / \\::. / | |
\\::./ \\::./ \\::./ \\::./ \\::./ \\::./ | |
'=' '=' '=' '=' '=' '=' | |
EOC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$the_cow = <<"EOC"; | |
$thoughts | |
|\\ . . /| | |
._\\\\/ \\//_. | |
',\\_, ,_/,' | |
\\.' './ | |
_\\\\/ \\//_ | |
'-.\\, ,/.-' | |
\\\\ // | |
_.-`"""`-._ | |
,-'-' _ _ '-'-, | |
'--\\ o o /'-' | |
| | | |
/ \\ | |
| (A) | | |
\\ _|_ / | |
'---' | |
EOC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$the_cow = <<"EOC"; | |
. . . * . . . | |
. . . # . . | |
. . ##"(A)"## . . | |
. . "#:. .:##"##:. .:#" . . | |
. . "####"(A)"####" . | |
. "#:. .:#"###"#:. .:#" . . | |
. "###"(A)"######"(A)"###" . . | |
. "#:. "####"(A)"####" .:#" . . | |
. . "#######""##"##""#######" | |
."##"#"(A)"#####"(A)"#"##" . | |
. "#:. ... .:##"###"###"##:. ... .:#" . | |
. "###"(A)"##"##"(A)"#"##"##"(A)"###" . | |
. . "#####""#######""#####" . . | |
. " 000 " . . | |
. . . 000 . . . | |
.. .. ..................O000O.................. .. .. | |
EOC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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