---

- name: base packages installed
  package:
    name: 
    - prometheus
    - nginx
- name: alerts directory
  file:
    state: directory
    path: /etc/prometheus/alerts
- name: prometheus template
  template:
    src: prometheus.yml.j2
    dest: /etc/prometheus/prometheus.yml
  notify: restart prometheus
  tags: prometheus_conf
- name: prometheus site template
  template:
    src: prometheus_site.j2
    dest: /etc/nginx/sites-available/prometheus
  notify: reload nginx
  tags: nginx
- name: site link
  file:
    state: link
    path: /etc/nginx/sites-enabled/prometheus
    src: ../sites-available/prometheus
  notify: reload nginx
  tags: nginx

- name: lxc.yml
  copy:
    force: no
    dest: /etc/prometheus/lxc.yml
    content: '- targets:'

- name: prometheus started and enabled
  service:
    name: prometheus
    state: started
    enabled: yes
