๐Ÿ“— Ansible playbooks and roles for building an idempotent, interconnected and scalable infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible-playbooks/roles/strongswan/tasks/prometheus.yml

65 lines
1.5 KiB

2 years ago
- name: set strongswan exporter config
set_fact:
strongswan_exporter_cfg: "{{ strongswan_exporter_default_config | d({}) | combine(strongswan_exporter_config | d({}), recursive=true) }}"
- name: create strongswan exporter directory
file:
path: "{{ strongswan_exporter_dir }}"
state: directory
owner: "{{ strongswan_user }}"
group: "{{ strongswan_group }}"
- name: get and extract latest version of strongswan exporter
include_tasks: tasks/get_lastversion.yml
vars:
package:
name: sergeymakinen/ipsec_exporter
location: github
prerelease: yes
assets: yes
asset_filter: '.linux_amd64.tar.gz$'
file: "{{ strongswan_exporter_dir }}/last_version"
extract: "{{ strongswan_exporter_dir }}"
user: "{{ strongswan_user }}"
group: "{{ strongswan_group }}"
notify: restart strongswan exporter
- name: ensure strongswan exporter has executable bit set
file:
path: "{{ strongswan_exporter_dir }}/ipsec_exporter"
mode: "+x"
- name: template init script
template:
src: init_exporter.j2
dest: /etc/init.d/strongswan_exporter
force: yes
mode: 0755
notify: restart strongswan exporter
- name: add prometheus metric target
include_role:
name: prometheus
vars:
function: add_target
target:
name: strongswan
scheme: http
port: "{{ strongswan_prometheus_port }}"
- name: flush handlers
meta: flush_handlers
- name: enable and start strongswan exporter
service:
name: strongswan_exporter
enabled: yes
state: started