r/vmagent: Deploy vmagent
The *vmagent* role installs and configures the scraping and routing agent used in the Victoria Metrics ecosystem.
This commit is contained in:
62
roles/vmagent/tasks/deploy.yml
Normal file
62
roles/vmagent/tasks/deploy.yml
Normal file
@@ -0,0 +1,62 @@
|
||||
- name: ensure victoria metrics user exists
|
||||
user:
|
||||
name: victoriametrics
|
||||
system: true
|
||||
home: /var/lib/victoria-metrics
|
||||
createhome: false
|
||||
shell: /sbin/nologin
|
||||
state: present
|
||||
tags:
|
||||
- user
|
||||
|
||||
- name: ensure /etc/sysconfig directory exists
|
||||
file:
|
||||
path: /etc/sysconfig
|
||||
mode: u=rwx,go=rx
|
||||
owner: root
|
||||
group: root
|
||||
state: directory
|
||||
tags:
|
||||
- config
|
||||
- name: ensure vmagent is configured
|
||||
template:
|
||||
src: vmagent.sysconfig.j2
|
||||
dest: /etc/sysconfig/vmagent
|
||||
mode: '0644'
|
||||
notify:
|
||||
- restart vmagent
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: ensure victoria metrics config directory exists
|
||||
file:
|
||||
path: /etc/victoria-metrics
|
||||
mode: '0755'
|
||||
state: directory
|
||||
tags:
|
||||
- config
|
||||
- name: ensure vmagent scrape configuration is set
|
||||
copy:
|
||||
dest: /etc/victoria-metrics/scrape.yml
|
||||
content: '{{ vmagent_config|to_nice_yaml(indent=2) }}'
|
||||
mode: '0644'
|
||||
notify:
|
||||
- reload vmagent
|
||||
tags:
|
||||
- config
|
||||
- scrape-config
|
||||
|
||||
- name: ensure vmagent starts at boot
|
||||
service:
|
||||
name: vmagent
|
||||
enabled: true
|
||||
tags:
|
||||
- service
|
||||
- systemd
|
||||
- name: ensure vmagent is running
|
||||
service:
|
||||
name: vmagent
|
||||
state: started
|
||||
tags:
|
||||
- service
|
||||
- systemd
|
||||
11
roles/vmagent/tasks/install.yml
Normal file
11
roles/vmagent/tasks/install.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
- name: ensure vmagent systemd unit is installed
|
||||
copy:
|
||||
src: vmagent.service
|
||||
dest: /etc/systemd/system/vmagent.service
|
||||
mode: '0644'
|
||||
notify:
|
||||
- reload systemd
|
||||
- restart vmagent
|
||||
tags:
|
||||
- service
|
||||
- systemd
|
||||
7
roles/vmagent/tasks/main.yml
Normal file
7
roles/vmagent/tasks/main.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
- block:
|
||||
- import_tasks: install.yml
|
||||
tags:
|
||||
- install
|
||||
- import_tasks: deploy.yml
|
||||
tags:
|
||||
- vmagent
|
||||
Reference in New Issue
Block a user