-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathpfsense_system_patch.py
More file actions
119 lines (108 loc) · 2.99 KB
/
pfsense_system_patch.py
File metadata and controls
119 lines (108 loc) · 2.99 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2023, genofire <geno+dev@fireorbit.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = """
---
module: pfsense_system_patch
version_added: 0.6.0
author: Geno (@genofire)
short_description: System Patch
description:
- Manage System Patch
notes:
options:
id:
description: ID of Patch - for update / delete the correct
type: str
required: True
description:
description: The name of the patch in the "System Patch" menu.
type: str
required: False
content:
description: The contents of the patch.
type: str
required: False
src:
description: Path to a patch file.
type: path
required: False
location:
description: Location.
type: str
required: False
default: ""
pathstrip:
description: The number of levels to strip from the front of the path in the patch header.
type: int
required: False
default: 2
basedir:
description: |
Enter the base directory for the patch, default is /.
Patches from github are all based in /.
Custom patches may need a full path here such as /usr/local/www/.
type: str
required: False
default: "/"
ignore_whitespace:
description: Ignore whitespace in the patch.
type: bool
required: False
default: true
auto_apply:
description: Apply the patch automatically when possible, useful for patches to survive after updates.
type: bool
required: False
default: false
state:
description: State in which to leave the interface group.
choices: [ "present", "absent" ]
default: present
type: str
run:
description: State in which to leave the interface group.
choices: [ "no", "apply", "revert" ]
default: "no"
type: str
"""
EXAMPLES = """
- name: Try Systempatch
pfsense_system_patch:
id: "3f60a103a613"
description: "Hello Welt Patch"
content: >
--- b/tmp/test.txt
+++ a/tmp/test.txt
@@ -0,0 +1 @@
+Hello Welt
location: ""
pathstrip: 1
basedir: "/"
ignore_whitespace: true
auto_apply: true
"""
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.pfsensible.core.plugins.module_utils.system_patch import (
PFSenseSystemPatchModule,
SYSTEMPATCH_ARGUMENT_SPEC,
SYSTEMPATCH_MUTUALLY_EXCLUSIVE,
SYSTEMPATCH_REQUIRED_IF
)
def main():
module = AnsibleModule(
argument_spec=SYSTEMPATCH_ARGUMENT_SPEC,
mutually_exclusive=SYSTEMPATCH_MUTUALLY_EXCLUSIVE,
required_if=SYSTEMPATCH_REQUIRED_IF,
supports_check_mode=True)
pfmodule = PFSenseSystemPatchModule(module)
pfmodule.run(module.params)
pfmodule.commit_changes()
if __name__ == '__main__':
main()