Files
configpolicy/roles/vmagent/tasks/deploy.yml
Dustin C. Hatch 3e8ac36f88 r/vmagent: Rework as container deployment
Like the _blackbox-exporter_ role, the _vmagent_ role now deploys
`vmagent` as a container.  This simplifies the process considerably,
eliminating the download/transfer step.

While refactoring this role, I also changed how the trusted CA
certificates are handled.  Rather than copy files, the role now expects
a `vmagent_ca_certs` variable.  This variable is a mapping of
certificate name (file name without extension) to PEM contents.  This
allows certificates to be defined using normal host/group variables.
2025-01-26 13:08:59 -06:00

94 lines
1.9 KiB
YAML

- name: ensure vmagent container image is present
podman_image:
name: '{{ vmagent_container_image_name }}'
tag: '{{ vmagent_container_image_tag }}'
state: present
pull: '{{ vmagent_pull_image|d(false)|bool }}'
notify:
- restart vmagent
tags:
- container-image
- name: ensure vmagent system container is configured
template:
src: vmagent.container.j2
dest: /etc/containers/systemd/vmagent.container
owner: root
group: root
mode: u=rw,go=r
notify:
- reload systemd
- restart vmagent
tags:
- container
- systemd
- 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 additional ca certificates are installed
copy:
content: '{{ item.1 }}'
dest: /etc/victoria-metrics/{{ item.0 }}.crt
mode: u=rw,go=r
owner: root
group: root
loop: '{{ vmagent_ca_certs|dictsort }}'
notify:
- reload vmagent
tags:
- cert
- scrape-config
- name: flush handlers
meta: flush_handlers
- 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