aboutsummaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
Diffstat (limited to 'docker')
-rw-r--r--docker/kolla-ansible/Dockerfile.j26
-rw-r--r--docker/kolla-ansible/find_disks.py73
2 files changed, 77 insertions, 2 deletions
diff --git a/docker/kolla-ansible/Dockerfile.j2 b/docker/kolla-ansible/Dockerfile.j2
index 16fba6064..8d3834662 100644
--- a/docker/kolla-ansible/Dockerfile.j2
+++ b/docker/kolla-ansible/Dockerfile.j2
@@ -17,7 +17,9 @@ RUN pip install -U pip wheel
{% endif %}
-RUN pip --no-cache-dir install shade
+RUN pip --no-cache-dir install \
+ shade \
+ pyudev
RUN git clone --depth 1 -b v2.0.0-0.2.alpha2 https://github.com/ansible/ansible.git \
&& cd ansible \
@@ -28,7 +30,7 @@ RUN mkdir -p /etc/ansible /usr/share/ansible /home/ansible \
&& echo 'localhost ansible_connection=local' > /etc/ansible/hosts \
&& useradd --user-group ansible --groups kolla
-COPY kolla_keystone_service.py kolla_keystone_user.py /usr/share/ansible/
+COPY find_disks.py kolla_keystone_service.py kolla_keystone_user.py /usr/share/ansible/
COPY ansible.cfg /home/ansible/.ansible.cfg
{{ include_footer }}
diff --git a/docker/kolla-ansible/find_disks.py b/docker/kolla-ansible/find_disks.py
new file mode 100644
index 000000000..7b9324b2c
--- /dev/null
+++ b/docker/kolla-ansible/find_disks.py
@@ -0,0 +1,73 @@
+#!/usr/bin/python
+
+# Copyright 2015 Sam Yaple
+#
+# 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.
+
+# This module has been relicensed from the source below:
+# https://github.com/SamYaple/yaodu/blob/master/ansible/library/ceph_osd_list
+
+DOCUMENTATION = '''
+---
+module: find_disks
+short_description: Return list of devices containing a specfied label
+description:
+ - This will return a list of all devices with a GPT partition label with
+ the name specified.
+options:
+ partition_name:
+ description:
+ - Partition name
+ required: True
+ type: bool
+author: Sam Yaple
+'''
+
+EXAMPLES = '''
+- hosts: ceph-osd
+ tasks:
+ - name: Return all valid formated devices with the name KOLLA_CEPH_OSD
+ ceph_osd_list:
+ partition_name: 'KOLLA_CEPH_OSD'
+ register: osds
+'''
+
+import json
+import pyudev
+
+def main():
+ module = AnsibleModule(
+ argument_spec = dict(
+ partition_name = dict(required=True, type='str')
+ )
+ )
+ partition_name = module.params.get('partition_name')
+
+ try:
+ ret = list()
+ ct = pyudev.Context()
+ for dev in ct.list_devices(subsystem='block', DEVTYPE='partition'):
+ if dev.get('ID_PART_ENTRY_NAME') == partition_name:
+ fs_uuid = dev.get('ID_FS_UUID')
+ if not fs_uuid:
+ fs_uuid = ''
+ dev_parent = dev.find_parent('block').device_node
+ ret.append({'device': dev_parent, 'fs_uuid': fs_uuid})
+ module.exit_json(disks=json.dumps(ret))
+ except Exception as e:
+ module.exit_json(failed=True, msg=repr(e))
+
+# import module snippets
+from ansible.module_utils.basic import *
+if __name__ == '__main__':
+ main()