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 all commits
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
1 change: 1 addition & 0 deletions roles/alertmanager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults
| Name | Default Value | Description |
| -------------- | ------------- | -----------------------------------|
| `alertmanager_version` | 0.21.0 | Alertmanager package version. Also accepts `latest` as parameter. |
| `alertmanager_skip_install` | false | Alertmanager installation tasks gets skipped when set to true. |
| `alertmanager_binary_local_dir` | "" | Allows to use local packages instead of ones distributed on github. As parameter it takes a directory where `alertmanager` AND `amtool` binaries are stored on host on which ansible is ran. This overrides `alertmanager_version` parameter |
| `alertmanager_binary_url` | `https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz` | URL of the alertmanager binaries .tar.gz file |
| `alertmanager_checksums_url` | `https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/sha256sums.txt` | URL of the alertmanager checksums file |
Expand Down
1 change: 1 addition & 0 deletions roles/alertmanager/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ alertmanager_binary_local_dir: ''
alertmanager_binary_url: "https://github.com/{{ _alertmanager_repo }}/releases/download/v{{ alertmanager_version }}/\
alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz"
alertmanager_checksums_url: "https://github.com/{{ _alertmanager_repo }}/releases/download/v{{ alertmanager_version }}/sha256sums.txt"
alertmanager_skip_install: false

alertmanager_config_dir: /etc/alertmanager
alertmanager_db_dir: /var/lib/alertmanager
Expand Down
4 changes: 4 additions & 0 deletions roles/alertmanager/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ argument_specs:
alertmanager_version:
description: "Alertmanager package version. Also accepts `latest` as parameter."
default: 0.21.0
alertmanager_skip_install:
description: "Alertmanager installation tasks gets skipped when set to true."
type: bool
default: false
alertmanager_binary_local_dir:
description:
- "Allows to use local packages instead of ones distributed on github."
Expand Down
8 changes: 6 additions & 2 deletions roles/alertmanager/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
- "{{ _alertmanager_amtool_config_dir }}"

- name: Get alertmanager binary
when: alertmanager_binary_local_dir | length == 0
when:
- alertmanager_binary_local_dir | length == 0
- not alertmanager_skip_install
block:

- name: Download alertmanager binary to local folder
Expand Down Expand Up @@ -78,6 +80,8 @@
with_items:
- alertmanager
- amtool
when: alertmanager_binary_local_dir | length > 0
when:
- alertmanager_binary_local_dir | length > 0
- not alertmanager_skip_install
notify:
- restart alertmanager
2 changes: 2 additions & 0 deletions roles/alertmanager/tasks/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
when:
- alertmanager_version == "latest"
- alertmanager_binary_local_dir | length == 0
- not alertmanager_skip_install

- name: Get alertmanager binary checksum
when:
- alertmanager_binary_local_dir | length == 0
- not alertmanager_skip_install
block:
- name: "Get checksum list"
ansible.builtin.set_fact:
Expand Down
1 change: 1 addition & 0 deletions roles/blackbox_exporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults
| Name | Default Value | Description |
| -------------- | ------------- | -----------------------------------|
| `blackbox_exporter_version` | 0.18.0 | Blackbox exporter package version |
| `blackbox_exporter_skip_install` | false | Blackbox exporter installation tasks gets skipped when set to true. |
| `blackbox_exporter_binary_url` | `"https://github.com/prometheus/blackbox_exporter/releases/download/v{{ blackbox_exporter_version }}/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"` | URL of the blackbox exporter binaries .tar.gz file |
| `blackbox_exporter_web_listen_address` | 0.0.0.0:9115 | Address on which blackbox exporter will be listening |
| `blackbox_exporter_cli_flags` | {} | Additional configuration flags passed to blackbox exporter binary at startup |
Expand Down
1 change: 1 addition & 0 deletions roles/blackbox_exporter/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ blackbox_exporter_version: 0.18.0
blackbox_exporter_binary_url: "https://github.com/{{ _blackbox_exporter_repo }}/releases/download/v{{ blackbox_exporter_version }}/\
blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] |
default(ansible_architecture) }}.tar.gz"
blackbox_exporter_skip_install: false

blackbox_exporter_web_listen_address: "0.0.0.0:9115"

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

- name: Propagate blackbox exporter binary
ansible.builtin.copy:
Expand All @@ -36,6 +37,7 @@
mode: 0750
owner: blackbox-exp
group: blackbox-exp
when: not blackbox_exporter_skip_install
notify:
- restart blackbox exporter

Expand Down
2 changes: 1 addition & 1 deletion roles/blackbox_exporter/tasks/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
that: ansible_service_mgr == 'systemd'
msg: "This role only works with systemd"

