mirror of
https://github.com/ansible/awx.git
synced 2026-02-24 14:36:00 -03:30
add state to awx license module
This commit is contained in:
committed by
Sean Sullivan
parent
923cc671db
commit
7bcceb7e98
@@ -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())
|
||||||
|
|||||||
Reference in New Issue
Block a user