diff --git a/awx_collection/plugins/modules/license.py b/awx_collection/plugins/modules/license.py index dfb4c1745ce0..5cea090d5e35 100644 --- a/awx_collection/plugins/modules/license.py +++ b/awx_collection/plugins/modules/license.py @@ -31,6 +31,12 @@ 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 @@ - 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())