Browse Source

Merge "Add a new set of modules to support derived params"

tags/1.4.0
Zuul 2 months ago
committed by Gerrit Code Review
parent
commit
43282081d0
21 changed files with 565 additions and 9 deletions
  1. +14
    -0
      doc/source/modules/modules-tripleo_get_flatten_stack.rst
  2. +14
    -0
      doc/source/modules/modules-tripleo_get_flavor_profile.rst
  3. +14
    -0
      doc/source/modules/modules-tripleo_get_introspected_data.rst
  4. +14
    -0
      doc/source/modules/modules-tripleo_get_role_list.rst
  5. +14
    -0
      doc/source/modules/modules-tripleo_reset_params.rst
  6. +6
    -7
      tripleo_ansible/ansible_plugins/module_utils/tripleo_common_utils.py
  7. +1
    -0
      tripleo_ansible/ansible_plugins/modules/baremetal_register_or_update_nodes.py
  8. +1
    -1
      tripleo_ansible/ansible_plugins/modules/os_tripleo_baremetal_configure.py
  9. +1
    -0
      tripleo_ansible/ansible_plugins/modules/tripleo_fernet_keys_rotate.py
  10. +92
    -0
      tripleo_ansible/ansible_plugins/modules/tripleo_get_flatten_stack.py
  11. +94
    -0
      tripleo_ansible/ansible_plugins/modules/tripleo_get_flavor_profile.py
  12. +89
    -0
      tripleo_ansible/ansible_plugins/modules/tripleo_get_introspected_data.py
  13. +107
    -0
      tripleo_ansible/ansible_plugins/modules/tripleo_get_role_list.py
  14. +1
    -0
      tripleo_ansible/ansible_plugins/modules/tripleo_image_params_prepare.py
  15. +1
    -1
      tripleo_ansible/ansible_plugins/modules/tripleo_nova_image_cache.py
  16. +1
    -0
      tripleo_ansible/ansible_plugins/modules/tripleo_passwords_rotate.py
  17. +1
    -0
      tripleo_ansible/ansible_plugins/modules/tripleo_plan_deploy.py
  18. +1
    -0
      tripleo_ansible/ansible_plugins/modules/tripleo_plan_parameters_update.py
  19. +97
    -0
      tripleo_ansible/ansible_plugins/modules/tripleo_reset_params.py
  20. +1
    -0
      tripleo_ansible/ansible_plugins/modules/tripleo_swift_tempurl.py
  21. +1
    -0
      tripleo_ansible/ansible_plugins/modules/tripleo_templates_upload.py

+ 14
- 0
doc/source/modules/modules-tripleo_get_flatten_stack.rst View File

@@ -0,0 +1,14 @@
==================================
Module - tripleo_get_flatten_stack
==================================


This module provides for the following ansible plugin:

* tripleo_get_flatten_stack


.. ansibleautoplugin::
:module: tripleo_ansible/ansible_plugins/modules/tripleo_get_flatten_stack.py
:documentation: true
:examples: true

+ 14
- 0
doc/source/modules/modules-tripleo_get_flavor_profile.rst View File

@@ -0,0 +1,14 @@
===================================
Module - tripleo_get_flavor_profile
===================================


This module provides for the following ansible plugin:

* tripleo_get_flavor_profile


.. ansibleautoplugin::
:module: tripleo_ansible/ansible_plugins/modules/tripleo_get_flavor_profile.py
:documentation: true
:examples: true

+ 14
- 0
doc/source/modules/modules-tripleo_get_introspected_data.rst View File

@@ -0,0 +1,14 @@
======================================
Module - tripleo_get_introspected_data
======================================


This module provides for the following ansible plugin:

* tripleo_get_introspected_data


.. ansibleautoplugin::
:module: tripleo_ansible/ansible_plugins/modules/tripleo_get_introspected_data.py
:documentation: true
:examples: true

+ 14
- 0
doc/source/modules/modules-tripleo_get_role_list.rst View File

@@ -0,0 +1,14 @@
==============================
Module - tripleo_get_role_list
==============================


This module provides for the following ansible plugin:

* tripleo_get_role_list


.. ansibleautoplugin::
:module: tripleo_ansible/ansible_plugins/modules/tripleo_get_role_list.py
:documentation: true
:examples: true

+ 14
- 0
doc/source/modules/modules-tripleo_reset_params.rst View File

@@ -0,0 +1,14 @@
=============================
Module - tripleo_reset_params
=============================


This module provides for the following ansible plugin:

* tripleo_reset_params


