summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/mongodb/roles/mongodb_selinux/tasks/main.yml
blob: b80c4c7cb5e212ea8e41c713690b41d9eb612d98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
# tasks file for mongodb_selinux
- name: Include OS-specific vars
  include_vars:
    file: "{{ lookup('first_found', params) }}"
  vars:
    params:
      paths:
        - "vars"
      files:
        - "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_version }}.yml"
        - "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml"
        - "{{ ansible_facts.distribution }}.yml"
        - "{{ ansible_facts.os_family }}.yml"
        - default.yml
  tags:
    - "vars"

- name: Install required packages
  package:
    name: "{{ required_packages }}"
  register: _pkg
  until: _pkg is succeeded
  retries: 5
  tags:
    - "pkg"
    - "setup"

- name: Copy custom MongoDB SeLinux Policy to Host
  copy:
    content: |
      module mongodb_cgroup_memory 1.0;

      require {
          type cgroup_t;
          type mongod_t;
          class dir search;
          class file { getattr open read };
      }

      #============= mongod_t ==============
      allow mongod_t cgroup_t:dir search;
      allow mongod_t cgroup_t:file { getattr open read };
    dest: /root/mongodb_cgroup_memory.te
  register: mongodb_policy
  tags:
    - "setup"
    - "mongodb"
    - "linux"

- name: Compile & Install MongoDB Policy
  script: files/compile_mongodb_selinux.sh
  when: mongodb_policy.changed
  tags:
    - "setup"
    - "mongodb"
    - "linux"