- name: Install package fact dependencie
- name: Install package fact dependencies
ansible.builtin.package:
name: "{{ _pkg_fact_req }}"
state: present
Expand Down
1 change: 1 addition & 0 deletions roles/mysqld_exporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults
| Name | Default Value | Description |
| -------------- | ------------- | -----------------------------------|
| `mysqld_exporter_version` | 0.14.0 | mysqld exporter package version. Also accepts latest as parameter. |
| `mysqld_exporter_skip_install` | false | mysqld exporter installation tasks gets skipped when set to true. |
| `mysqld_exporter_binary_local_dir` | "" | Enables the use of local packages instead of those distributed on github. The parameter may be set to a directory where the `mysqld_exporter` binary is stored on the host where ansible is run. This overrides the `mysqld_exporter_version` parameter |
| `mysqld_exporter_binary_url` | `https://github.com/prometheus/mysqld_exporter/releases/download/v{{ mysqld_exporter_version }}/mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ go_arch }}.tar.gz` | URL of the mysqld\_exporter binaries .tar.gz file |
| `mysqld_exporter_checksums_url` | `https://github.com/prometheus/mysqld_exporter/releases/download/v{{ mysqld_exporter_version }}/sha256sums.txt` | URL of the mysqld\_exporter checksums file |
Expand Down
1 change: 1 addition & 0 deletions roles/mysqld_exporter/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mysqld_exporter_binary_local_dir: ""
mysqld_exporter_binary_url: "https://github.com/{{ _mysqld_exporter_repo }}/releases/download/v{{ mysqld_exporter_version }}/\
mysqld_exporter-{{ mysqld_exporter_version }}.linux-{{ go_arch }}.tar.gz"
mysqld_exporter_checksums_url: "https://github.com/{{ _mysqld_exporter_repo }}/releases/download/v{{ mysqld_exporter_version }}/sha256sums.txt"
mysqld_exporter_skip_install: false

mysqld_exporter_web_listen_address: "0.0.0.0:9104"
mysqld_exporter_web_telemetry_path: "/metrics"
Expand Down
4 changes: 4 additions & 0 deletions roles/mysqld_exporter/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ argument_specs:
mysqld_exporter_version:
description: "MySQLd exporter package version. Also accepts latest as parameter."
default: "1.1.2"
mysqld_exporter_skip_install:
description: "MySQLd installation tasks gets skipped when set to true."
type: bool
default: false
mysqld_exporter_binary_local_dir:
description:
- "Enables the use of local packages instead of those distributed on github."
Expand Down
8 changes: 6 additions & 2 deletions roles/mysqld_exporter/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
when: mysqld_exporter_system_user != "root"

- name: Discover latest version
when: mysqld_exporter_binary_local_dir | length == 0
when:
- mysqld_exporter_binary_local_dir | length == 0
- not mysqld_exporter_skip_install
block:

- name: Download mysqld_exporter binary to local folder
Expand Down Expand Up @@ -61,5 +63,7 @@
mode: 0755
owner: root
group: root
when: mysqld_exporter_binary_local_dir | length > 0
when:
- mysqld_exporter_binary_local_dir | length > 0
- not mysqld_exporter_skip_install
notify: restart mysqld_exporter
5 changes: 4 additions & 1 deletion roles/mysqld_exporter/tasks/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@
when:
- mysqld_exporter_version == "latest"
- mysqld_exporter_binary_local_dir | length == 0
- not mysqld_exporter_skip_install

- name: Get mysqld_exporter binary checksum
when: mysqld_exporter_binary_local_dir | length == 0
when:
- mysqld_exporter_binary_local_dir | length == 0
- not mysqld_exporter_skip_install
block:
- name: Get checksum list from github
ansible.builtin.set_fact:
Expand Down
1 change: 1 addition & 0 deletions roles/node_exporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults
| Name | Default Value | Description |
| -------------- | ------------- | -----------------------------------|
| `node_exporter_version` | 1.1.2 | Node exporter package version. Also accepts `latest` as parameter. |
| `node_exporter_skip_install` | false | Node exporter installation tasks gets skipped when set to true. |
| `node_exporter_binary_local_dir` | "" | Enables the use of local packages instead of those distributed on github. The parameter may be set to a directory where the `node_exporter` binary is stored on the host where ansible is run. This overrides the `node_exporter_version` parameter |
| `node_exporter_binary_url` | `https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz` | URL of the node exporter binaries .tar.gz file |
| `node_exporter_checksums_url` | `https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/sha256sums.txt` | URL of the node exporter checksums file |
Expand Down
1 change: 1 addition & 0 deletions roles/node_exporter/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_exporter_binary_local_dir: ""
node_exporter_binary_url: "https://github.com/{{ _node_exporter_repo }}/releases/download/v{{ node_exporter_version }}/\
node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
node_exporter_checksums_url: "https://github.com/{{ _node_exporter_repo }}/releases/download/v{{ node_exporter_version }}/sha256sums.txt"
node_exporter_skip_install: false

