diff --git a/tasks/main.yml b/tasks/main.yml index a5aa7e3..cdd5a3d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -4,50 +4,7 @@ # tasks file # -- name: include OS family/distribution specific variables - include_vars: "{{ item }}" - with_first_found: - - "../defaults/{{ ansible_os_family | lower }}-{{ ansible_distribution | lower }}_{{ ansible_distribution_version | lower }}.yml" - - "../defaults/{{ ansible_os_family | lower }}-{{ ansible_distribution | lower }}.yml" - - "../defaults/{{ ansible_os_family | lower }}.yml" - -- include: debug.yml - when: debug | default(false) - tags: debug - -- include: validation.yml - tags: validation - -- name: ensure apt dependencies are installed - apt: - name="{{ item }}" - state=present - become: yes - when: ansible_distribution | lower == 'debian' and grafana_apt_dependencies is defined - with_items: "{{ grafana_apt_dependencies }}" - -- name: ensure grafana apt key is present - apt_key: - url=https://packagecloud.io/gpg.key - id=D59097AB - state=present - become: yes - tags: [ apt ] - -- name: ensure grafana apt repository is present - apt_repository: - repo="deb https://packagecloud.io/grafana/stable/{{ ansible_os_family | lower }}/ {{ grafana_apt_distribution }} main" - update_cache=yes - state=present - become: yes - tags: [ apt ] - -- name: ensure grafana is installed - apt: - name=grafana - state=present - become: yes - tags: installation +- include_tasks: "setup-{{ansible_os_family}}.yml" - name: Ensure integrity of grafana configuration. template: diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml new file mode 100644 index 0000000..a165706 --- /dev/null +++ b/tasks/setup-Debian.yml @@ -0,0 +1,45 @@ +--- +- name: include OS family/distribution specific variables + include_vars: "{{ item }}" + with_first_found: + - "../defaults/{{ ansible_os_family | lower }}-{{ ansible_distribution | lower }}_{{ ansible_distribution_version | lower }}.yml" + - "../defaults/{{ ansible_os_family | lower }}-{{ ansible_distribution | lower }}.yml" + - "../defaults/{{ ansible_os_family | lower }}.yml" + +- include: debug.yml + when: debug | default(false) + tags: debug + +- include: validation.yml + tags: validation + +- name: ensure apt dependencies are installed + apt: + name="{{ item }}" + state=present + become: yes + when: ansible_distribution | lower == 'debian' and grafana_apt_dependencies is defined + with_items: "{{ grafana_apt_dependencies }}" + +- name: ensure grafana apt key is present + apt_key: + url=https://packages.grafana.com/gpg.key + id=D59097AB + state=present + become: yes + tags: [ apt ] + +- name: ensure grafana apt repository is present + apt_repository: + repo="deb https://packagecloud.io/grafana/stable/{{ ansible_os_family | lower }}/ {{ grafana_apt_distribution }} main" + update_cache=yes + state=present + become: yes + tags: [ apt ] + +- name: ensure grafana is installed + apt: + name=grafana + state=present + become: yes + tags: installation diff --git a/tasks/setup-RedHat.yml b/tasks/setup-RedHat.yml new file mode 100644 index 0000000..fe8a06a --- /dev/null +++ b/tasks/setup-RedHat.yml @@ -0,0 +1,24 @@ +--- +- name: Install wget package + yum: pkg=wget state=present + +- name: Checking /opt directory exists + become: yes + file: + path: /opt + state: directory + +- name: Downloading Grafana rpm file + get_url: + url: https://dl.grafana.com/oss/release/grafana-6.5.0-1.x86_64.rpm + dest: /opt + +- name: Installing grafana... + yum: + name: /opt/grafana-6.5.0-1.x86_64.rpm + state: present + +- name: Removing RPM file... + file: + state: absent + path: /opt/grafana-6.5.0-1.x86_64.rpm