Skip to content

Commit

Permalink
added yaml 1.2.2 compatibility (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
DEvil0000 authored Oct 20, 2023
1 parent 4064c8b commit f241fd3
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 41 deletions.
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
14 changes: 7 additions & 7 deletions tasks/configure_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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 +42,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 +63,7 @@
when:
- telegraf_plugins_extra_exclusive
- telegraf_directory.stat.exists
become: yes
become: true
notify:
- Restart Telegraf
- Restart Telegraf container
Expand All @@ -78,7 +78,7 @@
when:
- telegraf_plugins_extra_exclusive
- telegraf_directory.stat.exists
become: yes
become: true
notify:
- Restart Telegraf
- Restart Telegraf container
Expand All @@ -97,7 +97,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 +113,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 +126,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
12 changes: 6 additions & 6 deletions tasks/configure_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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 +42,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 +63,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 +78,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 +97,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 +113,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 f241fd3

Please sign in to comment.