add state to awx license module

This commit is contained in:
sean-m-sullivan 2022-06-20 12:37:06 -04:00 committed by Sean Sullivan
parent 923cc671db
commit 7bcceb7e98

View File

@ -31,6 +31,12 @@ options:
unlicensed or trial licensed. When force=true, the license is always applied.
type: bool
default: 'False'
state:
description:
- Desired state of the resource.
default: "present"
choices: ["present", "absent"]
type: str
extends_documentation_fragment: awx.awx.auth
'''
@ -40,6 +46,10 @@ EXAMPLES = '''
- name: Set the license using a file
license:
manifest: "/tmp/my_manifest.zip"
- name: Remove license
license:
state: absent
'''
import base64
@ -50,13 +60,23 @@ def main():
module = ControllerAPIModule(
argument_spec=dict(
manifest=dict(type='str', required=True),
manifest=dict(type='str', required=False),
force=dict(type='bool', default=False),
state=dict(choices=['present', 'absent'], default='present'),
),
required_if=[
['state', 'present', ['manifest']],
],
)
json_output = {'changed': False}
# If the state was absent we can delete the endpoint and exit.
state = module.params.get('state')
if state == 'absent':
module.delete_endpoint('config')
module.exit_json(**json_output)
try:
with open(module.params.get('manifest'), 'rb') as fid:
manifest = base64.b64encode(fid.read())