Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: add skip_install variables to various roles #74

Merged
merged 6 commits into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
enhancement(snmp_exporter): add skip_install variable
This is similar to prometheus_skip_install variable and does what the
name says: when set, it won't try to re-download the snmp exporter
binary

Signed-off-by: Christian Brabandt <cb@256bit.org>
  • Loading branch information
chrisbra committed Mar 21, 2023
commit 6dc879d5f558804ef75c22bb12ff4c6093aef8dd
1 change: 1 addition & 0 deletions roles/snmp_exporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults
| Name | Default Value | Description |
| -------------- | ------------- | -----------------------------------|
| `snmp_exporter_version` | 0.19.0 | SNMP exporter package version |
| `snmp_exporter_skip_install` | false | SNMP exporter installation tasks gets skipped when set to true. |
| `snmp_exporter_binary_url` | `https://github.com/prometheus/snmp_exporter/releases/download/v{{ snmp_exporter_version }}/snmp_exporter-{{ snmp_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz` | URL of the snmp exporter binaries .tar.gz file |
| `snmp_exporter_checksums_url` | `https://github.com/prometheus/snmp_exporter/releases/download/v{{ snmp_exporter_version }}/sha256sums.txt` | URL of the snmp exporter checksums file |
| `snmp_exporter_web_listen_address` | "0.0.0.0:9116" | Address on which SNMP exporter will be listening |
Expand Down
1 change: 1 addition & 0 deletions roles/snmp_exporter/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ snmp_exporter_version: 0.19.0
snmp_exporter_binary_url: "https://github.com/{{ _snmp_exporter_repo }}/releases/download/v{{ snmp_exporter_version }}/\
snmp_exporter-{{ snmp_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
snmp_exporter_checksums_url: "https://github.com/{{ _snmp_exporter_repo }}/releases/download/v{{ snmp_exporter_version }}/sha256sums.txt"
snmp_exporter_skip_install: false
snmp_exporter_web_listen_address: "0.0.0.0:9116"
snmp_exporter_log_level: info

Expand Down
4 changes: 4 additions & 0 deletions roles/snmp_exporter/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ argument_specs:
snmp_exporter_version:
description: "SNMP exporter package version"
default: "0.19.0"
snmp_exporter_skip_install:
description: "SNMP exporter installation tasks gets skipped when set to true."
type: bool
default: false
snmp_exporter_binary_url:
description: "URL of the snmp exporter binaries .tar.gz file"
default: "https://github.com/{{ _snmp_exporter_repo }}/releases/download/v{{ snmp_exporter_version }}/snmp_exporter-{{ snmp_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
Expand Down
3 changes: 3 additions & 0 deletions roles/snmp_exporter/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
delay: 2
delegate_to: localhost
check_mode: false
when: not snmp_exporter_skip_install

- name: Unpack snmp_exporter binary
become: false
Expand All @@ -21,12 +22,14 @@
creates: "/tmp/snmp_exporter-{{ snmp_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/snmp_exporter"
delegate_to: localhost
check_mode: false
when: not snmp_exporter_skip_install

- name: Propagate SNMP Exporter binaries
ansible.builtin.copy:
src: "/tmp/snmp_exporter-{{ snmp_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/snmp_exporter"
dest: "/usr/local/bin/snmp_exporter"
mode: 0755
when: not snmp_exporter_skip_install
notify:
- restart snmp exporter

Expand Down
4 changes: 3 additions & 1 deletion roles/snmp_exporter/tasks/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
snmp_exporter_checksum: "{{ item.split(' ')[0] }}"
with_items:
- "{{ lookup('url', snmp_exporter_checksums_url, wantlist=True) | list }}"
when: "('linux-' + (go_arch_map[ansible_architecture] | default(ansible_architecture)) + '.tar.gz') in item"
when:
- "('linux-' + (go_arch_map[ansible_architecture] | default(ansible_architecture)) + '.tar.gz') in item"
- not snmp_exporter_skip_install