| 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: host_errata_info |
| 25 |
version_added: 2.1.0 |
| 26 |
short_description: Fetch information about Host Errata |
| 27 |
description: |
| 28 |
- Fetch information about Host Errata |
| 29 |
author: |
| 30 |
- "Evgeni Golov (@evgeni)" |
| 31 |
options: |
| 32 |
host: |
| 33 |
description: |
| 34 |
- Name of the host to fetch errata for. |
| 35 |
required: true |
| 36 |
type: str |
| 37 |
content_view: |
| 38 |
description: |
| 39 |
- Calculate Applicable Errata based on a particular Content View. |
| 40 |
- Required together with I(lifecycle_environment). |
| 41 |
- If this is set, I(organization) also needs to be set. |
| 42 |
required: false |
| 43 |
type: str |
| 44 |
lifecycle_environment: |
| 45 |
description: |
| 46 |
- Calculate Applicable Errata based on a particular Lifecycle Environment. |
| 47 |
- Required together with I(content_view). |
| 48 |
- If this is set, I(organization) also needs to be set. |
| 49 |
required: false |
| 50 |
type: str |
| 51 |
extends_documentation_fragment: |
| 52 |
- theforeman.foreman.foreman |
| 53 |
- theforeman.foreman.foreman.infomodulewithoutname |
| 54 |
''' |
| 55 |
|
| 56 |
EXAMPLES = ''' |
| 57 |
- name: "List installable errata for host" |
| 58 |
theforeman.foreman.host_errata_info: |
| 59 |
username: "admin" |
| 60 |
password: "changeme" |
| 61 |
server_url: "https://foreman.example.com" |
| 62 |
host: "host.example.com" |
| 63 |
|
| 64 |
- name: "List applicable errata for host" |
| 65 |
theforeman.foreman.host_errata_info: |
| 66 |
username: "admin" |
| 67 |
password: "changeme" |
| 68 |
server_url: "https://foreman.example.com" |
| 69 |
organization: "Default Organization" |
| 70 |
host: "host.example.com" |
| 71 |
lifecycle_environment: "Library" |
| 72 |
content_view: "Default Organization View" |
| 73 |
''' |
| 74 |
|
| 75 |
RETURN = ''' |
| 76 |
host_errata: |
| 77 |
description: List of all found errata for the host and their details |
| 78 |
returned: success |
| 79 |
type: list |
| 80 |
elements: dict |
| 81 |
''' |
| 82 |
|
| 83 |
from ansible_collections.theforeman.foreman.plugins.module_utils.foreman_helper import ( |
| 84 |
ForemanInfoAnsibleModule |
| 85 |
) |
| 86 |
|
| 87 |
|
| 88 |
class ForemanHostErrataInfo(ForemanInfoAnsibleModule): |
| 89 |
pass |
| 90 |
|
| 91 |
|
| 92 |
def main(): |
| 93 |
module = ForemanHostErrataInfo( |
| 94 |
foreman_spec=dict( |
| 95 |
name=dict(invisible=True), |
| 96 |
host=dict(type='entity', required=True), |
| 97 |
content_view=dict(type='entity', scope=['organization']), |
| 98 |
lifecycle_environment=dict(type='entity', flat_name='environment_id', scope=['organization']), |
| 99 |
), |
| 100 |
entity_opts=dict( |
| 101 |
resource_type='host_errata', |
| 102 |
), |
| 103 |
required_together=[ |
| 104 |
('content_view', 'lifecycle_environment'), |
| 105 |
], |
| 106 |
required_by={ |
| 107 |
'content_view': 'organization', |
| 108 |
'lifecycle_environment': 'organization', |
| 109 |
}, |
| 110 |
) |
| 111 |
|
| 112 |
with module.api_connection(): |
| 113 |
module.run() |
| 114 |
|
| 115 |
|
| 116 |
if __name__ == '__main__': |
| 117 |
main() |