Skip to content

Commit

Permalink
Add Archlinux OS
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Villaro-Dixon <[email protected]>
  • Loading branch information
Frankkkkk committed Jun 21, 2024
1 parent 51c2bb6 commit 16cf93f
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ This role supports the following systems:
* (Open)Suse
* Windows (Best effort)
* FreeBSD (Best effort)
* Archlinux (only "online" mode)

So, you'll need one of those systems.. :-)
Please sent Pull Requests or suggestions when you want to use this role for other systems.
Expand Down
86 changes: 86 additions & 0 deletions tasks/Archlinux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---

- name: "Archlinux | Set name if state != latest"
set_fact:
telegraf_agent_binary: telegraf={{ telegraf_agent_version }}-{{ telegraf_agent_version_patch }}
when:
- telegraf_agent_package_state != "latest"

- name: "Archlinux | Set telegraf_agent_package_arch"
set_fact:
telegraf_agent_package_arch: "{{ ansible_architecture }}"

- name: "Archlinux | Set telegraf_agent_package_arch specific for x86_64"
set_fact:
telegraf_agent_package_arch: "amd64"
when:
- ansible_architecture == "x86_64"

- name: "Archlinux | Set telegraf_agent_package_arch specific for arm64/armv7l"
set_fact:
telegraf_agent_package_arch: "armhf"
when:
- ansible_architecture == "arm64" or ansible_architecture == "armv7l"

- name: "Archlinux | Create telegraf user"
user:
name: telegraf
system: yes
shell: /bin/false
home: /etc/telegraf
when:
- telegraf_agent_package_method == "online"

- name: "Archlinux | Create telegraf directory"
file:
path: /etc/telegraf
state: directory
when:
- telegraf_agent_package_method == "online"

- name: "Archlinux | Extract telegraf binary"
ansible.builtin.unarchive:
src: "https://dl.influxdata.com/telegraf/releases/telegraf-{{ telegraf_agent_version }}_linux_{{ telegraf_agent_package_arch }}.tar.gz"
dest: /tmp/
remote_src: yes
when:
- telegraf_agent_package_method == "online"

- name: "Archlinux | Copy telegraf binary"
ansible.builtin.copy:
src: "/tmp/telegraf-{{ telegraf_agent_version }}/usr/bin/telegraf"
remote_src: yes
dest: /usr/bin/
owner: root
group: root
mode: 0755
when:
- telegraf_agent_package_method == "online"

- name: "Archlinux | Copy telegraf unit file"
ansible.builtin.copy:
src: "/tmp/telegraf-{{ telegraf_agent_version }}/usr/lib/telegraf/scripts/telegraf.service"
remote_src: yes
dest: /etc/systemd/system/telegraf.service
owner: root
group: root
mode: 0755
when:
- telegraf_agent_package_method == "online"

- name: "Archlinux | Copy telegraf unit file"
ansible.builtin.copy:
src: "/tmp/telegraf-{{ telegraf_agent_version }}/usr/lib/telegraf/scripts/telegraf.service"
remote_src: yes
dest: /etc/systemd/system/telegraf.service
owner: root
group: root
mode: 0755
when:
- telegraf_agent_package_method == "online"
register: telegraf_service

- name: Reload systemd
ansible.builtin.systemd:
daemon_reload: yes
when: telegraf_service.changed
5 changes: 5 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
- telegraf
- packages

- name: "Install on Archlinux"
include_tasks: "Archlinux.yml"
when:
- ansible_os_family == "Archlinux" and not telegraf_agent_docker

- name: "Install on Suse"
include_tasks: "Suse.yml"
when: ansible_os_family == "Suse" and not telegraf_agent_docker
Expand Down

0 comments on commit 16cf93f

Please sign in to comment.