.. ansibleautoplugin::
:module: tripleo_ansible/ansible_plugins/modules/tripleo_reset_params.py
:documentation: true
:examples: true

+ 6
- 7
tripleo_ansible/ansible_plugins/module_utils/tripleo_common_utils.py View File

@@ -154,13 +154,12 @@ class TripleOCommon(object):
if 'swift_client' in self.client_cache:
return self.client_cache['swift_client']
else:
self.client_cache['swift_client'] = \
swift_client.Connection(
session=self.sess,
retries=10,
starting_backoff=3,
max_backoff=120
)
self.client_cache['swift_client'] = swift_client.Connection(
session=self.sess,
retries=10,
starting_backoff=3,
max_backoff=120
)
return self.client_cache['swift_client']

def baremetal_configure_boot(self, kwargs):


+ 1
- 0
tripleo_ansible/ansible_plugins/modules/baremetal_register_or_update_nodes.py View File

@@ -64,6 +64,7 @@ options:

author:
- Adriano Petrich (@frac)
requirements: ["openstacksdk", "tripleo-common"]
'''




+ 1
- 1
tripleo_ansible/ansible_plugins/modules/os_tripleo_baremetal_configure.py View File

@@ -46,7 +46,7 @@ options:
type: dict
required: true

requirements: ["openstacksdk"]
requirements: ["openstacksdk", "tripleo-common"]
"""

EXAMPLES = """


+ 1
- 0
tripleo_ansible/ansible_plugins/modules/tripleo_fernet_keys_rotate.py View File

@@ -53,6 +53,7 @@ options:
default: overcloud
author:
- Rabi Mishra (@ramishra)
requirements: ["openstacksdk", "tripleo-common"]
'''

