aboutsummaryrefslogtreecommitdiff
path: root/ansible/library
diff options
context:
space:
mode:
authorMichal Nasiadka <mnasiadka@gmail.com>2022-12-30 15:19:27 +0000
committerMichal Nasiadka <mnasiadka@gmail.com>2023-09-05 09:18:38 +0000
commit7cc4bf62031d293487b1714448ba7bb65ed324d6 (patch)
tree60169be3282e81329afa04ea7cb6cf8152bca537 /ansible/library
parent375ecdde07e2bae25179b2454560389097f0573b (diff)
downloadkolla-ansible-7cc4bf62031d293487b1714448ba7bb65ed324d6.tar.gz
kolla-ansible-7cc4bf62031d293487b1714448ba7bb65ed324d6.zip
ovn: Improve clustering
Currently clustering steps are very static, if for a reason first node in the inventory fails and gets re-introduced - K-A will create a second empty cluster on that node. This patch changes the approach and checks if cluster exists, if it does - chooses a donor for the new node from currently running node set. Also it fixes node replacement - it removes old node from cluster (that has the same ip address as newly provisioned node). Closes-Bug: #1875223 Change-Id: Ia025283e38ea7c3bd37c7a70d03f6b46c68f4456
Diffstat (limited to 'ansible/library')
-rw-r--r--ansible/library/kolla_container_volume_facts.py91
1 files changed, 91 insertions, 0 deletions
diff --git a/ansible/library/kolla_container_volume_facts.py b/ansible/library/kolla_container_volume_facts.py
new file mode 100644
index 000000000..b1f471d22
--- /dev/null
+++ b/ansible/library/kolla_container_volume_facts.py
@@ -0,0 +1,91 @@
+# Copyright 2023 StackHPC
+#
+# 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.
+
+
+import docker
+
+from ansible.module_utils.basic import AnsibleModule
+
+DOCUMENTATION = '''
+---
+module: kolla_container_volume_facts
+short_description: Module for collecting Docker container volume facts
+description:
+ - A module targeted at collecting Docker container volume facts. It is used
+ for detecting whether the container volume exists on a host.
+options:
+ container_engine:
+ description:
+ - Name of container engine to use
+ required: True
+ type: str
+ api_version:
+ description:
+ - The version of the api for docker-py to use when contacting docker
+ required: False
+ type: str
+ default: auto
+ name:
+ description:
+ - Name or names of the container volumes
+ required: False
+ type: str or list
+author: Jeffrey Zhang / Michal Nasiadka
+'''
+
+EXAMPLES = '''
+- hosts: all
+ tasks:
+ - name: Gather docker facts
+ kolla_container_volume_facts:
+
+ - name: Gather glance container facts
+ kolla_container_volume_facts:
+ container_engine: docker
+ name:
+ - glance_api
+ - glance_registry
+'''
+
+
+def get_docker_client():
+ return docker.APIClient
+
+
+def main():
+ argument_spec = dict(
+ name=dict(required=False, type='list', default=[]),
+ api_version=dict(required=False, type='str', default='auto'),
+ container_engine=dict(required=True, type='str')
+ )
+
+ module = AnsibleModule(argument_spec=argument_spec)
+
+ results = dict(changed=False, _volumes=[])
+ client = get_docker_client()(version=module.params.get('api_version'))
+ volumes = client.volumes()
+ names = module.params.get('name')
+ if names and not isinstance(names, list):
+ names = [names]
+ for volume in volumes['Volumes']:
+ volume_name = volume['Name']
+ if names and volume_name not in names:
+ continue
+ results['_volumes'].append(volume)
+ results[volume_name] = volume
+ module.exit_json(**results)
+
+
+if __name__ == "__main__":
+ main()