Import the old role.
This commit is contained in:
parent
c6d5a24cc1
commit
527ce7850e
31
README.md
31
README.md
|
@ -1,31 +1,26 @@
|
||||||
Role Name
|
Role Name
|
||||||
=========
|
=========
|
||||||
|
|
||||||
A brief description of the role goes here.
|
A role that installs the Prometheus open-source systems monitoring and alerting toolkit, <https://prometheus.io>
|
||||||
|
|
||||||
Requirements
|
|
||||||
------------
|
|
||||||
|
|
||||||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
|
||||||
|
|
||||||
Role Variables
|
Role Variables
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
The most important variables are listed below:
|
||||||
|
|
||||||
|
``` yaml
|
||||||
|
prometheus_install: True
|
||||||
|
prometheus_version: 2.19.2
|
||||||
|
prometheus_loglevel: info
|
||||||
|
prometheus_http_port: 9090
|
||||||
|
prometheus_opts: '--storage.tsdb.retention=360d'
|
||||||
|
```
|
||||||
|
|
||||||
Dependencies
|
Dependencies
|
||||||
------------
|
------------
|
||||||
|
|
||||||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
* nginx
|
||||||
|
* letsencrypt-acme-sh-client
|
||||||
Example Playbook
|
|
||||||
----------------
|
|
||||||
|
|
||||||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
|
||||||
|
|
||||||
- hosts: servers
|
|
||||||
roles:
|
|
||||||
- { role: username.rolename, x: 42 }
|
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
@ -35,4 +30,4 @@ EUPL-1.2
|
||||||
Author Information
|
Author Information
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
Andrea Dell'Amico, <andrea.dellamico@isti.cnr.it>
|
||||||
|
|
|
@ -1,2 +1,11 @@
|
||||||
---
|
---
|
||||||
# defaults file for ansible-role-template
|
prometheus_install: True
|
||||||
|
prometheus_version: 2.19.2
|
||||||
|
prometheus_user: prometheus
|
||||||
|
prometheus_home: /opt/prometheus
|
||||||
|
prometheus_dist_dir: '{{ prometheus_home }}/dist'
|
||||||
|
prometheus_confdir: '/opt/prometheus/conf'
|
||||||
|
prometheus_cmd: '{{ prometheus_dist_dir }}/{{ prometheus_dir }}/prometheus'
|
||||||
|
prometheus_loglevel: info
|
||||||
|
prometheus_http_port: 9090
|
||||||
|
prometheus_opts: '--storage.tsdb.retention=360d'
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
---
|
---
|
||||||
# handlers file for ansible-role-template
|
- name: Restart prometheus
|
||||||
|
service: name=prometheus state=restarted
|
||||||
|
|
||||||
|
- name: Reload prometheus
|
||||||
|
service: name=prometheus state=reloaded
|
||||||
|
|
|
@ -1,61 +1,38 @@
|
||||||
galaxy_info:
|
galaxy_info:
|
||||||
author: your name
|
author: Andrea Dell'Amico
|
||||||
description: your description
|
description: Systems Architect
|
||||||
company: ISTI-CNR
|
company: ISTI-CNR
|
||||||
|
|
||||||
# If the issue tracker for your role is not on github, uncomment the
|
|
||||||
# next line and provide a value
|
|
||||||
issue_tracker_url: https://redmine-s2i2s.isti.cnr.it/projects/provisioning
|
issue_tracker_url: https://redmine-s2i2s.isti.cnr.it/projects/provisioning
|
||||||
|
|
||||||
# Some suggested licenses:
|
license: EUPL 1.2+
|
||||||
# - BSD (default)
|
|
||||||
# - MIT
|
|
||||||
# - GPLv2
|
|
||||||
# - GPLv3
|
|
||||||
# - Apache
|
|
||||||
# - CC-BY
|
|
||||||
license: EUPL-1.2
|
|
||||||
|
|
||||||
min_ansible_version: 2.8
|
min_ansible_version: 2.8
|
||||||
|
|
||||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
|
||||||
# min_ansible_container_version:
|
|
||||||
|
|
||||||
# Optionally specify the branch Galaxy will use when accessing the GitHub
|
|
||||||
# repo for this role. During role install, if no tags are available,
|
|
||||||
# Galaxy will use this branch. During import Galaxy will access files on
|
|
||||||
# this branch. If Travis integration is configured, only notifications for this
|
|
||||||
# branch will be accepted. Otherwise, in all cases, the repo's default branch
|
|
||||||
# (usually master) will be used.
|
|
||||||
#github_branch:
|
|
||||||
|
|
||||||
#
|
|
||||||
# Provide a list of supported platforms, and for each platform a list of versions.
|
|
||||||
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
|
||||||
# To view available platforms and versions (or releases), visit:
|
# To view available platforms and versions (or releases), visit:
|
||||||
# https://galaxy.ansible.com/api/v1/platforms/
|
# https://galaxy.ansible.com/api/v1/platforms/
|
||||||
#
|
#
|
||||||
# platforms:
|
platforms:
|
||||||
# - name: Fedora
|
- name: Ubuntu
|
||||||
# versions:
|
versions:
|
||||||
# - all
|
- bionic
|
||||||
# - 25
|
- name: EL
|
||||||
# - name: SomePlatform
|
versions:
|
||||||
# versions:
|
- 7
|
||||||
# - all
|
- 8
|
||||||
# - 1.0
|
|
||||||
# - 7
|
|
||||||
# - 99.99
|
|
||||||
|
|
||||||
galaxy_tags: []
|
galaxy_tags:
|
||||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
- monitoring
|
||||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
- alerting
|
||||||
# remove the '[]' above, if you add tags to this list.
|
- metrics
|
||||||
#
|
|
||||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
|
||||||
# Maximum 20 tags per role.
|
|
||||||
|
|
||||||
dependencies: []
|
dependencies:
|
||||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
- src: git+https://gitea-s2i2s.isti.cnr.it/ISTI-ansible-roles/ansible-role-nginx.git
|
||||||
# if you add dependencies to this list.
|
version: master
|
||||||
|
name: nginx
|
||||||
|
state: latest
|
||||||
|
- src: git+https://gitea-s2i2s.isti.cnr.it/ISTI-ansible-roles/ansible-role-letsencrypt-acme-sh-client.git
|
||||||
|
version: master
|
||||||
|
name: letsencrypt-acme-sh-client
|
||||||
|
state: latest
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,60 @@
|
||||||
---
|
---
|
||||||
# tasks file for ansible-role-template
|
- block:
|
||||||
|
- name: Create the user under prometheus will run
|
||||||
|
user: name={{ prometheus_user }} home={{ prometheus_home }} createhome=no shell=/usr/sbin/nologin system=yes
|
||||||
|
|
||||||
|
- name: Create the prometheus server base and conf directories
|
||||||
|
file: dest={{ item }} state=directory owner=root group=root
|
||||||
|
with_items:
|
||||||
|
- '{{ prometheus_home }}'
|
||||||
|
- '{{ prometheus_confdir }}'
|
||||||
|
- '{{ prometheus_dist_dir }}'
|
||||||
|
|
||||||
|
- name: Create the prometheus directory structure
|
||||||
|
file: dest={{ prometheus_home }}/{{ item }} state=directory owner={{ prometheus_user }} group={{ prometheus_user }}
|
||||||
|
with_items:
|
||||||
|
- data
|
||||||
|
- logs
|
||||||
|
|
||||||
|
- name: Download prometheus
|
||||||
|
get_url: url={{ prometheus_download_url }} dest=/srv/
|
||||||
|
|
||||||
|
- name: Unarchive the prometheus distribution
|
||||||
|
unarchive: src=/srv/{{ prometheus_file }} dest={{ prometheus_dist_dir }} remote_src=yes
|
||||||
|
args:
|
||||||
|
creates: '{{ prometheus_dist_dir }}/{{ prometheus_dir }}/prometheus'
|
||||||
|
notify: Restart prometheus
|
||||||
|
|
||||||
|
- name: Install the prometheus configuration
|
||||||
|
template: src=prometheus.yml.j2 dest={{ prometheus_confdir }}/prometheus.yml force=no
|
||||||
|
notify: Reload prometheus
|
||||||
|
|
||||||
|
- name: Install the prometheus defaults
|
||||||
|
template: src=prometheus.default.j2 dest=/etc/default/prometheus mode=0644 owner=root group=root
|
||||||
|
|
||||||
|
- name: Install the prometheus server systemd unit
|
||||||
|
template: src=prometheus.service.j2 dest=/etc/systemd/system/prometheus.service mode=0644 owner=root group=root
|
||||||
|
register: systemd_reload_required
|
||||||
|
|
||||||
|
- name: Reload the systemd data
|
||||||
|
systemd: daemon_reload=yes
|
||||||
|
when: systemd_reload_required is changed
|
||||||
|
|
||||||
|
- name: Ensure that prometheus is started and enabled
|
||||||
|
service: name=prometheus state=started enabled=yes
|
||||||
|
|
||||||
|
tags: prometheus
|
||||||
|
when: prometheus_install
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Ensure that prometheus is stopped and disabled
|
||||||
|
service: name=prometheus state=stopped enabled=no
|
||||||
|
|
||||||
|
- name: Remove the prometheus init script
|
||||||
|
file: dest=/etc/init/prometheus.conf state=absent
|
||||||
|
|
||||||
|
- name: Remove all the prometheus files
|
||||||
|
file: dest={{ prometheus_home }} state=absent
|
||||||
|
|
||||||
|
tags: prometheus
|
||||||
|
when: not prometheus_install
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
GOMAXPROCS={{ ansible_processor_vcpus }}
|
||||||
|
PROMETHEUS_CMD={{ prometheus_cmd }}
|
||||||
|
PROMETHEUS_LOGDIR={{ prometheus_home }}/logs
|
||||||
|
PROMETHEUS_DATADIR={{ prometheus_home }}/data
|
||||||
|
PROMETHEUS_LOGLEVEL={{ prometheus_loglevel }}
|
||||||
|
PROMETHEUS_CONF={{ prometheus_confdir }}/prometheus.yml
|
||||||
|
PROMETHEUS_OPTS="{{ prometheus_opts }}"
|
||||||
|
PROMETHEUS_STARTUP_OPTS="--config.file={{ prometheus_confdir }}/prometheus.yml --storage.tsdb.path={{ prometheus_home }}/data {{ prometheus_opts }} --log.level={{ prometheus_loglevel }}"
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Prometheus - Prometheus metrics collector.
|
||||||
|
Documentation=https://prometheus.io/docs/introduction/overview/
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User={{ prometheus_user }}
|
||||||
|
Group={{ prometheus_user }}
|
||||||
|
EnvironmentFile=/etc/default/prometheus
|
||||||
|
ExecStart={{ prometheus_cmd }} $PROMETHEUS_STARTUP_OPTS
|
||||||
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
Alias=prometheus_server.service
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
global:
|
||||||
|
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
|
||||||
|
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
|
||||||
|
# scrape_timeout is set to the global default (10s).
|
||||||
|
|
||||||
|
# Alertmanager configuration
|
||||||
|
alerting:
|
||||||
|
alertmanagers:
|
||||||
|
- static_configs:
|
||||||
|
- targets:
|
||||||
|
# - alertmanager:9093
|
||||||
|
|
||||||
|
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
|
||||||
|
rule_files:
|
||||||
|
# - "first_rules.yml"
|
||||||
|
# - "second_rules.yml"
|
||||||
|
|
||||||
|
# A scrape configuration containing exactly one endpoint to scrape:
|
||||||
|
# Here it's Prometheus itself.
|
||||||
|
scrape_configs:
|
||||||
|
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
|
||||||
|
- job_name: 'prometheus'
|
||||||
|
|
||||||
|
# metrics_path defaults to '/metrics'
|
||||||
|
# scheme defaults to 'http'.
|
||||||
|
|
||||||
|
static_configs:
|
||||||
|
- targets: ['localhost:9090']
|
|
@ -1,2 +1,22 @@
|
||||||
---
|
---
|
||||||
# vars file for ansible-role-template
|
prometheus_dir: 'prometheus-{{ prometheus_version }}.linux-amd64'
|
||||||
|
prometheus_file: '{{ prometheus_dir }}.tar.gz'
|
||||||
|
prometheus_download_url: 'https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/{{ prometheus_file }}'
|
||||||
|
|
||||||
|
nginx_letsencrypt_managed: True
|
||||||
|
nginx_use_common_virthost: True
|
||||||
|
nginx_virthosts:
|
||||||
|
- virthost_name: '{{ ansible_fqdn }}'
|
||||||
|
listen: '{{ http_port }}'
|
||||||
|
server_name: '{{ ansible_fqdn }}'
|
||||||
|
server_aliases: ''
|
||||||
|
index: index.html
|
||||||
|
ssl_enabled: True
|
||||||
|
ssl_only: True
|
||||||
|
ssl_letsencrypt_certs: '{{ nginx_letsencrypt_managed }}'
|
||||||
|
root: '{{ nginx_webroot }}'
|
||||||
|
server_tokens: 'off'
|
||||||
|
proxy_standard_setup: True
|
||||||
|
locations:
|
||||||
|
- location: /
|
||||||
|
target: http://localhost:{{ prometheus_http_port }}
|
||||||
|
|
Loading…
Reference in New Issue