EXAMPLES = '''


+ 92
- 0
tripleo_ansible/ansible_plugins/modules/tripleo_get_flatten_stack.py View File

@@ -0,0 +1,92 @@
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils import tripleo_common_utils as tc
from ansible.module_utils.openstack import openstack_full_argument_spec
from ansible.module_utils.openstack import openstack_module_kwargs
from ansible.module_utils.openstack import openstack_cloud_from_module


DOCUMENTATION = """
---
module: tripleo_get_flatten_stack
short_description: Get the heat stack tree and parameters in flattened structure
extends_documentation_fragment: openstack
author:
- "Kevin Carter (@cloudnull)"
version_added: "2.10"
description:
- This method validates the stack of the container and returns the
parameters and the heat stack tree. The heat stack tree is
flattened for easy consumption.
options:
container:
description:
- Name of plan / container
type: str
required: true

requirements: ["openstacksdk", "tripleo-common"]
"""

EXAMPLES = """
- name: Get flattened stack
tripleo_get_flatten_stack:
cloud: undercloud
container: overcloud
register: flattened_params
"""


import yaml

from tripleo_common.utils import stack_parameters as stack_param_utils


def main():
result = dict(
success=False,
changed=False,
error=None,
)
module = AnsibleModule(
openstack_full_argument_spec(
**yaml.safe_load(DOCUMENTATION)['options']
),
**openstack_module_kwargs()
)
_, conn = openstack_cloud_from_module(module)
tripleo = tc.TripleOCommon(session=conn.session)
try:
result['stack_data'] = stack_param_utils.get_flattened_parameters(
tripleo.get_object_client(),
tripleo.get_orchestration_client(),
module.params["container"]
)
except Exception as exp:
result['error'] = str(exp)
result['msg'] = 'Error flattening stack data for plan {}: {}'.format(
module.params["container"],
exp
)
module.fail_json(**result)
else:
result['success'] = True
module.exit_json(**result)


if __name__ == "__main__":
main()

+ 94
- 0
tripleo_ansible/ansible_plugins/modules/tripleo_get_flavor_profile.py View File

@@ -0,0 +1,94 @@
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils import tripleo_common_utils as tc
from ansible.module_utils.openstack import openstack_full_argument_spec
from ansible.module_utils.openstack import openstack_module_kwargs
from ansible.module_utils.openstack import openstack_cloud_from_module


DOCUMENTATION = """
---
module: tripleo_get_flavor_profile
short_description: Get the flavor profile data
extends_documentation_fragment: openstack
author:
- "Kevin Carter (@cloudnull)"
version_added: "2.10"
description:
- Pull profile from a given flavor
options:
flavor_name:
description:
- Name of flavor
type: str
required: true

requirements: ["openstacksdk", "tripleo-common"]
"""

EXAMPLES = """
- name: Get flavor profile
tripleo_get_flavor_profile:
flavor_name: m1.tiny
register: flavor_profile
"""


import os

import yaml

from tripleo_common import exception
from tripleo_common.utils import stack_parameters as stack_param_utils


def main():
result = dict(
success=False,
changed=False,
error=None,
)
module = AnsibleModule(
openstack_full_argument_spec(
**yaml.safe_load(DOCUMENTATION)['options']
),
**openstack_module_kwargs()
)
_, conn = openstack_cloud_from_module(module)
tripleo = tc.TripleOCommon(session=conn.session)
try:
result['profile'] = tripleo.return_flavor_profile(
module.params["flavor_name"]
)
except exception.DeriveParamsError:
result['profile'] = None
result['success'] = True
module.exit_json(**result)
except Exception as exp:
result['error'] = str(exp)
result['msg'] = 'Error pulling flavor properties for {}: {}'.format(
module.params["flavor_name"],
exp
)
module.fail_json(**result)
else:
result['success'] = True
module.exit_json(**result)


if __name__ == "__main__":
main()

+ 89
- 0
tripleo_ansible/ansible_plugins/modules/tripleo_get_introspected_data.py View File

@@ -0,0 +1,89 @@
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils import tripleo_common_utils as tc
from ansible.module_utils.openstack import openstack_full_argument_spec
from ansible.module_utils.openstack import openstack_module_kwargs
from ansible.module_utils.openstack import openstack_cloud_from_module


DOCUMENTATION = """
---
module: tripleo_get_introspected_data
short_description: Retrieve introspection data
extends_documentation_fragment: openstack
author:
- "Kevin Carter (@cloudnull)"
version_added: "2.10"
description:
- Pull introspection data from a baremetal node.
options:
node_id:
description:
- ID of the baremetal node
type: str
required: true

requirements: ["openstacksdk", "tripleo-common"]
"""

EXAMPLES = """
- name: Get introspected data
tripleo_get_introspected_data:
node_id: xxx
register: introspected_data
"""


import os

import yaml

from tripleo_common import exception


def main():
result = dict(
success=False,
changed=False,
error=None,
)
module = AnsibleModule(
openstack_full_argument_spec(
**yaml.safe_load(DOCUMENTATION)['options']
),
**openstack_module_kwargs()
)
_, conn = openstack_cloud_from_module(module)
tripleo = tc.TripleOCommon(session=conn.session)
try:
result['data'] = tripleo.return_introspected_node_data(
node_id=module.params["node_id"]
)
except Exception as exp:
result['error'] = str(exp)
result['msg'] = 'Error pulling introspection data for {}: {}'.format(
module.params["node_id"],
exp
)
module.fail_json(**result)
else:
result['success'] = True
module.exit_json(**result)


if __name__ == "__main__":
main()

+ 107
- 0
tripleo_ansible/ansible_plugins/modules/tripleo_get_role_list.py View File

@@ -0,0 +1,107 @@
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils import tripleo_common_utils as tc
from ansible.module_utils.openstack import openstack_full_argument_spec
from ansible.module_utils.openstack import openstack_module_kwargs
from ansible.module_utils.openstack import openstack_cloud_from_module


DOCUMENTATION = """
---
module: tripleo_get_role_list
short_description: Lists deployment roles
extends_documentation_fragment: openstack
author:
- "Kevin Carter (@cloudnull)"
version_added: "2.10"
description:
- This action lists all deployment roles residing in the undercloud. A
deployment plan consists of a container marked with metadata
'x-container-meta-usage-tripleo'.
options:
container:
description:
- Name of plan / container
type: str
required: true
role_file_name:
description:
- File name
type: str
default: roles_data.yaml
detail:
description:
- If false displays role names only.
If true, returns all roles data.
type: bool
default: false
valid:
description:
- check if the role has count > 0 in heat environment
type: bool
default: true
requirements: ["openstacksdk", "tripleo-common"]
"""

EXAMPLES = """
- name: configure boot
tripleo_get_role_list:
register: role_list
"""


import os

import yaml

from tripleo_common.utils import roles as roles_utils


def main():
result = dict(
success=False,
changed=False,
error=None,
)
module = AnsibleModule(
openstack_full_argument_spec(
**yaml.safe_load(DOCUMENTATION)['options']
),
**openstack_module_kwargs()
)
_, conn = openstack_cloud_from_module(module)
tripleo = tc.TripleOCommon(session=conn.session)
object_client = tripleo.get_object_client()
try:
result['roles'] = roles_utils.get_roles_from_plan(
object_client,
container=module.params['container'],
role_file_name=module.params['role_file_name'],
detail=module.params['detail'],
valid=module.params['valid']
)
except Exception as exp:
result['error'] = str(exp)
result['msg'] = 'Error listing roles: {}'.format(exp)
module.fail_json(**result)
else:
result['success'] = True
module.exit_json(**result)


if __name__ == "__main__":
main()

+ 1
- 0
tripleo_ansible/ansible_plugins/modules/tripleo_image_params_prepare.py View File

@@ -59,6 +59,7 @@ options:
default: false
author:
- Rabi Mishra (@ramishra)
requirements: ["openstacksdk", "tripleo-common"]
'''

