@installdoc/ansible-gas-station
Version:
An Ansible playbook that provisions your network with software from GitHub Awesome lists, developed with disaster recovery in mind ⛽🔥🤤
49 lines (42 loc) • 1.63 kB
YAML
- name: Ensure Megabyte Labs configuration directory exists
file:
mode: 0700
path: "{{ item }}"
state: directory
loop:
- ~/.config
- ~/.config/megabytelabs
- name: "Check if {{ app_name }} has configuration stored in ~/.config/megabytelabs/tflint"
stat:
path: ~/.config/megabytelabs/tflint
register: tflint_config
- name: "Detect previously installed {{ app_name }} version"
command: cat tflint
args:
chdir: ~/.config/megabytelabs
changed_when: false
register: current_tflint_version
when: tflint_config.stat.exists
- name: "Detect the latest {{ app_name }} version"
uri:
url: https://api.github.com/repos/terraform-linters/tflint/releases/latest
register: tflint_latest_release_tag
- name: "Determine whether or not the latest version of {{ app_name }} is already installed"
set_fact:
install_tflint: "{{ (current_tflint_version.skipped | default(false)) or \
((not current_tflint_version.skipped | default(false)) and (current_tflint_version.stdout != \
tflint_latest_release_tag.json.tag_name | replace('v',''))) }}"
- name: "Ensure {{ app_name }} is installed"
unarchive:
src: "https://github.com/terraform-linters/tflint/releases/download/{{ tflint_latest_release_tag.json.tag_name }}/tflint_linux_amd64.zip"
dest: /usr/local/bin
remote_src: true
when: install_tflint
- name: "Save meta information about the version of {{ app_name }} that was installed"
copy:
dest: ~/.config/megabytelabs/tflint
mode: 0600
content: |
{{ tflint_latest_release_tag.json.tag_name | replace('v','') }}
when: install_tflint