| 1 |
# Copyright: Contributors to the Ansible project |
| 2 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 3 |
# Determine if a system is in 'fips' mode |
| 4 |
|
| 5 |
from __future__ import annotations |
| 6 |
|
| 7 |
import typing as t |
| 8 |
|
| 9 |
from ansible.module_utils.facts.utils import get_file_content |
| 10 |
|
| 11 |
from ansible.module_utils.facts.collector import BaseFactCollector |
| 12 |
|
| 13 |
|
| 14 |
class FipsFactCollector(BaseFactCollector): |
| 15 |
name = 'fips' |
| 16 |
_fact_ids = set() # type: t.Set[str] |
| 17 |
|
| 18 |
def collect(self, module=None, collected_facts=None): |
| 19 |
# NOTE: this is populated even if it is not set |
| 20 |
fips_facts = { |
| 21 |
'fips': False |
| 22 |
} |
| 23 |
if get_file_content('/proc/sys/crypto/fips_enabled') == '1': |
| 24 |
fips_facts['fips'] = True |
| 25 |
return fips_facts |