Skip to content

Commit

Permalink
feat(vmagent): allow for additional CLI flags in systemd definition
Browse files Browse the repository at this point in the history
  • Loading branch information
meysam81 committed Oct 31, 2024
1 parent 0c22d12 commit 5366058
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## [1.5.2] - 2024-10-31

### ⚙️ Miscellaneous Tasks

- *(vmagent)* Add optional labels

## [1.5.1] - 2024-10-28

### 🐛 Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace: meysam81
name: general
version: 1.5.2
version: 1.5.3
readme: README.md
authors:
- Meysam Azad <[email protected]>
Expand Down
30 changes: 28 additions & 2 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@
tasks:
- name: Ping
ansible.builtin.ping:
- name: Copy relabling config
ansible.builtin.copy:
content: |
- source_labels:
- exported_job
action: replace
target_label: job
regex: (.+)
- source_labels:
- exported_instance
action: replace
target_label: instance
regex: (.+)
dest: /etc/vmagent/relablings.yml
owner: vmagent
group: vmagent
mode: "0644"
notify: Restart vmagent service
tags: vmagent
- name: Ensure vmagent.service is running

Check failure on line 28 in molecule/default/converge.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

fqcn[action-core]

Use FQCN for builtin module actions (command).

Check failure on line 28 in molecule/default/converge.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

fqcn[action-core]

Use FQCN for builtin module actions (command).
command: systemctl status vmagent
register: vmagent_service_status
changed_when: false
tags: vmagent
roles:
- role: haproxy
tags: haproxy
Expand All @@ -14,10 +38,12 @@
- role: vmagent
tags: vmagent
vars:
vmagent_remote_write_url: "{{ lookup('env', 'VMAGENT_REMOTE_WRITE_URL') | default('http://localhost:8428/api/v1/write') }}"
vmagent_remote_write_url: "{{ lookup('env', 'VMAGENT_REMOTE_WRITE_URL') | default('http://localhost:8428/api/v1/write', true) }}"
vmagent_extra_cli_flags:
- -remoteWrite.urlRelabelConfig=/etc/vmagent/relablings.yml
- role: promtail
tags: promtail
vars:
promtail_remote_write_url: "{{ lookup('env', 'PROMTAIL_REMOTE_WRITE_URL') | default('http://localhost:3100/loki/api/v1/push') }}"
promtail_remote_write_url: "{{ lookup('env', 'PROMTAIL_REMOTE_WRITE_URL') | default('http://localhost:3100/loki/api/v1/push', true) }}"
- role: pushgateway
tags: pushgateway
9 changes: 9 additions & 0 deletions roles/vmagent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Install vmagent from GitHub release
- [vmagent_arch](#vmagent_arch)
- [vmagent_bin](#vmagent_bin)
- [vmagent_docker_enabled](#vmagent_docker_enabled)
- [vmagent_extra_cli_flags](#vmagent_extra_cli_flags)
- [vmagent_extra_labels](#vmagent_extra_labels)
- [vmagent_fail2ban_enabled](#vmagent_fail2ban_enabled)
- [vmagent_group](#vmagent_group)
Expand Down Expand Up @@ -65,6 +66,14 @@ vmagent_bin: /usr/local/bin/vmagent-prod
vmagent_docker_enabled: false
```
### vmagent_extra_cli_flags
#### Default value
```YAML
vmagent_extra_cli_flags: []
```
### vmagent_extra_labels
#### Default value
Expand Down
1 change: 1 addition & 0 deletions roles/vmagent/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
vmagent_arch: "{{ (ansible_architecture | default('amd64')) | replace('x86_64', 'amd64') | replace('aarch64', 'arm64') }}"
vmagent_bin: /usr/local/bin/vmagent-prod
vmagent_docker_enabled: false
vmagent_extra_cli_flags: []
vmagent_extra_labels: {}
vmagent_fail2ban_enabled: false
vmagent_group: vmagent
Expand Down
3 changes: 3 additions & 0 deletions roles/vmagent/templates/vmagent.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ ExecStart={{ vmagent_bin }} \
{% endif %}
{% for key, value in vmagent_extra_labels.items() %}
-remoteWrite.label={{ key }}={{ value }} \
{% endfor %}
{% for cli_flag in vmagent_extra_cli_flags %}
{{ cli_flag }} \
{% endfor %}
-httpListenAddr={{ vmagent_http_listen_addr }} \
-influxListenAddr=""
Expand Down

0 comments on commit 5366058

Please sign in to comment.