EXAMPLES = '''


+ 1
- 1
tripleo_ansible/ansible_plugins/modules/tripleo_nova_image_cache.py View File

@@ -65,7 +65,7 @@ options:
- Fallback to image download if scp fails
default: false

requirements: ["openstacksdk"]
requirements: ["openstacksdk", "tripleo-common"]
'''

EXAMPLES = '''


+ 1
- 0
tripleo_ansible/ansible_plugins/modules/tripleo_passwords_rotate.py View File

@@ -63,6 +63,7 @@ options:
no_log: true
author:
- Rabi Mishra (@ramishra)
requirements: ["openstacksdk", "tripleo-common"]
'''

EXAMPLES = '''


+ 1
- 0
tripleo_ansible/ansible_plugins/modules/tripleo_plan_deploy.py View File

@@ -65,6 +65,7 @@ options:

author:
- Rabi Mishra (@ramishra)
requirements: ["openstacksdk", "tripleo-common"]
'''

EXAMPLES = '''


+ 1
- 0
tripleo_ansible/ansible_plugins/modules/tripleo_plan_parameters_update.py View File

@@ -70,6 +70,7 @@ options:

author:
- Rabi Mishra (@ramishra)
requirements: ["openstacksdk", "tripleo-common"]
'''

EXAMPLES = '''


+ 97
- 0
tripleo_ansible/ansible_plugins/modules/tripleo_reset_params.py View File

@@ -0,0 +1,97 @@
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils import tripleo_common_utils as tc
from ansible.module_utils.openstack import openstack_full_argument_spec
from ansible.module_utils.openstack import openstack_module_kwargs
from ansible.module_utils.openstack import openstack_cloud_from_module


DOCUMENTATION = """
---
module: tripleo_reset_params
short_description: Reset params
extends_documentation_fragment: openstack
author:
- "Kevin Carter (@cloudnull)"
version_added: "2.10"
description:
- This method will reset params for a given parmeter key.
options:
container:
description:
- Name of plan / container
type: str
required: true
parameter_key:
description:
- Heat parameter key
type: str
default: parameter_defaults
requirements: ["openstacksdk", "tripleo-common"]
"""

EXAMPLES = """
- name: configure boot
tripleo_reset_params:
cloud: undercloud
container: overcloud
parameter_key: parameter_defaults
"""


import os

import yaml

from tripleo_common.utils import stack_parameters as stack_param_utils


def main():
result = dict(
success=False,
changed=False,
error=None,
)
module = AnsibleModule(
openstack_full_argument_spec(
**yaml.safe_load(DOCUMENTATION)['options']
),
**openstack_module_kwargs()
)
_, conn = openstack_cloud_from_module(module)
tripleo = tc.TripleOCommon(session=conn.session)
try:
stack_param_utils.reset_parameters(
swift=tripleo.get_object_client(),
container=module.params["container"],
key=module.params["parameter_key"]
)
result['changed'] = True
except Exception as exp:
result['error'] = str(exp)
result['msg'] = 'Error resetting params for plan {}: {}'.format(
module.params["container"],
exp
)
module.fail_json(**result)
else:
result['success'] = True
module.exit_json(**result)


if __name__ == "__main__":
main()

+ 1
- 0
tripleo_ansible/ansible_plugins/modules/tripleo_swift_tempurl.py View File

@@ -65,6 +65,7 @@ options:

author:
- Rabi Mishra (@ramishra)
requirements: ["openstacksdk", "tripleo-common"]
'''

EXAMPLES = '''


+ 1
- 0
tripleo_ansible/ansible_plugins/modules/tripleo_templates_upload.py View File

@@ -59,6 +59,7 @@ options:
default: '/usr/share/openstack-tripleo-heat-templates/'
author:
- Rabi Mishra (@ramishra)
requirements: ["openstacksdk", "tripleo-common"]
'''

EXAMPLES = '''


Loading…
Cancel
Save