Skip to content

Commit

Permalink
Modify for Amazon Linux 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
yuichisatake committed Apr 11, 2024
1 parent 808cad1 commit 1e1b3fa
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
5 changes: 5 additions & 0 deletions files/amazonlinux-mackerel-v2-2023.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[mackerel]
name=mackerel-agent
baseurl=http://yum.mackerel.io/amznlinux/v2/2023/$basearch
gpgcheck=1
enabled=1
55 changes: 55 additions & 0 deletions files/amazonlinux2023.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
- name: import mackerel GPG key
rpm_key:
key: https://mackerel.io/file/cert/GPG-KEY-mackerel

- name: import mackerel GPG key v2
rpm_key:
key: https://mackerel.io/file/cert/GPG-KEY-mackerel-v2

- name: add repository 'mackerel'
copy:
src: amazonlinux-mackerel.repo
dest: /etc/yum.repos.d/mackerel.repo
owner: root
group: root
mode: 0644

- name: add repository 'mackerel' v2 al2023
copy:
src: amazonlinux-mackerel-v2-2023.repo
dest: /etc/yum.repos.d/mackerel.repo
owner: root
group: root
mode: 0644

- name: install mackerel-agent
dnf:
name: mackerel-agent
state: latest
ignore_errors: "{{ ansible_check_mode }}"

- name: install mackerel-agent-plugins
dnf:
name: mackerel-agent-plugins
state: latest
when: mackerel_use_plugins
ignore_errors: "{{ ansible_check_mode }}"
notify:
- restart mackerel-agent

- name: install mackerel-check-plugins
dnf:
name: mackerel-check-plugins
state: latest
when: mackerel_use_plugins
ignore_errors: "{{ ansible_check_mode }}"
notify:
- restart mackerel-agent

- name: install mkr
dnf:
name: mkr
state: latest
when: mackerel_install_mkr
ignore_errors: "{{ ansible_check_mode }}"
37 changes: 37 additions & 0 deletions files/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
- include: debian.yml
when: ansible_distribution == "Debian" or ansible_distribution == "Ubuntu"

- include: centos.yml
when: ansible_os_family == "RedHat" and ansible_distribution != "Amazon"

- include: amazonlinux.yml
when: ansible_distribution == "Amazon" and ansible_distribution_major_version == "2"

- include: amazonlinux2023.yml
when: ansible_distribution == "Amazon" and ansible_distribution_major_version == "2023"

- name: check config directory
stat:
path: "{{ prefix_dir }}/etc/mackerel-agent"
register: config_directory

- name: create config directory
file:
path: "{{ prefix_dir }}/etc/mackerel-agent"
state: directory
mode: 0755
when: config_directory.stat.exists == false

- name: update config
template:
src: mackerel-agent.conf.j2
dest: "{{ prefix_dir }}/etc/mackerel-agent/mackerel-agent.conf"
notify: restart mackerel-agent

- name: start mackerel-agent
service:
name: mackerel-agent
state: started
when: mackerel_agent_start_on_setup
ignore_errors: "{{ ansible_check_mode }}"

0 comments on commit 1e1b3fa

Please sign in to comment.