Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add manage_operating_system role #594

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions roles/manage_operating_system/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# manage_operating_system

This role is for managing operating system settings.

## Requirements

Following are the requirements of this role.
1. Ansible
2. An already initialized system running Linux.

## Role Variables

When executing the role via Ansible these are the applicable variables:

* ***enable_user_profiling***

When `true`, sets relevant operating system settings such that any user and
profile the system as well as disabling any masking of operating system
kernel memory addresses. Default: `false`

These variables can be assigned in the `pre_tasks` definition of the Playbook.

## Example Playbook

### Inventory file content

Content of the `inventory.yml`:

```yaml
all:
children:
primary:
hosts:
pgsql1.dbt2.internal:
ansible_host: 10.1.1.3
private_ip: 10.1.1.3
```

### Playbook file content

Content of the `inventory.yml` file:

```yaml
---
- hosts: all
name: Example
become: yes

pre_tasks:
- name: Initialize the user defined variables
ansible.builtin.set_fact:
enable_user_profiling: true

collections:
- edb_devops.edb_postgres

roles:
- role: manage_operating_system
```

## Playbook execution examples

```bash
$ ansible-playbook playbook.yml \
-i inventory.yml \
-u centos \
--private-key <key.pem> \
--extra-vars="enable_user_profiling=true"
```

## License

BSD

## Author information

Author:

* Mark Wong
* EDB Postgres
* edb-devops@enterprisedb.com www.enterprisedb.com
2 changes: 2 additions & 0 deletions roles/manage_operating_system/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
enable_user_profiling: false
14 changes: 14 additions & 0 deletions roles/manage_operating_system/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
galaxy_info:
author: EDB
description: Manage Operating System
company: "EnterpriseDB"

license: BSD

min_ansible_version: "2.8"

galaxy_tags:
- operating system

dependencies: []
12 changes: 12 additions & 0 deletions roles/manage_operating_system/tasks/disable_user_profiling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: reset use of all profiling events by all users
ansible.posix.sysctl:
name: kernel.perf_event_paranoid
state: absent
become: true

- name: reset restrictions on exposing kernel address
ansible.posix.sysctl:
name: kernel.kptr_restrict
state: absent
become: true
18 changes: 18 additions & 0 deletions roles/manage_operating_system/tasks/enable_user_profiling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: allow use of all profiling events by all users
ansible.posix.sysctl:
name: kernel.perf_event_paranoid
value: '-1'
sysctl_set: true
state: present
reload: true
become: true

- name: remove restrictions on exposing kernel address
ansible.posix.sysctl:
name: kernel.kptr_restrict
value: '0'
sysctl_set: true
state: present
reload: true
become: true
5 changes: 5 additions & 0 deletions roles/manage_operating_system/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Enable user level profiling
ansible.builtin.include_tasks: enable_user_profiling.yml
when:
- enable_user_profiling | bool
Loading