mso_st_deploy: Add state 'undeploy' (#55093)
This adds undeploy support to mso_schema_template_deploy.
This commit is contained in:
parent
166a33ef4d
commit
524a418a08
1 changed files with 29 additions and 3 deletions
|
@ -31,12 +31,17 @@ options:
|
||||||
- The name of the template.
|
- The name of the template.
|
||||||
type: str
|
type: str
|
||||||
aliases: [ name ]
|
aliases: [ name ]
|
||||||
|
site:
|
||||||
|
description:
|
||||||
|
- The name of the site B(to undeploy).
|
||||||
|
type: str
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Use C(deploy) to deploy schema template.
|
- Use C(deploy) to deploy schema template.
|
||||||
- Use C(status) to get deployment status.
|
- Use C(status) to get deployment status.
|
||||||
|
- Use C(undeploy) to deploy schema template from a site.
|
||||||
type: str
|
type: str
|
||||||
choices: [ deploy, status ]
|
choices: [ deploy, status, undeploy ]
|
||||||
default: deploy
|
default: deploy
|
||||||
seealso:
|
seealso:
|
||||||
- module: mso_schema_site
|
- module: mso_schema_site
|
||||||
|
@ -55,6 +60,17 @@ EXAMPLES = r'''
|
||||||
state: deploy
|
state: deploy
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Undeploy a schema template
|
||||||
|
mso_schema_template:
|
||||||
|
host: mso_host
|
||||||
|
username: admin
|
||||||
|
password: SomeSecretPassword
|
||||||
|
schema: Schema 1
|
||||||
|
template: Template 1
|
||||||
|
site: Site 1
|
||||||
|
state: undeploy
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Get deployment status
|
- name: Get deployment status
|
||||||
mso_schema:
|
mso_schema:
|
||||||
host: mso_host
|
host: mso_host
|
||||||
|
@ -79,16 +95,21 @@ def main():
|
||||||
argument_spec.update(
|
argument_spec.update(
|
||||||
schema=dict(type='str', required=True),
|
schema=dict(type='str', required=True),
|
||||||
template=dict(type='str', required=True, aliases=['name']),
|
template=dict(type='str', required=True, aliases=['name']),
|
||||||
state=dict(type='str', default='deploy', choices=['deploy', 'status']),
|
site=dict(type='str'),
|
||||||
|
state=dict(type='str', default='deploy', choices=['deploy', 'status', 'undeploy']),
|
||||||
)
|
)
|
||||||
|
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=argument_spec,
|
argument_spec=argument_spec,
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
|
required_if=[
|
||||||
|
['state', 'undeploy', ['site']],
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
schema = module.params['schema']
|
schema = module.params['schema']
|
||||||
template = module.params['template']
|
template = module.params['template']
|
||||||
|
site = module.params['site']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
|
||||||
mso = MSOModule(module)
|
mso = MSOModule(module)
|
||||||
|
@ -101,13 +122,18 @@ def main():
|
||||||
templateName=template,
|
templateName=template,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
qs = None
|
||||||
if state == 'deploy':
|
if state == 'deploy':
|
||||||
path = 'execute/schema/{0}/template/{1}'.format(schema_id, template)
|
path = 'execute/schema/{0}/template/{1}'.format(schema_id, template)
|
||||||
elif state == 'status':
|
elif state == 'status':
|
||||||
path = 'status/schema/{0}/template/{1}'.format(schema_id, template)
|
path = 'status/schema/{0}/template/{1}'.format(schema_id, template)
|
||||||
|
elif state == 'undeploy':
|
||||||
|
path = 'execute/schema/{0}/template/{1}'.format(schema_id, template)
|
||||||
|
site_id = mso.lookup_site(site)
|
||||||
|
qs = dict(undeploy=site_id)
|
||||||
|
|
||||||
if not module.check_mode:
|
if not module.check_mode:
|
||||||
status = mso.request(path, method='GET', data=payload)
|
status = mso.request(path, method='GET', data=payload, qs=qs)
|
||||||
|
|
||||||
mso.exit_json(**status)
|
mso.exit_json(**status)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue