123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- ---
- # Installs the Grafana Dashboard, as described in:
- # http://docs.grafana.org/installation/debian/
- # http://docs.grafana.org/installation/configuration/
-
- - name: Ensure repository key for Grafana is in place
- apt_key: url=https://packages.grafana.com/gpg.key state=present
- tags:
- - dependencies
-
- - name: Add Grafana repository
- apt_repository: repo="deb https://packages.grafana.com/oss/deb stable main"
- tags:
- - dependencies
-
- - name: Install Grafana from official repository
- apt:
- name: "{{ packages }}"
- state: present
- update_cache: yes
- vars:
- packages:
- - grafana
- tags:
- - dependencies
-
- - name: Configure Grafana
- template:
- src=etc_grafana_grafana.j2
- dest=/etc/grafana/grafana.ini
- owner=root
- group=grafana
- notify: restart grafana
-
- - name: Create Grafana data directory
- file: state=directory path=/data/grafana owner=grafana group=grafana
-
- - name: Add Grafana postgres user
- postgresql_user:
- login_host=localhost
- login_user={{ db_admin_username }}
- login_password="{{ db_admin_password }}"
- name={{ grafana_db_username }}
- password="{{ grafana_db_password }}"
- encrypted=yes
- state=present
-
- - name: Create Grafana database
- postgresql_db:
- login_host=localhost
- login_user={{ db_admin_username }}
- login_password="{{ db_admin_password }}"
- name={{ grafana_db_database }}
- state=present
- owner={{ grafana_db_username }}
-
- - name: Register new Grafana service
- systemd: name=grafana-server daemon_reload=yes enabled=yes
-
- - name: Start new Grafana instance
- service: name=grafana-server state=started
-
- - name: Create the Apache Grafana sites config files
- template:
- src=etc_apache2_sites-available_grafana.j2
- dest=/etc/apache2/sites-available/grafana_{{ item.name }}.conf
- owner=root
- group=root
- with_items: "{{ virtual_domains }}"
- notify: restart apache
-
- - name: Enable Apache sites (creates new sites-enabled symlinks)
- command: a2ensite grafana_{{ item }}.conf creates=/etc/apache2/sites-enabled/grafana_{{ item }}.conf
- notify: restart apache
- with_items: "{{ virtual_domains | json_query('[*].name') }}"
|