| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
""" |
| 8 |
The module file for sonic_fips |
| 9 |
""" |
| 10 |
|
| 11 |
from __future__ import absolute_import, division, print_function |
| 12 |
__metaclass__ = type |
| 13 |
|
| 14 |
|
| 15 |
DOCUMENTATION = """ |
| 16 |
--- |
| 17 |
module: sonic_fips |
| 18 |
version_added: '2.1.0' |
| 19 |
short_description: Manage FIPS configurations on SONiC |
| 20 |
description: |
| 21 |
- This module provides FIPS configuration management to specify the |
| 22 |
security requirements for cryptographic modules in devices running |
| 23 |
SONiC. |
| 24 |
author: 'Balasubramaniam Koundappa(@balasubramaniam-k)' |
| 25 |
options: |
| 26 |
config: |
| 27 |
description: The mode of FIPS configuration with specifications of security requirements for cryptographic modules. |
| 28 |
type: dict |
| 29 |
suboptions: |
| 30 |
enable: |
| 31 |
description: |
| 32 |
- This argument is a boolean value to enable or disable FIPS mode. |
| 33 |
type: bool |
| 34 |
state: |
| 35 |
description: |
| 36 |
- The state specifies the type of configuration update to be performed on the device. |
| 37 |
If the state is "merged", merge specified attributes with existing configured attributes. |
| 38 |
For "deleted", delete the specified attributes from existing configuration. |
| 39 |
type: str |
| 40 |
choices: |
| 41 |
- merged |
| 42 |
- deleted |
| 43 |
default: merged |
| 44 |
""" |
| 45 |
|
| 46 |
EXAMPLES = """ |
| 47 |
# Using "deleted" state |
| 48 |
# |
| 49 |
# Before state: |
| 50 |
# ------------- |
| 51 |
# |
| 52 |
# sonic# show running-configuration | grep fips |
| 53 |
# ! |
| 54 |
# crypto fips enable |
| 55 |
# ! |
| 56 |
|
| 57 |
- name: Delete FIPS mode configuration |
| 58 |
dellemc.enterprise_sonic.sonic_fips: |
| 59 |
config: |
| 60 |
enable: false |
| 61 |
state: deleted |
| 62 |
|
| 63 |
# After state: |
| 64 |
# ------------ |
| 65 |
# sonic# show running-configuration | grep fips |
| 66 |
# sonic# |
| 67 |
|
| 68 |
|
| 69 |
# Using "deleted" state |
| 70 |
# |
| 71 |
# Before state: |
| 72 |
# ------------- |
| 73 |
# |
| 74 |
# sonic# show fips status |
| 75 |
# ! |
| 76 |
# FIPS Mode : Enabled |
| 77 |
# Crypto Library : OpenSSL 1.1.1n-fips 15 Mar 2022 |
| 78 |
# FIPS Object Module : DELL OpenSSL FIPS Crypto Module v2.6 July 2021 |
| 79 |
# ! |
| 80 |
|
| 81 |
- name: Disable FIPS mode |
| 82 |
dellemc.enterprise_sonic.sonic_fips: |
| 83 |
config: |
| 84 |
enable: false |
| 85 |
state: deleted |
| 86 |
|
| 87 |
# After state: |
| 88 |
# ------------ |
| 89 |
# |
| 90 |
# sonic# show fips status |
| 91 |
# ! |
| 92 |
# FIPS Mode : Disabled |
| 93 |
# Crypto Library : OpenSSL 1.1.1n-fips 15 Mar 2022 |
| 94 |
# FIPS Object Module : DELL OpenSSL FIPS Crypto Module v2.6 July 2021 |
| 95 |
# ! |
| 96 |
|
| 97 |
|
| 98 |
# Using "merged" state |
| 99 |
# |
| 100 |
# Before state: |
| 101 |
# ------------- |
| 102 |
# |
| 103 |
# sonic# show running-configuration | grep fips |
| 104 |
# sonic# |
| 105 |
|
| 106 |
- name: Modify FIPS configurations |
| 107 |
dellemc.enterprise_sonic.sonic_fips: |
| 108 |
config: |
| 109 |
enable: true |
| 110 |
state: merged |
| 111 |
|
| 112 |
# After state: |
| 113 |
# ------------ |
| 114 |
# sonic# show running-configuration | grep fips |
| 115 |
# ! |
| 116 |
# crypto fips enable |
| 117 |
# ! |
| 118 |
|
| 119 |
|
| 120 |
# Using "merged" state |
| 121 |
# |
| 122 |
# Before state: |
| 123 |
# ------------- |
| 124 |
# |
| 125 |
# sonic# show fips status |
| 126 |
# ! |
| 127 |
# FIPS Mode : Disabled |
| 128 |
# Crypto Library : OpenSSL 1.1.1n-fips 15 Mar 2022 |
| 129 |
# FIPS Object Module : DELL OpenSSL FIPS Crypto Module v2.6 July 2021 |
| 130 |
# ! |
| 131 |
|
| 132 |
- name: Enable FIPS mode |
| 133 |
dellemc.enterprise_sonic.sonic_fips: |
| 134 |
config: |
| 135 |
enable: true |
| 136 |
state: merged |
| 137 |
|
| 138 |
# After state: |
| 139 |
# ------------ |
| 140 |
# |
| 141 |
# sonic# show fips status |
| 142 |
# ! |
| 143 |
# FIPS Mode : Enabled |
| 144 |
# Crypto Library : OpenSSL 1.1.1n-fips 15 Mar 2022 |
| 145 |
# FIPS Object Module : DELL OpenSSL FIPS Crypto Module v2.6 July 2021 |
| 146 |
# ! |
| 147 |
""" |
| 148 |
|
| 149 |
RETURN = """ |
| 150 |
before: |
| 151 |
description: The configuration prior to the module invocation. |
| 152 |
returned: always |
| 153 |
type: dict |
| 154 |
sample: > |
| 155 |
The configuration returned will always be in the same format |
| 156 |
as the parameters above. |
| 157 |
after: |
| 158 |
description: The resulting configuration module invocation. |
| 159 |
returned: when changed |
| 160 |
type: dict |
| 161 |
sample: > |
| 162 |
The configuration returned will always be in the same format |
| 163 |
as the parameters above. |
| 164 |
commands: |
| 165 |
description: The set of commands pushed to the remote device. |
| 166 |
returned: always |
| 167 |
type: list |
| 168 |
sample: ['command 1', 'command 2', 'command 3'] |
| 169 |
""" |
| 170 |
|
| 171 |
|
| 172 |
from ansible.module_utils.basic import AnsibleModule |
| 173 |
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.fips.fips import FipsArgs |
| 174 |
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.fips.fips import Fips |
| 175 |
|
| 176 |
|
| 177 |
def main(): |
| 178 |
""" |
| 179 |
Main entry point for module execution |
| 180 |
|
| 181 |
:returns: the result form module invocation |
| 182 |
""" |
| 183 |
module = AnsibleModule(argument_spec=FipsArgs.argument_spec, |
| 184 |
supports_check_mode=True) |
| 185 |
|
| 186 |
result = Fips(module).execute_module() |
| 187 |
module.exit_json(**result) |
| 188 |
|
| 189 |
|
| 190 |
if __name__ == '__main__': |
| 191 |
main() |