Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
---
- name: create prometheus system group
  group:
    name: prometheus
    system: true
    state: present

- name: create prometheus system user
  user:
    name: prometheus
    system: true
    shell: "/sbin/nologin"
    group: prometheus
    createhome: false
    home: "{{ prometheus_db_dir }}"

- name: create prometheus data directory
  file:
    path: "{{ prometheus_db_dir }}"
    state: directory
    owner: prometheus
    group: prometheus
    mode: 0755

- name: create prometheus configuration directories
  file:
    path: "{{ item }}"
    state: directory
    owner: root
    group: prometheus
    mode: 0770
  with_items:
    - "{{ prometheus_config_dir }}"
    - "{{ prometheus_config_dir }}/conf.d"
    - "{{ prometheus_config_dir }}/rules"
    - "{{ prometheus_config_dir }}/file_sd"

- name: download prometheus binary to local folder
  become: false
  get_url:
    url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz"
    dest: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz"
    checksum: "sha256:{{ prometheus_checksum }}"
  register: _download_archive
  until: _download_archive is succeeded
  retries: 5
  delay: 2
  # run_once: true # <-- this canfalset be set due to multi-arch support
  delegate_to: localhost
  check_mode: false

- name: unpack prometheus binaries
  become: false
  unarchive:
    src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz"
    dest: "/tmp"
    creates: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}/prometheus"
  delegate_to: localhost
  check_mode: false

- name: propagate prometheus and promtool binaries
  copy:
    src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}/{{ item }}"
    dest: "/usr/local/bin/{{ item }}"
    mode: 0755
    owner: root
    group: root
  with_items:
    - prometheus
    - promtool
  notify:
    - restart prometheus

- name: propagate console templates
  copy:
    src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}/{{ item }}/"
    dest: "{{ prometheus_config_dir }}/{{ item }}/"
    mode: 0644
    owner: root
    group: root
  with_items:
    - console_libraries
    - consoles
  notify:
    - restart prometheus

- name: create systemd service unit
  template:
    src: prometheus.service.j2
    dest: /etc/systemd/system/prometheus.service
    owner: root
    group: root
    mode: 0644
  notify:
    - restart prometheus

- name: Install SELinux dependencies
  package:
    name: "{{ item }}"
    state: present
  with_items: "{{ prometheus_selinux_packages }}"
  register: _install_packages
  until: _install_packages is succeeded
  retries: 5
  delay: 2
  when:
    - ansible_version.full is version_compare('2.4', '>=')
    - ansible_selinux.status == "enabled"

- name: Allow prometheus to bind to port in SELinux
  seport:
    ports: "{{ prometheus_web_listen_address.split(':')[1] }}"
    proto: tcp
    setype: http_port_t
    state: present
  when:
    - ansible_version.full is version_compare('2.4', '>=')
    - ansible_selinux.status == "enabled"

# - name: change pam falsefile limits for prometheus
#   pam_limits:
#     domain: "prometheus"
#     limit_item: falsefile
#     limit_type: "{{ item }}"
#     value: "1024"
#     use_max: true
#   with_items:
#       - soft
#       - hard
#   notify:
#     - restart prometheus