From 72124b3fc1c6112e43aacc47479e8615a131ac97 Mon Sep 17 00:00:00 2001 From: Brian Lee Date: Thu, 25 May 2023 15:53:25 -0700 Subject: [PATCH] New Ansible Role to build and install ntfy-alertmanager. --- .gitignore | 0 LICENSE | 17 +++++++++++++++++ README.md | 21 +++++++++++++++++++++ defaults/main.yml | 2 ++ meta/main.yml | 3 +++ tasks/main.yml | 26 ++++++++++++++++++++++++++ 6 files changed, 69 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 defaults/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4baac1e --- /dev/null +++ b/LICENSE @@ -0,0 +1,17 @@ +MIT No Attribution License + +Copyright (c) 2023 Brian Lee + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..3263e06 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Ansible Role: ntfy-alertmanager + +This Ansible Role installs [ntfy-alertmanager](https://git.xenrox.net/~xenrox/ntfy-alertmanager). + +## Requirements + +* [gantsign.golang](https://github.com/gantsign/ansible-role-golang) + +## Role Variables + +```yaml +ntfy_alertmanager_version: v0.2.0 +``` + +## Example Playbook + +```yaml +- hosts: all + roles: + - role: bleetube.ntfy-alertmanager +``` diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..b442d3c --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,2 @@ +--- +ntfy_alertmanager_version: v0.2.0 \ No newline at end of file diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..08fbcc1 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - gantsign.golang \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..ad85f14 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,26 @@ +--- +- name: Clone git repository + ansible.builtin.git: + repo: https://git.xenrox.net/~xenrox/ntfy-alertmanager + dest: "{{ ansible_env.HOME }}/src/ntfy-alertmanager" + version: "{{ ntfy_alertmanager_version }}" + register: git_repository + +- name: Create the required version.txt file for building ntfy-alertmanager + ansible.builtin.shell: + chdir: "{{ ansible_env.HOME }}/src/ntfy-alertmanager" + cmd: git describe --long > version.txt + when: git_repository.changed + +- name: Build ntfy-alertmanager + ansible.builtin.command: + chdir: "{{ ansible_env.HOME }}/src/ntfy-alertmanager" + cmd: "{{ ansible_local.golang.general.home }}/bin/go build ." + when: git_repository.changed + +- name: Install ntfy-alertmanager binary + ansible.builtin.copy: + remote_src: true + src: "{{ ansible_env.HOME }}/src/ntfy-alertmanager/ntfy-alertmanager" + dest: /usr/local/bin/ + become: true \ No newline at end of file