| 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: content_export_version |
| 25 |
version_added: 3.6.0 |
| 26 |
short_description: Manage content view version content exports |
| 27 |
description: |
| 28 |
- Export a content view version to a directory. |
| 29 |
author: |
| 30 |
- "Jeremy Lenz (@jeremylenz)" |
| 31 |
options: |
| 32 |
content_view_version: |
| 33 |
description: |
| 34 |
- Content view version, e.g. "7.0" |
| 35 |
required: true |
| 36 |
type: str |
| 37 |
content_view: |
| 38 |
description: |
| 39 |
- Content view name. |
| 40 |
required: true |
| 41 |
type: str |
| 42 |
destination_server: |
| 43 |
description: |
| 44 |
- Destination server name; optional parameter to differentiate between exports |
| 45 |
required: false |
| 46 |
type: str |
| 47 |
fail_on_missing_content: |
| 48 |
description: |
| 49 |
- Fails if any of the repositories belonging to this version are unexportable. |
| 50 |
required: false |
| 51 |
type: bool |
| 52 |
extends_documentation_fragment: |
| 53 |
- theforeman.foreman.foreman |
| 54 |
- theforeman.foreman.foreman.organization |
| 55 |
- theforeman.foreman.foreman.katelloexport |
| 56 |
''' |
| 57 |
|
| 58 |
EXAMPLES = ''' |
| 59 |
- name: "Export content view version (full)" |
| 60 |
theforeman.foreman.content_export_version: |
| 61 |
content_view: RHEL8 |
| 62 |
content_view_version: '1.0' |
| 63 |
username: "admin" |
| 64 |
password: "changeme" |
| 65 |
server_url: "https://foreman.example.com" |
| 66 |
organization: "Default Organization" |
| 67 |
destination_server: "airgapped.example.com" |
| 68 |
|
| 69 |
- name: "Export content view version (full) in chunks of 10 GB" |
| 70 |
theforeman.foreman.content_export_version: |
| 71 |
content_view: RHEL8 |
| 72 |
content_view_version: '1.0' |
| 73 |
username: "admin" |
| 74 |
password: "changeme" |
| 75 |
server_url: "https://foreman.example.com" |
| 76 |
organization: "Default Organization" |
| 77 |
destination_server: "airgapped.example.com" |
| 78 |
chunk_size_gb: 10 |
| 79 |
|
| 80 |
- name: "Export content view version (full) and fail if any repos are unexportable" |
| 81 |
theforeman.foreman.content_export_version: |
| 82 |
content_view: RHEL8 |
| 83 |
content_view_version: '1.0' |
| 84 |
username: "admin" |
| 85 |
password: "changeme" |
| 86 |
server_url: "https://foreman.example.com" |
| 87 |
organization: "Default Organization" |
| 88 |
destination_server: "airgapped.example.com" |
| 89 |
fail_on_missing_content: true |
| 90 |
|
| 91 |
- name: "Export content view version (incremental) since the most recent export" |
| 92 |
theforeman.foreman.content_export_version: |
| 93 |
content_view: RHEL8 |
| 94 |
content_view_version: '1.0' |
| 95 |
username: "admin" |
| 96 |
password: "changeme" |
| 97 |
server_url: "https://foreman.example.com" |
| 98 |
organization: "Default Organization" |
| 99 |
destination_server: "airgapped.example.com" |
| 100 |
incremental: true |
| 101 |
|
| 102 |
- name: "Export content view version (incremental) since a specific export" |
| 103 |
theforeman.foreman.content_export_version: |
| 104 |
content_view: RHEL8 |
| 105 |
content_view_version: '1.0' |
| 106 |
username: "admin" |
| 107 |
password: "changeme" |
| 108 |
server_url: "https://foreman.example.com" |
| 109 |
organization: "Default Organization" |
| 110 |
destination_server: "airgapped.example.com" |
| 111 |
incremental: true |
| 112 |
from_history_id: 12345 |
| 113 |
''' |
| 114 |
|
| 115 |
from ansible_collections.theforeman.foreman.plugins.module_utils.foreman_helper import KatelloContentExportBaseModule |
| 116 |
|
| 117 |
|
| 118 |
class KatelloContentExportModule(KatelloContentExportBaseModule): |
| 119 |
pass |
| 120 |
|
| 121 |
|
| 122 |
def main(): |
| 123 |
module = KatelloContentExportModule( |
| 124 |
foreman_spec=dict( |
| 125 |
content_view_version=dict(type='entity', scope=['content_view'], search_by='version', flat_name='id', required=True), |
| 126 |
content_view=dict(type='entity', scope=['organization'], required=True), |
| 127 |
destination_server=dict(required=False, type='str'), |
| 128 |
fail_on_missing_content=dict(required=False, type='bool'), |
| 129 |
), |
| 130 |
export_action='version', |
| 131 |
) |
| 132 |
|
| 133 |
with module.api_connection(): |
| 134 |
module.run() |
| 135 |
|
| 136 |
|
| 137 |
if __name__ == '__main__': |
| 138 |
main() |