Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dj-wasabi/ansible-telegraf
Browse files Browse the repository at this point in the history
  • Loading branch information
dj-wasabi committed Oct 20, 2023
2 parents fdcff0b + 94774fb commit ccdb9bd
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 46 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@

- Replace apt\_key with get\_url [\#170](https://github.com/dj-wasabi/ansible-telegraf/pull/170) ([danclough](https://github.com/danclough))

**Closed issues:**

- Failure due to apt-key when run against newer Debian/Ubuntu releases [\#169](https://github.com/dj-wasabi/ansible-telegraf/issues/169)

**Merged pull requests:**

- replace depracted aws module [\#178](https://github.com/dj-wasabi/ansible-telegraf/pull/178) ([ThorstenHeck](https://github.com/ThorstenHeck))
- added yaml 1.2.2 compatibility [\#176](https://github.com/dj-wasabi/ansible-telegraf/pull/176) ([DEvil0000](https://github.com/DEvil0000))
- Migrate from io to diskio to fix deprecation warning [\#173](https://github.com/dj-wasabi/ansible-telegraf/pull/173) ([mprasil](https://github.com/mprasil))

## [0.14.0](https://github.com/dj-wasabi/ansible-telegraf/tree/0.14.0) (2023-01-30)

[Full Changelog](https://github.com/dj-wasabi/ansible-telegraf/compare/0.13.3...0.14.0)
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ telegraf_plugins_default:
config:
- percpu = true
- plugin: disk
- plugin: io
- plugin: diskio
- plugin: mem
- plugin: net
- plugin: system
Expand Down
4 changes: 2 additions & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
service:
name: telegraf
state: restarted
enabled: yes
enabled: true
when: not telegraf_agent_docker
become: yes
become: true
ignore_errors: "{{ ansible_check_mode }}"

- name: "Restart Telegraf container"
Expand Down
24 changes: 12 additions & 12 deletions tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
until: are_telegraf_dependencies_packages_installed is succeeded
when:
- not apt_https_transport.stat.exists
become: yes
become: true

- name: "Debian | Configure Telegraf apt repository"
when:
Expand All @@ -49,7 +49,7 @@
state: present
register: are_telegraf_dependencies_keys_installed
until: are_telegraf_dependencies_keys_installed is succeeded
become: yes
become: true
- when: (ansible_distribution == "Debian" and ansible_distribution_major_version|int >= 9) or (ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 18)
block:
- name: "Debian | Ensure the shared keyrings directory exists"
Expand All @@ -66,15 +66,15 @@
mode: 0755
when:
- not usr_share_keyrings.stat.exists
become: yes
become: true

- name: "Debian | Install Telegraf apt key"
get_url:
url: https://repos.influxdata.com/influxdata-archive.key
dest: /usr/share/keyrings/influxdata-archive.asc
register: are_telegraf_dependencies_keys_installed
until: are_telegraf_dependencies_keys_installed is succeeded
become: yes
become: true

- name: "Debian | Set Telegraf apt repository parameters"
set_fact:
Expand All @@ -92,19 +92,19 @@
copy:
content: "deb {{ telegraf_repository_params | default('') }} https://repos.influxdata.com/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} stable"
dest: /etc/apt/sources.list.d/telegraf.list
become: yes
become: true
when:
- ansible_lsb is not defined or ansible_lsb.codename is not defined

- name: "Debian | Install Telegraf package (repo)"
apt:
name: "{{ telegraf_agent_package }}"
state: "{{ telegraf_agent_package_state }}"
update_cache: yes
update_cache: true
register: is_telegraf_package_installed
until: is_telegraf_package_installed is succeeded
notify: "Restart Telegraf"
become: yes
become: true
when:
- telegraf_agent_package_method == "repo"
ignore_errors: "{{ ansible_check_mode }}"
Expand All @@ -113,11 +113,11 @@
apt:
name: "{{ telegraf_agent_package }}"
state: "{{ telegraf_agent_package_state }}"
update_cache: yes
update_cache: true
register: is_telegraf_package_installed
until: is_telegraf_package_installed is succeeded
notify: "Restart Telegraf"
become: yes
become: true
ignore_errors: "{{ ansible_check_mode }}"

- name: "Debian | Download Telegraf package (online)"
Expand All @@ -135,11 +135,11 @@
apt:
deb: "{{ telegraf_agent_package_path }}/{{ telegraf_agent_package }}"
state: "present"
allow_downgrade: yes
allow_downgrade: true
register: is_telegraf_package_installed
until: is_telegraf_package_installed is succeeded
notify: "Restart Telegraf"
become: yes
become: true
when:
- telegraf_agent_package_method == "online" or telegraf_agent_package_method == "offline"
ignore_errors: "{{ ansible_check_mode }}"
Expand All @@ -148,6 +148,6 @@
file:
path: "/etc/apt/sources.list.d/telegraf.list"
state: absent
become: yes
become: true
when:
- telegraf_agent_package_method == "online" or telegraf_agent_package_method == "offline"
4 changes: 2 additions & 2 deletions tasks/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
baseurl: "{{ telegraf_yum_baseurl[ansible_distribution|lower] | default(telegraf_yum_baseurl['default']) }}"
gpgcheck: "{{ telegraf_yum_gpgcheck | default('true') }}"
gpgkey: "{{ telegraf_yum_gpgkey }}"
become: yes
become: true
when:
- telegraf_agent_package_method == "repo"

Expand All @@ -41,6 +41,6 @@
state: "{{ telegraf_agent_package_state }}"
register: is_telegraf_package_installed
until: is_telegraf_package_installed is succeeded
become: yes
become: true
notify: "Restart Telegraf"
ignore_errors: "{{ ansible_check_mode }}"
12 changes: 6 additions & 6 deletions tasks/Suse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
name: telegraf
group: telegraf
state: present
become: yes
become: true

- name: "Suse | Install repo dependencies for Python 2"
zypper:
Expand All @@ -21,7 +21,7 @@
state: present
register: are_telegraf_dependencies_packages_installed
until: are_telegraf_dependencies_packages_installed is succeeded
become: yes
become: true
when: ansible_python.version.major == 2

- name: "Suse | Install repo dependencies for Python >= 3"
Expand All @@ -32,7 +32,7 @@
state: present
register: are_telegraf_dependencies_packages_installed
until: are_telegraf_dependencies_packages_installed is succeeded
become: yes
become: true
when: ansible_python.version.major >= 3

- name: "Suse | Add default Open Build Service repository"
Expand All @@ -42,7 +42,7 @@
state: present
runrefresh: True
auto_import_keys: True
become: yes
become: true
when: telegraf_zypper_baseurl is not defined

- name: "Suse | Add specified package repository"
Expand All @@ -52,7 +52,7 @@
state: present
runrefresh: True
auto_import_keys: True
become: yes
become: true
when: telegraf_zypper_baseurl is defined

- name: "Suse | Install Telegraf"
Expand All @@ -61,7 +61,7 @@
state: "{{ telegraf_agent_package_state }}"
register: is_telegraf_package_installed
until: is_telegraf_package_installed is succeeded
become: yes
become: true
ignore_errors: "{{ ansible_check_mode }}"

- name: "Suse | Create directories for telegraf"
Expand Down
17 changes: 8 additions & 9 deletions tasks/configure_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
- ansible_os_family == "FreeBSD"

- name: Retrieve all ec2 tags on the instance
ec2_tag:
amazon.aws.ec2_tag_info:
region: '{{ ansible_ec2_placement_region }}'
resource: '{{ ansible_ec2_instance_id }}'
state: list
when:
- telegraf_agent_aws_tags
register: ec2_tags
Expand All @@ -28,7 +27,7 @@
owner: telegraf
group: telegraf
mode: 0640
become: yes
become: true
when:
- telegraf_agent_version is version('0.10.0', '<')
notify:
Expand All @@ -42,7 +41,7 @@
owner: telegraf
group: telegraf
mode: 0640
become: yes
become: true
when:
- telegraf_agent_version is version('0.10.0', '>=')
notify:
Expand All @@ -63,7 +62,7 @@
when:
- telegraf_plugins_extra_exclusive
- telegraf_directory.stat.exists
become: yes
become: true
notify:
- Restart Telegraf
- Restart Telegraf container
Expand All @@ -78,7 +77,7 @@
when:
- telegraf_plugins_extra_exclusive
- telegraf_directory.stat.exists
become: yes
become: true
notify:
- Restart Telegraf
- Restart Telegraf container
Expand All @@ -97,7 +96,7 @@
- telegraf_plugins_extra is defined
- telegraf_plugins_extra is iterable
- item.value.state|default('present') != 'absent'
become: yes
become: true
notify:
- Restart Telegraf
- Restart Telegraf container
Expand All @@ -113,7 +112,7 @@
- telegraf_plugins_extra is defined
- telegraf_plugins_extra is iterable
- item.value.state|default('present') == 'absent'
become: yes
become: true
notify:
- Restart Telegraf
- Restart Telegraf container
Expand All @@ -126,7 +125,7 @@
name: telegraf
state: "{{ telegraf_enabled | ternary('started', 'stopped') }}"
enabled: "{{ telegraf_enabled }}"
become: yes
become: true
when: not telegraf_agent_docker
ignore_errors: "{{ ansible_check_mode }}"

Expand Down
15 changes: 7 additions & 8 deletions tasks/configure_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
- ansible_os_family in ["FreeBSD", "Darwin"]

- name: Retrieve all ec2 tags on the instance
ec2_tag:
amazon.aws.ec2_tag_info:
region: '{{ ansible_ec2_placement_region }}'
resource: '{{ ansible_ec2_instance_id }}'
state: list
when:
- telegraf_agent_aws_tags
register: ec2_tags
Expand All @@ -28,7 +27,7 @@
owner: "{{ telegraf_mac_user }}"
group: "{{ telegraf_mac_group }}"
mode: 0640
become: yes
become: true
when:
- telegraf_agent_version is version('0.10.0', '<')
notify:
Expand All @@ -42,7 +41,7 @@
owner: "{{ telegraf_mac_user }}"
group: "{{ telegraf_mac_group }}"
mode: 0640
become: yes
become: true
when:
- telegraf_agent_version is version('0.10.0', '>=')
notify:
Expand All @@ -63,7 +62,7 @@
when:
- telegraf_plugins_extra_exclusive
- telegraf_directory.stat.exists
become: yes
become: true
notify:
- Restart MacOS Telegraf
- Restart Telegraf container
Expand All @@ -78,7 +77,7 @@
when:
- telegraf_plugins_extra_exclusive
- telegraf_directory.stat.exists
become: yes
become: true
notify:
- Restart MacOS Telegraf
- Restart Telegraf container
Expand All @@ -97,7 +96,7 @@
- telegraf_plugins_extra is defined
- telegraf_plugins_extra is iterable
- item.value.state|default('present') != 'absent'
become: yes
become: true
notify:
- Restart MacOS Telegraf
- Restart Telegraf container
Expand All @@ -113,7 +112,7 @@
- telegraf_plugins_extra is defined
- telegraf_plugins_extra is iterable
- item.value.state|default('present') == 'absent'
become: yes
become: true
notify:
- Restart MacOS Telegraf
- Restart Telegraf container
Expand Down
6 changes: 3 additions & 3 deletions tasks/configure_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@
win_copy:
src: '{{ telegraf_win_install_dir }}\telegraf-{{ telegraf_agent_version }}\telegraf.exe'
dest: '{{ telegraf_win_install_dir }}\telegraf.exe'
remote_src: yes
remote_src: true
when: telegraf_agent_version is version('1.15', '>=')

- name: "Windows | Unzip file"
win_unzip:
src: '{{ telegraf_win_install_dir }}\telegraf-{{ telegraf_agent_version }}_windows_amd64.zip'
dest: '{{ telegraf_win_install_dir }}'
creates: '{{ telegraf_win_install_dir }}\telegraf.exe'
delete_archive: yes
delete_archive: true
when: telegraf_agent_version is version('1.15', '<')

- name: "Windows | Move extracted executable"
win_copy:
src: '{{ telegraf_win_install_dir }}\telegraf\telegraf.exe'
dest: '{{ telegraf_win_install_dir }}\telegraf.exe'
remote_src: yes
remote_src: true
when: telegraf_agent_version is version('1.15', '<')

- name: "Windows | Configure Telegraf"
Expand Down
6 changes: 3 additions & 3 deletions tasks/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
home: /etc/telegraf
uid: "{{ telegraf_uid_docker }}"
system: True
become: yes
become: true

- name: Create /etc/telegraf (home) directory
file:
Expand All @@ -24,7 +24,7 @@
group: telegraf
mode: 0750
state: directory
become: yes
become: true

- name: Create /etc/telegraf.d directory
file:
Expand All @@ -33,7 +33,7 @@
group: telegraf
mode: 0750
state: directory
become: yes
become: true

- name: Ensure Telegraf Docker container is running
docker_container:
Expand Down

0 comments on commit ccdb9bd

Please sign in to comment.