| 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_info |
| 25 |
version_added: 3.5.0 |
| 26 |
short_description: List content exports |
| 27 |
description: |
| 28 |
- List information about content exports. |
| 29 |
author: |
| 30 |
- "Jeremy Lenz (@jeremylenz)" |
| 31 |
options: |
| 32 |
id: |
| 33 |
description: |
| 34 |
- Export history identifier. |
| 35 |
required: false |
| 36 |
type: int |
| 37 |
content_view_version: |
| 38 |
description: |
| 39 |
- Content view version. |
| 40 |
required: false |
| 41 |
type: str |
| 42 |
content_view: |
| 43 |
description: |
| 44 |
- Content view name. |
| 45 |
required: false |
| 46 |
type: str |
| 47 |
destination_server: |
| 48 |
description: |
| 49 |
- Destination server name |
| 50 |
required: false |
| 51 |
type: str |
| 52 |
type: |
| 53 |
description: |
| 54 |
- Specify complete or incremental exports. |
| 55 |
required: false |
| 56 |
type: str |
| 57 |
choices: |
| 58 |
- complete |
| 59 |
- incremental |
| 60 |
extends_documentation_fragment: |
| 61 |
- theforeman.foreman.foreman |
| 62 |
- theforeman.foreman.foreman.katelloinfomodule |
| 63 |
- theforeman.foreman.foreman.infomodulewithoutname |
| 64 |
''' |
| 65 |
|
| 66 |
EXAMPLES = ''' |
| 67 |
- name: "List all full exports in the organization" |
| 68 |
theforeman.foreman.content_export_info: |
| 69 |
organization: "Default Organization" |
| 70 |
type: complete |
| 71 |
username: "admin" |
| 72 |
password: "changeme" |
| 73 |
server_url: "https://foreman.example.com" |
| 74 |
- name: "Get a specific export history and register the result for the next task" |
| 75 |
vars: |
| 76 |
organization_name: "Export Org" |
| 77 |
theforeman.foreman.content_export_info: |
| 78 |
id: 29 |
| 79 |
username: "admin" |
| 80 |
password: "changeme" |
| 81 |
server_url: "https://foreman.example.com" |
| 82 |
organization: "Default Organization" |
| 83 |
register: result |
| 84 |
- name: "Write metadata.json to disk using data from the previous task" |
| 85 |
vars: |
| 86 |
metadata: "{{ result['content_exports'][0]['metadata'] }}" |
| 87 |
ansible.builtin.copy: |
| 88 |
content: "{{ metadata }}" |
| 89 |
dest: ./metadata.json |
| 90 |
- name: "List all exports of a specific content view version" |
| 91 |
theforeman.foreman.content_export_info: |
| 92 |
content_view: RHEL8 |
| 93 |
content_view_version: '1.0' |
| 94 |
username: "admin" |
| 95 |
password: "changeme" |
| 96 |
server_url: "https://foreman.example.com" |
| 97 |
organization: "Default Organization" |
| 98 |
- name: "List all exports marked for a specific destination server" |
| 99 |
theforeman.foreman.content_export_info: |
| 100 |
destination_server: "airgapped.example.com" |
| 101 |
username: "admin" |
| 102 |
password: "changeme" |
| 103 |
server_url: "https://foreman.example.com" |
| 104 |
organization: "Default Organization" |
| 105 |
- name: "List incremental exports of a specific content view marked for a specific destination server" |
| 106 |
theforeman.foreman.content_export_info: |
| 107 |
content_view: RHEL8 |
| 108 |
destination_server: "airgapped.example.com" |
| 109 |
type: incremental |
| 110 |
username: "admin" |
| 111 |
password: "changeme" |
| 112 |
server_url: "https://foreman.example.com" |
| 113 |
organization: "Default Organization" |
| 114 |
- name: "List all exports of a specific content view marked for a specific destination server" |
| 115 |
theforeman.foreman.content_export_info: |
| 116 |
content_view: RHEL8 |
| 117 |
destination_server: "airgapped.example.com" |
| 118 |
username: "admin" |
| 119 |
password: "changeme" |
| 120 |
server_url: "https://foreman.example.com" |
| 121 |
organization: "Default Organization" |
| 122 |
''' |
| 123 |
|
| 124 |
from ansible_collections.theforeman.foreman.plugins.module_utils.foreman_helper import KatelloInfoAnsibleModule |
| 125 |
|
| 126 |
|
| 127 |
class KatelloContentExportInfo(KatelloInfoAnsibleModule): |
| 128 |
pass |
| 129 |
|
| 130 |
|
| 131 |
def main(): |
| 132 |
module = KatelloContentExportInfo( |
| 133 |
foreman_spec=dict( |
| 134 |
id=dict(required=False, type='int'), |
| 135 |
content_view_version=dict(type='entity', scope=['content_view'], required=False), |
| 136 |
content_view=dict(type='entity', scope=['organization'], required=False), |
| 137 |
destination_server=dict(required=False, type='str'), |
| 138 |
type=dict(required=False, type='str', choices=['complete', 'incremental']), |
| 139 |
name=dict(invisible=True), |
| 140 |
), |
| 141 |
) |
| 142 |
|
| 143 |
with module.api_connection(): |
| 144 |
module.run() |
| 145 |
|
| 146 |
|
| 147 |
if __name__ == '__main__': |
| 148 |
main() |