Add basis of the role

This commit is contained in:
2024-03-01 11:01:15 +01:00
parent fef5c8a0ea
commit bf077a1cca
10 changed files with 151 additions and 0 deletions

9
tasks/check_rapl.yml Normal file
View File

@@ -0,0 +1,9 @@
---
# This file checks for the presence of the intel_rapl_common kernel module, and tries to install it if
# it's not present on the host machine.
- name: Check for RAPL module
community.general.modprobe:
name: intel_rapl_common
state: present
persistent: present

7
tasks/install.yml Normal file
View File

@@ -0,0 +1,7 @@
---
# Installs the scaphandre package and setups the user.
- name: Install the scaphandre package
ansible.builtin.apt:
deb: https://github.com/hubblo-org/scaphandre/releases/download/v{{ scaphandre_version }}/scaphandre_v{{ scaphandre_version }}-{{ scaphandre_arch }}.deb
state: present

14
tasks/main.yml Normal file
View File

@@ -0,0 +1,14 @@
---
# tasks file for hubblo.scaphandre
- name: Import the tasks to check for RAPL kernel module presence
ansible.builtin.import_tasks:
file: check_rapl.yml
- name: Install scaphandre packages
ansible.builtin.import_tasks:
file: install.yml
- name: Configure and install the systemD service
ansible.builtin.import_tasks:
file: systemd-service.yml

39
tasks/systemd-service.yml Normal file
View File

@@ -0,0 +1,39 @@
---
# Creates the user and setups the systemD service.
- name: Ensure group "scaphandre" exists
ansible.builtin.group:
name: scaphandre
state: present
- name: Create scaphandre user
ansible.builtin.user:
name: scaphandre
groups:
- scaphandre
append: true
create_home: true
home: "{{ scaphandre_home_dir }}"
- name: Setup systemD service
ansible.builtin.template:
src: scaphandre.service.j2
dest: /etc/systemd/system/scaphandre.service
owner: root
group: root
mode: "644"
- name: Ensure proper permissions
ansible.builtin.file:
path: "{{ scaphandre_home_dir }}"
state: directory
recurse: true
owner: scaphandre
group: scaphandre
mode: u+rwx,g-wx,o-rwx
- name: Ensure scaphandre is running
ansible.builtin.systemd_service:
state: restarted
daemon_reload: true
name: scaphandre