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. unlicensed or trial licensed. When force=true, the license is always applied.
type: bool type: bool
default: 'False' default: 'False'
state:
description:
- Desired state of the resource.
default: "present"
choices: ["present", "absent"]
type: str
extends_documentation_fragment: awx.awx.auth extends_documentation_fragment: awx.awx.auth
''' '''
@@ -40,6 +46,10 @@ EXAMPLES = '''
- name: Set the license using a file - name: Set the license using a file
license: license:
manifest: "/tmp/my_manifest.zip" manifest: "/tmp/my_manifest.zip"
- name: Remove license
license:
state: absent
''' '''
import base64 import base64
@@ -50,13 +60,23 @@ def main():
module = ControllerAPIModule( module = ControllerAPIModule(
argument_spec=dict( argument_spec=dict(
manifest=dict(type='str', required=True), manifest=dict(type='str', required=False),
force=dict(type='bool', default=False), force=dict(type='bool', default=False),
state=dict(choices=['present', 'absent'], default='present'),
), ),
required_if=[
['state', 'present', ['manifest']],
],
) )
json_output = {'changed': False} 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: try:
with open(module.params.get('manifest'), 'rb') as fid: with open(module.params.get('manifest'), 'rb') as fid:
manifest = base64.b64encode(fid.read()) manifest = base64.b64encode(fid.read())