diff --git a/defaults/main.yml b/defaults/main.yml index 210d128..7d662c0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -3,6 +3,8 @@ grafana_enabled: true # The role is enabled grafana_apt_repository: deb https://packagecloud.io/grafana/stable/debian/ jessie main grafana_apt_key: https://packagecloud.io/gpg.key +grafana_yum_reposotory: https://packagecloud.io/grafana/stable/el/7/$basearch +grafana_yum_key: https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana grafana_version: 4.1.2-* # Set version (set to latest to install latest version) diff --git a/tasks/grafana.yml b/tasks/grafana.yml index 12544bf..855a8d9 100644 --- a/tasks/grafana.yml +++ b/tasks/grafana.yml @@ -4,5 +4,9 @@ when: ansible_os_family == 'Debian' tags: [grafana, grafana-install] +- include: install.rhel.yml + when: ansible_os_family == 'RedHat' + tags: [grafana, grafana-install] + - include: configure.yml tags: [grafana, grafana-configure] diff --git a/tasks/install.rhel.yml b/tasks/install.rhel.yml new file mode 100644 index 0000000..52eb467 --- /dev/null +++ b/tasks/install.rhel.yml @@ -0,0 +1,33 @@ +--- + +- name: Add repository + yum_repository: + name: 'grafana' + baseurl: '{{ grafana_yum_reposotory }}' + repo_gpgcheck: yes + gpgcheck: yes + enabled: yes + gpgkey: '{{ grafana_yum_key }}' + sslverify: yes + sslcacert: '/etc/pki/tls/certs/ca-bundle.crt' + description: 'Grafana repo' + state: present + tags: [grafana, grafana-install] + +- set_fact: grafana_release='grafana-{{grafana_version}}' + tags: [grafana, grafana-install] + +- name: Install grafana | Install Grafana Release + yum: name="{{ grafana_release }}" + when: grafana_version != "latest" + notify: + - grafana restart + tags: [grafana, grafana-install] + +- name: Install grafana | Install Grafana Latest + yum: name="grafana" + when: grafana_version == "latest" + notify: + - grafana restart + tags: [grafana, grafana-install] +