| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
from __future__ import absolute_import, division, print_function |
| 19 |
__metaclass__ = type |
| 20 |
|
| 21 |
|
| 22 |
DOCUMENTATION = ''' |
| 23 |
--- |
| 24 |
module: scap_content |
| 25 |
version_added: 1.0.0 |
| 26 |
short_description: Manage SCAP content |
| 27 |
description: |
| 28 |
- Create, update, and delete SCAP content |
| 29 |
author: |
| 30 |
- "Jameer Pathan (@jameerpathan111)" |
| 31 |
options: |
| 32 |
title: |
| 33 |
description: |
| 34 |
- Title of SCAP content. |
| 35 |
required: true |
| 36 |
type: str |
| 37 |
updated_title: |
| 38 |
description: |
| 39 |
- New SCAP content title. |
| 40 |
- When this parameter is set, the module will not be idempotent. |
| 41 |
type: str |
| 42 |
extends_documentation_fragment: |
| 43 |
- theforeman.foreman.foreman |
| 44 |
- theforeman.foreman.foreman.entity_state |
| 45 |
- theforeman.foreman.foreman.taxonomy |
| 46 |
- theforeman.foreman.foreman.scap_datastream |
| 47 |
''' |
| 48 |
|
| 49 |
EXAMPLES = ''' |
| 50 |
- name: Create SCAP content |
| 51 |
theforeman.foreman.scap_content: |
| 52 |
title: "Red Hat firefox default content" |
| 53 |
scap_file: "/home/user/Downloads/ssg-firefox-ds.xml" |
| 54 |
original_filename: "ssg-firefox-ds.xml" |
| 55 |
organizations: |
| 56 |
- "Default Organization" |
| 57 |
locations: |
| 58 |
- "Default Location" |
| 59 |
server_url: "https://foreman.example.com" |
| 60 |
username: "admin" |
| 61 |
password: "changeme" |
| 62 |
state: present |
| 63 |
|
| 64 |
- name: Update SCAP content |
| 65 |
theforeman.foreman.scap_content: |
| 66 |
title: "Red Hat firefox default content" |
| 67 |
updated_title: "Updated scap content title" |
| 68 |
scap_file: "/home/user/Downloads/updated-ssg-firefox-ds.xml" |
| 69 |
original_filename: "updated-ssg-firefox-ds.xml" |
| 70 |
organizations: |
| 71 |
- "Org One" |
| 72 |
- "Org Two" |
| 73 |
locations: |
| 74 |
- "Loc One" |
| 75 |
- "Loc Two" |
| 76 |
server_url: "https://foreman.example.com" |
| 77 |
username: "admin" |
| 78 |
password: "changeme" |
| 79 |
state: present |
| 80 |
|
| 81 |
- name: Delete SCAP content |
| 82 |
theforeman.foreman.scap_content: |
| 83 |
title: "Red Hat firefox default content" |
| 84 |
server_url: "https://foreman.example.com" |
| 85 |
username: "admin" |
| 86 |
password: "changeme" |
| 87 |
state: absent |
| 88 |
''' |
| 89 |
|
| 90 |
RETURN = ''' |
| 91 |
entity: |
| 92 |
description: Final state of the affected entities grouped by their type. |
| 93 |
returned: success |
| 94 |
type: dict |
| 95 |
contains: |
| 96 |
scap_contents: |
| 97 |
description: List of scap contents. |
| 98 |
type: list |
| 99 |
elements: dict |
| 100 |
''' |
| 101 |
|
| 102 |
from ansible_collections.theforeman.foreman.plugins.module_utils.foreman_helper import ForemanScapDataStreamModule |
| 103 |
|
| 104 |
|
| 105 |
class ForemanScapContentModule(ForemanScapDataStreamModule): |
| 106 |
pass |
| 107 |
|
| 108 |
|
| 109 |
def main(): |
| 110 |
module = ForemanScapContentModule( |
| 111 |
argument_spec=dict( |
| 112 |
updated_title=dict(type='str'), |
| 113 |
), |
| 114 |
foreman_spec=dict( |
| 115 |
title=dict(type='str', required=True), |
| 116 |
), |
| 117 |
entity_key='title', |
| 118 |
required_plugins=[('openscap', ['*'])], |
| 119 |
) |
| 120 |
|
| 121 |
with module.api_connection(): |
| 122 |
module.run() |
| 123 |
|
| 124 |
|
| 125 |
if __name__ == '__main__': |
| 126 |
main() |