| 1 |
|
| 2 |
from __future__ import absolute_import, division, print_function |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
__metaclass__ = type |
| 7 |
|
| 8 |
ANSIBLE_METADATA = {'status': ['preview'], |
| 9 |
'supported_by': 'community', |
| 10 |
'metadata_version': '1.1'} |
| 11 |
|
| 12 |
DOCUMENTATION = ''' |
| 13 |
--- |
| 14 |
module: fmgr_securityconsole_reinstall_package |
| 15 |
short_description: Re-install a policy package that had been previously installed. |
| 16 |
version_added: "2.0.0" |
| 17 |
extends_documentation_fragment: |
| 18 |
- fortinet.fortimanager.general |
| 19 |
options: |
| 20 |
securityconsole_reinstall_package: |
| 21 |
description: The top level parameters set. |
| 22 |
required: false |
| 23 |
type: dict |
| 24 |
suboptions: |
| 25 |
adom: |
| 26 |
type: str |
| 27 |
description: Source ADOM name. |
| 28 |
flags: |
| 29 |
type: list |
| 30 |
elements: str |
| 31 |
description: |
| 32 |
- cp_all_objs - Assign all objects during global policy assignment. |
| 33 |
- preview - Generate preview cache only. |
| 34 |
- generate_rev - Generate new ADOM revision before install. |
| 35 |
- copy_assigned_pkg - For global policy assignment - copy assigned package from ADOM to device. |
| 36 |
- unassign - Remove global policy from ADOM. |
| 37 |
- ifpolicy_only - Only install interface policies. |
| 38 |
- no_ifpolicy - Install regular policies only - do not install interface policies. |
| 39 |
- objs_only - Install object |
| 40 |
- auto_lock_ws - Automatically lock and unlock workspace when performing security console task. |
| 41 |
- copy_only - Only copy to device db. |
| 42 |
choices: ['none', 'cp_all_objs', 'preview', 'generate_rev', 'copy_assigned_pkg', |
| 43 |
'unassign', 'ifpolicy_only', 'no_ifpolicy', 'objs_only', 'auto_lock_ws', |
| 44 |
'check_pkg_st', 'copy_only'] |
| 45 |
target: |
| 46 |
type: list |
| 47 |
elements: dict |
| 48 |
description: Target. |
| 49 |
suboptions: |
| 50 |
pkg: |
| 51 |
type: str |
| 52 |
description: Source package path and name. |
| 53 |
scope: |
| 54 |
type: list |
| 55 |
elements: dict |
| 56 |
description: Scope. |
| 57 |
suboptions: |
| 58 |
name: |
| 59 |
type: str |
| 60 |
description: Name. |
| 61 |
vdom: |
| 62 |
type: str |
| 63 |
description: Vdom. |
| 64 |
''' |
| 65 |
|
| 66 |
EXAMPLES = ''' |
| 67 |
- name: Example playbook (generated based on argument schema) |
| 68 |
hosts: fortimanagers |
| 69 |
connection: httpapi |
| 70 |
gather_facts: false |
| 71 |
tasks: |
| 72 |
- name: Re-install a policy package that had been previously installed. |
| 73 |
fortinet.fortimanager.fmgr_securityconsole_reinstall_package: |
| 74 |
# workspace_locking_adom: <global or your adom name> |
| 75 |
securityconsole_reinstall_package: |
| 76 |
# adom: <string> |
| 77 |
# flags: ["none", "cp_all_objs", "preview", "generate_rev", "copy_assigned_pkg", |
| 78 |
# "unassign", "ifpolicy_only", "no_ifpolicy", "objs_only", "auto_lock_ws", |
| 79 |
# "check_pkg_st", "copy_only"] |
| 80 |
# target: |
| 81 |
# - pkg: <string> |
| 82 |
# scope: |
| 83 |
# - name: <string> |
| 84 |
# vdom: <string> |
| 85 |
''' |
| 86 |
|
| 87 |
RETURN = ''' |
| 88 |
meta: |
| 89 |
description: The result of the request. |
| 90 |
type: dict |
| 91 |
returned: always |
| 92 |
contains: |
| 93 |
request_url: |
| 94 |
description: The full url requested. |
| 95 |
returned: always |
| 96 |
type: str |
| 97 |
sample: /sys/login/user |
| 98 |
response_code: |
| 99 |
description: The status of api request. |
| 100 |
returned: always |
| 101 |
type: int |
| 102 |
sample: 0 |
| 103 |
response_data: |
| 104 |
description: The api response. |
| 105 |
type: list |
| 106 |
returned: always |
| 107 |
response_message: |
| 108 |
description: The descriptive message of the api response. |
| 109 |
type: str |
| 110 |
returned: always |
| 111 |
sample: OK. |
| 112 |
system_information: |
| 113 |
description: The information of the target system. |
| 114 |
type: dict |
| 115 |
returned: always |
| 116 |
rc: |
| 117 |
description: The status the request. |
| 118 |
type: int |
| 119 |
returned: always |
| 120 |
sample: 0 |
| 121 |
version_check_warning: |
| 122 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 123 |
type: list |
| 124 |
returned: complex |
| 125 |
''' |
| 126 |
from ansible.module_utils.basic import AnsibleModule |
| 127 |
from ansible.module_utils.connection import Connection |
| 128 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 129 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 130 |
|
| 131 |
|
| 132 |
def main(): |
| 133 |
urls_list = [ |
| 134 |
'/securityconsole/reinstall/package' |
| 135 |
] |
| 136 |
module_arg_spec = { |
| 137 |
'securityconsole_reinstall_package': { |
| 138 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 139 |
'options': { |
| 140 |
'adom': {'type': 'str'}, |
| 141 |
'flags': { |
| 142 |
'type': 'list', |
| 143 |
'choices': [ |
| 144 |
'none', 'cp_all_objs', 'preview', 'generate_rev', 'copy_assigned_pkg', 'unassign', 'ifpolicy_only', 'no_ifpolicy', 'objs_only', |
| 145 |
'auto_lock_ws', 'check_pkg_st', 'copy_only' |
| 146 |
], |
| 147 |
'elements': 'str' |
| 148 |
}, |
| 149 |
'target': { |
| 150 |
'type': 'list', |
| 151 |
'options': { |
| 152 |
'pkg': {'type': 'str'}, |
| 153 |
'scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'} |
| 154 |
}, |
| 155 |
'elements': 'dict' |
| 156 |
} |
| 157 |
} |
| 158 |
} |
| 159 |
} |
| 160 |
|
| 161 |
module_option_spec = get_module_arg_spec('exec') |
| 162 |
module_arg_spec.update(module_option_spec) |
| 163 |
check_galaxy_version(module_arg_spec) |
| 164 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'securityconsole_reinstall_package'), |
| 165 |
supports_check_mode=True) |
| 166 |
if not module._socket_path: |
| 167 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 168 |
connection = Connection(module._socket_path) |
| 169 |
fmgr = NAPIManager('exec', module_arg_spec, urls_list, |
| 170 |
None, 'data', module, connection) |
| 171 |
fmgr.process_exec() |
| 172 |
module.exit_json(meta=module.params) |
| 173 |
|
| 174 |
|
| 175 |
if __name__ == '__main__': |
| 176 |
main() |