Last active
September 20, 2019 20:54
-
-
Save deekayen/28463145fb957eccc370728601311005 to your computer and use it in GitHub Desktop.
Parse brew list for the version of currently installed cowsay.
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
--- | |
- 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run this like:
ansible-playbook -i localhost, cowsay.yml