Skip to content

Instantly share code, notes, and snippets.

@deekayen
Last active September 20, 2019 20:54
Show Gist options
  • Save deekayen/28463145fb957eccc370728601311005 to your computer and use it in GitHub Desktop.
Save deekayen/28463145fb957eccc370728601311005 to your computer and use it in GitHub Desktop.
Parse brew list for the version of currently installed cowsay.
---
- hosts: localhost
connection: local
tasks:
- name: Install cowsay.
homebrew:
name: cowsay
- name: brew list cowsay
command: brew list cowsay
register: cowsay_return
- name: /usr/local/Cellar/cowsay/3.04/INSTALL_RECEIPT.json
debug:
var: cowsay_return.stdout_lines[0]
- name: Look for installed cowsay version number.
set_fact:
version: "{{ cowsay_return.stdout_lines[0] | regex_search('(\\d+\\.\\d+)') }}"
- name: 3.04
debug:
var: version
- name: Install buffalo cow.
get_url:
url: https://gist.githubusercontent.com/deekayen/8a8e3fc22a7a84a35ada9dd9b4703b27/raw/c9515612afa387dc6d4445bace9ebcd0738cad99/buffalo.cow
dest: "/usr/local/Cellar/cowsay/{{ version }}/share/cows/buffalo.cow"
- name: Update local user ansible config to use buffalo.
ini_file:
path: ~/.ansible.cfg
section: defaults
option: cow_selection
value: buffalo
mode: 0644
@deekayen
Copy link
Author

Run this like:

ansible-playbook -i localhost, cowsay.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment