| 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: architecture |
| 25 |
version_added: 1.0.0 |
| 26 |
short_description: Manage Architectures |
| 27 |
description: |
| 28 |
- Create, update, and delete Architectures |
| 29 |
author: |
| 30 |
- "Manisha Singhal (@Manisha15) ATIX AG" |
| 31 |
options: |
| 32 |
name: |
| 33 |
description: Name of architecture |
| 34 |
required: true |
| 35 |
type: str |
| 36 |
updated_name: |
| 37 |
description: New architecture name. When this parameter is set, the module will not be idempotent. |
| 38 |
type: str |
| 39 |
extends_documentation_fragment: |
| 40 |
- theforeman.foreman.foreman |
| 41 |
- theforeman.foreman.foreman.entity_state |
| 42 |
- theforeman.foreman.foreman.operatingsystems |
| 43 |
''' |
| 44 |
|
| 45 |
EXAMPLES = ''' |
| 46 |
- name: "Create an Architecture" |
| 47 |
theforeman.foreman.architecture: |
| 48 |
name: "i386" |
| 49 |
operatingsystems: |
| 50 |
- "TestOS1" |
| 51 |
- "TestOS2" |
| 52 |
server_url: "https://foreman.example.com" |
| 53 |
username: "admin" |
| 54 |
password: "changeme" |
| 55 |
state: present |
| 56 |
|
| 57 |
- name: "Update an Architecture" |
| 58 |
theforeman.foreman.architecture: |
| 59 |
name: "i386" |
| 60 |
operatingsystems: |
| 61 |
- "TestOS3" |
| 62 |
- "TestOS4" |
| 63 |
server_url: "https://foreman.example.com" |
| 64 |
username: "admin" |
| 65 |
password: "changeme" |
| 66 |
state: present |
| 67 |
|
| 68 |
- name: "Delete an Architecture" |
| 69 |
theforeman.foreman.architecture: |
| 70 |
name: "i386" |
| 71 |
server_url: "https://foreman.example.com" |
| 72 |
username: "admin" |
| 73 |
password: "changeme" |
| 74 |
state: absent |
| 75 |
''' |
| 76 |
|
| 77 |
RETURN = ''' |
| 78 |
entity: |
| 79 |
description: Final state of the affected entities grouped by their type. |
| 80 |
returned: success |
| 81 |
type: dict |
| 82 |
contains: |
| 83 |
architectures: |
| 84 |
description: List of architectures. |
| 85 |
type: list |
| 86 |
elements: dict |
| 87 |
contains: |
| 88 |
id: |
| 89 |
description: Database id of the architecture. |
| 90 |
type: int |
| 91 |
name: |
| 92 |
description: Name of the architecture. |
| 93 |
type: str |
| 94 |
operatinsystem_ids: |
| 95 |
description: Database ids of associated operatingsystems. |
| 96 |
type: list |
| 97 |
elements: int |
| 98 |
''' |
| 99 |
|
| 100 |
from ansible_collections.theforeman.foreman.plugins.module_utils.foreman_helper import ForemanEntityAnsibleModule |
| 101 |
|
| 102 |
|
| 103 |
class ForemanArchitectureModule(ForemanEntityAnsibleModule): |
| 104 |
pass |
| 105 |
|
| 106 |
|
| 107 |
def main(): |
| 108 |
module = ForemanArchitectureModule( |
| 109 |
argument_spec=dict( |
| 110 |
updated_name=dict(), |
| 111 |
), |
| 112 |
foreman_spec=dict( |
| 113 |
name=dict(required=True), |
| 114 |
operatingsystems=dict(type='entity_list'), |
| 115 |
), |
| 116 |
) |
| 117 |
with module.api_connection(): |
| 118 |
module.run() |
| 119 |
|
| 120 |
|
| 121 |
if __name__ == '__main__': |
| 122 |
main() |