fixup return values for bulk launch and host create in awxkit

Enabled the params bulk job

make black

make black again

Fixed inventory and organization input params for bulk modules

add collection integration tests

Fix cli return errors

fix test completeness
This commit is contained in:
Elijah DeLee
2023-02-03 10:08:24 -05:00
parent 266ebe5501
commit 9e037f1a02
11 changed files with 365 additions and 42 deletions

View File

@@ -16,22 +16,43 @@ author: "Seth Foster (@fosterseth)"
short_description: Bulk host create in Automation Platform Controller
description:
- Single-request bulk host creation in Automation Platform Controller.
- Designed to efficiently add many hosts to an inventory.
- Provides a way to add many hosts at once to an inventory in Controller.
options:
hosts:
description:
- List of hosts to add to inventory.
required: True
type: str
type: list
elements: dict
suboptions:
name:
description:
- The name to use for the host.
type: str
require: True
description:
- The description to use for the host.
type: str
enabled:
description:
- If the host should be enabled.
type: bool
variables:
description:
- Variables to use for the host.
type: dict
instance_id:
description:
- instance_id to use for the host.
type: str
inventory:
description:
- Inventory the hosts should be made a member of.
- Inventory ID the hosts should be made a member of.
required: True
type: str
type: int
extends_documentation_fragment: awx.awx.auth
'''
EXAMPLES = '''
- name: Bulk host create
bulk_host_create:
@@ -44,11 +65,12 @@ EXAMPLES = '''
from ..module_utils.controller_api import ControllerAPIModule
import json
def main():
# Any additional arguments that are not fields of the item can be added here
argument_spec = dict(
hosts=dict(required=True, type='list'),
inventory=dict(),
inventory=dict(required=True, type='int'),
)
# Create a module for ourselves
@@ -58,6 +80,9 @@ def main():
inventory = module.params.get('inventory')
hosts = module.params.get('hosts')
for h in hosts:
if 'variables' in h:
h['variables'] = json.dumps(h['variables'])
# Launch the jobs
result = module.post_endpoint("bulk/host_create", data={"inventory": inventory, "hosts": hosts})
@@ -70,4 +95,4 @@ def main():
if __name__ == '__main__':
main()
main()