From 71b3e802275e1fefe154292ae92c89c89753ff82 Mon Sep 17 00:00:00 2001 From: Jannik Beyerstedt Date: Sun, 8 Mar 2020 16:41:55 +0100 Subject: [PATCH] [CODE] add CentOS support to telegraf and cronmails (fix #6) --- meta/main.yml | 4 ++++ tasks/cronmails-Centos.yml | 13 +++++++++++++ tasks/cronmails-Debian.yml | 13 +++++++++++++ tasks/cronmails.yml | 17 ++++++++--------- tasks/telegraf-Centos.yml | 18 ++++++++++++++++++ tasks/telegraf-Debian.yml | 25 +++++++++++++++++++++++++ tasks/telegraf.yml | 28 +++++++--------------------- 7 files changed, 88 insertions(+), 30 deletions(-) create mode 100644 tasks/cronmails-Centos.yml create mode 100644 tasks/cronmails-Debian.yml create mode 100644 tasks/telegraf-Centos.yml create mode 100644 tasks/telegraf-Debian.yml diff --git a/meta/main.yml b/meta/main.yml index 75ede6f..feb422a 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -10,6 +10,10 @@ galaxy_info: - name: Debian versions: - all + - name: Centos + versions: + - 7 + - 8 galaxy_tags: [] diff --git a/tasks/cronmails-Centos.yml b/tasks/cronmails-Centos.yml new file mode 100644 index 0000000..e1bb6d8 --- /dev/null +++ b/tasks/cronmails-Centos.yml @@ -0,0 +1,13 @@ +--- +# Server/Cronmails: Setup Mails from Cronjobs (install exim) - CentOS Version + +# Install exim +- name: cronmails - Install exim4 as MTA + become: yes + yum: + name: "{{ packages }}" + state: present + vars: + packages: + - exim4 + - mailutils diff --git a/tasks/cronmails-Debian.yml b/tasks/cronmails-Debian.yml new file mode 100644 index 0000000..98cb540 --- /dev/null +++ b/tasks/cronmails-Debian.yml @@ -0,0 +1,13 @@ +--- +# Server/Cronmails: Setup Mails from Cronjobs (install exim) - Debian Version + +# Install exim +- name: cronmails - Install exim4 as MTA + become: yes + apt: + name: "{{ packages }}" + state: present + vars: + packages: + - exim4 + - mailutils diff --git a/tasks/cronmails.yml b/tasks/cronmails.yml index cef921c..7bc0085 100644 --- a/tasks/cronmails.yml +++ b/tasks/cronmails.yml @@ -2,15 +2,14 @@ # Server/Cronmails: Setup Mails from Cronjobs (install exim) # Install and configure exim -- name: cronmails - Install exim4 as MTA - become: yes - apt: - name: "{{ packages }}" - state: present - vars: - packages: - - exim4 - - mailutils +- name: cronmails - Install exim4 + include_tasks: "{{ item }}" + with_first_found: + - "cronmails-{{ ansible_distribution }}.{{ ansible_distribution_release }}.yml" + - "cronmails-{{ ansible_distribution }}.yml" + - "cronmails-{{ ansible_os_family }}.yml" + +# Configure exim - name: cronmails - Create exim4 config folder become: yes file: diff --git a/tasks/telegraf-Centos.yml b/tasks/telegraf-Centos.yml new file mode 100644 index 0000000..78b5227 --- /dev/null +++ b/tasks/telegraf-Centos.yml @@ -0,0 +1,18 @@ +--- +# Server/Telegraf: Install and Setup Telegraf Monitoring - CentOS Version + +- name: telegraf - Add telegraf repo + become: yes + yum_repository: + name: influxdb + description: "InfluxDB Repository - RHEL \$releasever" + baseurl: "https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable" + enabled: yes + gpgcheck: yes + gpgkey: "https://repos.influxdata.com/influxdb.key" +- name: telegraf - Install telegraf + become: yes + yum: + name: telegraf + state: latest + update_cache: yes diff --git a/tasks/telegraf-Debian.yml b/tasks/telegraf-Debian.yml new file mode 100644 index 0000000..dc0bccd --- /dev/null +++ b/tasks/telegraf-Debian.yml @@ -0,0 +1,25 @@ +--- +# Server/Telegraf: Install and Setup Telegraf Monitoring - Debian Version + +- name: telegraf - Install apt-transport-https + become: yes + apt: + name: apt-transport-https + state: present +- name: telegraf - Add telegraf repo key + become: yes + apt_key: + url: https://repos.influxdata.com/influxdb.key + state: present +- name: telegraf - Add telegraf repo + become: yes + apt_repository: + repo: "deb https://repos.influxdata.com/debian {{ ansible_distribution_release }} stable" + state: present +- name: telegraf - Install telegraf + become: yes + apt: + name: telegraf + state: latest + update_cache: yes + cache_valid_time: 3600 diff --git a/tasks/telegraf.yml b/tasks/telegraf.yml index e086d92..20085f9 100644 --- a/tasks/telegraf.yml +++ b/tasks/telegraf.yml @@ -1,29 +1,15 @@ --- # Server/Telegraf: Install and Setup Telegraf Monitoring -- name: telegraf - Install apt-transport-https - become: yes - apt: - name: apt-transport-https - state: present -- name: telegraf - Add telegraf repo key - become: yes - apt_key: - url: https://repos.influxdata.com/influxdb.key - state: present -- name: telegraf - Add telegraf repo - become: yes - apt_repository: - repo: "deb https://repos.influxdata.com/debian {{ ansible_distribution_release }} stable" - state: present +# Install - name: telegraf - Install telegraf - become: yes - apt: - name: telegraf - state: latest - update_cache: yes - cache_valid_time: 3600 + include_tasks: "{{ item }}" + with_first_found: + - "telegraf-{{ ansible_distribution }}.{{ ansible_distribution_release }}.yml" + - "telegraf-{{ ansible_distribution }}.yml" + - "telegraf-{{ ansible_os_family }}.yml" +# Configure - name: telegraf - Copy telegraf config become: yes template: