- name: Ensure docker-compose directory exists file: state: directory path: /etc/grafana-docker - name: Write settings file template: src: docker-compose.yaml.j2 dest: /etc/grafana-docker/docker-compose.yaml - name: Ensure config directory exists file: state: directory path: /etc/grafana - name: Ensure secrets config directory exists file: state: directory path: /etc/grafana/secrets - name: Make admin_password copy: content: '{{ grafana_admin_password }}' dest: /etc/grafana/secrets/admin_password - name: Make admin_user copy: content: '{{ grafana_admin_user }}' dest: /etc/grafana/secrets/admin_user - name: Make secret_key copy: content: '{{ grafana_secret_key }}' dest: /etc/grafana/secrets/secret_key - name: Write grafyaml env file template: src: grafyaml.env.j2 dest: /etc/grafana/secrets/grafyaml.env owner: root group: root mode: 0644 - name: Ensure home panel directory exists file: state: directory path: /etc/grafana/home owner: root group: root mode: 0755 - name: Copy home panel copy: src: 'home.json' dest: '/etc/grafana/home/home.json' owner: root group: root mode: 0644 - name: Write update script template: src: update-grafana-dashboards.sh.j2 dest: /usr/local/bin/update-grafana-dashboards owner: root group: root mode: 0755 - name: Install apache2 apt: name: - apache2 - apache2-utils state: present - name: Apache modules apache2_module: state: present name: "{{ item }}" loop: - rewrite - proxy - proxy_http - ssl - headers - proxy_wstunnel - name: Copy apache config template: src: grafana.vhost.j2 dest: /etc/apache2/sites-enabled/000-default.conf owner: root group: root mode: 0644 notify: grafana Reload apache2 - name: Sync project-config include_role: name: sync-project-config - name: Run docker-compose pull shell: cmd: docker-compose pull chdir: /etc/grafana-docker/ - name: Run docker-compose up shell: cmd: docker-compose up -d chdir: /etc/grafana-docker/ - name: Run docker prune to cleanup unneeded images shell: cmd: docker image prune -f - name: Wait for grafana to be up and running wait_for: timeout: 60 port: 3000 - name: Import dashboards to container command: '/usr/local/bin/update-grafana-dashboards'