node_exporter_web_listen_address: "0.0.0.0:9100"
node_exporter_web_telemetry_path: "/metrics"
Expand Down
4 changes: 4 additions & 0 deletions roles/node_exporter/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ argument_specs:
node_exporter_version:
description: "Node exporter package version. Also accepts latest as parameter."
default: "1.1.2"
node_exporter_skip_install:
description: "Node exporter installation tasks gets skipped when set to true."
type: bool
default: false
node_exporter_binary_local_dir:
description:
- "Enables the use of local packages instead of those distributed on github."
Expand Down
8 changes: 6 additions & 2 deletions roles/node_exporter/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
when: node_exporter_system_user != "root"

- name: Discover latest version
when: node_exporter_binary_local_dir | length == 0
when:
- node_exporter_binary_local_dir | length == 0
- not node_exporter_skip_install
block:

- name: Download node_exporter binary to local folder
Expand Down Expand Up @@ -61,5 +63,7 @@
mode: 0755
owner: root
group: root
when: node_exporter_binary_local_dir | length > 0
when:
- node_exporter_binary_local_dir | length > 0
- not node_exporter_skip_install
notify: restart node_exporter
5 changes: 4 additions & 1 deletion roles/node_exporter/tasks/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@
when:
- node_exporter_version == "latest"
- node_exporter_binary_local_dir | length == 0
- not node_exporter_skip_install

- name: Get node_exporter binary checksum
when: node_exporter_binary_local_dir | length == 0
when:
- node_exporter_binary_local_dir | length == 0
- not node_exporter_skip_install
block:
- name: Get checksum list from github
ansible.builtin.set_fact:
Expand Down
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
1 change: 1 addition & 0 deletions roles/systemd_exporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults
| Name | Default Value | Description |
| -------------- | ------------- | -----------------------------------|
| `systemd_exporter_version` | 0.4.0 | SystemD exporter package version. Also accepts latest as parameter. |
| `systemd_exporter_skip_install` | false | SystemD exporter installation tasks gets skipped when set to true. |
| `systemd_exporter_binary_local_dir` | "" | Allows to use local packages instead of ones distributed on github. As parameter it takes a directory where `systemd_exporter` binary is stored on host on which ansible is ran. This overrides `systemd_exporter_version` parameter |
| `systemd_exporter_binary_url` | `https://github.com/prometheus-community/systemd_exporter/releases/download/v{{ systemd_exporter_version }}/systemd_exporter-{{ systemd_exporter_version }}.linux-{{ go_arch }}.tar.gz` | URL of the systemd exporter binaries .tar.gz file |
| `systemd_exporter_checksums_url` | `https://github.com/prometheus-community/systemd_exporter/releases/download/v{{ systemd_exporter_version }}/sha256sums.txt` | URL of the systemd exporter checksums file |
Expand Down
1 change: 1 addition & 0 deletions roles/systemd_exporter/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ systemd_exporter_binary_local_dir: ""
systemd_exporter_binary_url: "https://github.com/{{ _systemd_exporter_repo }}/releases/download/v{{ systemd_exporter_version }}/\
systemd_exporter-{{ systemd_exporter_version }}.linux-{{ go_arch }}.tar.gz"
systemd_exporter_checksums_url: "https://github.com/{{ _systemd_exporter_repo }}/releases/download/v{{ systemd_exporter_version }}/sha256sums.txt"
systemd_exporter_skip_install: false
systemd_exporter_web_listen_address: "0.0.0.0:9558"

systemd_exporter_enable_restart_count: false
Expand Down
4 changes: 4 additions & 0 deletions roles/systemd_exporter/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ argument_specs:
systemd_exporter_version:
description: "SystemD exporter package version. Also accepts latest as parameter."
default: "0.4.0"
systemd_exporter_skip_install:
description: "SystemD exporter installation tasks gets skipped when set to true."
type: bool
default: false
systemd_exporter_binary_local_dir:
description:
- "Allows to use local packages instead of ones distributed on github."
Expand Down
8 changes: 6 additions & 2 deletions roles/systemd_exporter/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
when: systemd_exporter_system_user != "root"

- name: Get systemd exporter binary
when: systemd_exporter_binary_local_dir | length == 0
when:
- systemd_exporter_binary_local_dir | length == 0
- not systemd_exporter_skip_install
block:
- name: Download systemd_exporter binary to local folder
become: false
Expand Down Expand Up @@ -60,5 +62,7 @@
mode: 0755
owner: root
group: root
when: systemd_exporter_binary_local_dir | length > 0
when:
- systemd_exporter_binary_local_dir | length > 0
- not systemd_exporter_skip_install
notify: restart systemd_exporter
5 changes: 4 additions & 1 deletion roles/systemd_exporter/tasks/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@
when:
- systemd_exporter_version == "latest"
- systemd_exporter_binary_local_dir | length == 0
- not systemd_exporter_skip_install

- name: Get systemd exporter binary checksum
when: systemd_exporter_binary_local_dir | length == 0
when:
- systemd_exporter_binary_local_dir | length == 0
- not systemd_exporter_skip_install
block:
- name: Get checksum list from github
ansible.builtin.set_fact:
Expand Down