| 1 |
# Collect facts related to apparmor |
| 2 |
# |
| 3 |
# This file is part of Ansible |
| 4 |
# |
| 5 |
# Ansible is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation, either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# Ansible is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
from __future__ import annotations |
| 19 |
|
| 20 |
import os |
| 21 |
import typing as t |
| 22 |
|
| 23 |
from ansible.module_utils.facts.collector import BaseFactCollector |
| 24 |
|
| 25 |
|
| 26 |
class ApparmorFactCollector(BaseFactCollector): |
| 27 |
name = 'apparmor' |
| 28 |
_fact_ids = set() # type: t.Set[str] |
| 29 |
|
| 30 |
def collect(self, module=None, collected_facts=None): |
| 31 |
facts_dict = {} |
| 32 |
apparmor_facts = {} |
| 33 |
if os.path.exists('/sys/kernel/security/apparmor'): |
| 34 |
apparmor_facts['status'] = 'enabled' |
| 35 |
else: |
| 36 |
apparmor_facts['status'] = 'disabled' |
| 37 |
|
| 38 |
facts_dict['apparmor'] = apparmor_facts |
| 39 |
return facts_dict |