diff options
| author | Jenkins <jenkins@review.openstack.org> | 2015-09-25 11:14:56 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2015-09-25 11:14:56 +0000 |
| commit | 0f297ed0ee9e9a2eedf8c846e200321fd0070072 (patch) | |
| tree | 8537924992ecbc1b27b216a60474e6d722f1a555 /docker/ceph/ceph-mon | |
| parent | 32f263b01d73f12779ec0e9653d3caa4a78706d6 (diff) | |
| parent | c86e66c9dc3595199b4b88a526e2c204c12364c8 (diff) | |
| download | kolla-0f297ed0ee9e9a2eedf8c846e200321fd0070072.tar.gz kolla-0f297ed0ee9e9a2eedf8c846e200321fd0070072.zip | |
Merge "Ceph Ansible support"
Diffstat (limited to 'docker/ceph/ceph-mon')
| -rw-r--r-- | docker/ceph/ceph-mon/Dockerfile.j2 | 1 | ||||
| -rw-r--r-- | docker/ceph/ceph-mon/config-external.sh | 30 | ||||
| -rwxr-xr-x | docker/ceph/ceph-mon/fetch_ceph_keys.py | 67 | ||||
| -rwxr-xr-x[-rw-r--r--] | docker/ceph/ceph-mon/start.sh | 12 |
4 files changed, 104 insertions, 6 deletions
diff --git a/docker/ceph/ceph-mon/Dockerfile.j2 b/docker/ceph/ceph-mon/Dockerfile.j2 index e9d47fc70..e8a1337ac 100644 --- a/docker/ceph/ceph-mon/Dockerfile.j2 +++ b/docker/ceph/ceph-mon/Dockerfile.j2 @@ -3,5 +3,6 @@ MAINTAINER Kolla Project (https://launchpad.net/kolla) COPY start.sh / COPY config-external.sh /opt/kolla/ +COPY fetch_ceph_keys.py /usr/bin/ CMD ["/start.sh"] diff --git a/docker/ceph/ceph-mon/config-external.sh b/docker/ceph/ceph-mon/config-external.sh index 75488239c..289cffc86 100644 --- a/docker/ceph/ceph-mon/config-external.sh +++ b/docker/ceph/ceph-mon/config-external.sh @@ -8,3 +8,33 @@ if [[ -f "$SOURCE" ]]; then chown ${OWNER}: $TARGET chmod 0644 $TARGET fi + +SOURCE="/opt/kolla/ceph-mon/ceph.client.admin.keyring" +TARGET="/etc/ceph/ceph.client.admin.keyring" +OWNER="ceph" + +if [[ -f "$SOURCE" ]]; then + cp $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0600 $TARGET +fi + +SOURCE="/opt/kolla/ceph-mon/ceph.client.mon.keyring" +TARGET="/etc/ceph/ceph.client.mon.keyring" +OWNER="ceph" + +if [[ -f "$SOURCE" ]]; then + cp $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0600 $TARGET +fi + +SOURCE="/opt/kolla/ceph-mon/ceph.monmap" +TARGET="/etc/ceph/ceph.monmap" +OWNER="ceph" + +if [[ -f "$SOURCE" ]]; then + cp $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0600 $TARGET +fi diff --git a/docker/ceph/ceph-mon/fetch_ceph_keys.py b/docker/ceph/ceph-mon/fetch_ceph_keys.py new file mode 100755 index 000000000..ab2be9c16 --- /dev/null +++ b/docker/ceph/ceph-mon/fetch_ceph_keys.py @@ -0,0 +1,67 @@ +#!/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 is a stripped down version of an ansible module I wrote in Yaodu to +# achieve the same goals we have for Kolla. I have relicensed it for Kolla +# https://github.com/SamYaple/yaodu/blob/master/ansible/library/bslurp + +# Basically this module will fetch the admin and mon keyrings as well as the +# monmap file. It then hashes the content, compresses them, and finally it +# converts them to base64 to be safely transported around with ansible + +import base64 +import hashlib +import json +import os +import sys +import zlib + + +def json_exit(msg=None, failed=False, changed=False): + if type(msg) is not dict: + msg = {'msg': str(msg)} + msg.update({'failed': failed, 'changed': changed}) + print(json.dumps(msg)) + sys.exit() + + +def read_file(filename): + filename_path = os.path.join('/etc/ceph', filename) + + if not os.path.exists(filename_path): + json_exit("file not found: {}".format(filename_path), failed=True) + if not os.access(filename_path, os.R_OK): + json_exit("file not readable: {}".format(filename_path), failed=True) + + with open(filename_path, 'rb') as f: + raw_data = f.read() + + return {'content': base64.b64encode(zlib.compress(raw_data)), + 'sha1': hashlib.sha1(raw_data).hexdigest(), + 'filename': filename} + + +def main(): + admin_keyring = 'ceph.client.admin.keyring' + mon_keyring = 'ceph.client.mon.keyring' + monmap = 'ceph.monmap' + + files = [admin_keyring, mon_keyring, monmap] + json_exit({filename: read_file(filename) for filename in files}) + + +if __name__ == '__main__': + main() diff --git a/docker/ceph/ceph-mon/start.sh b/docker/ceph/ceph-mon/start.sh index eb5d7f5af..3afaa3ad4 100644..100755 --- a/docker/ceph/ceph-mon/start.sh +++ b/docker/ceph/ceph-mon/start.sh @@ -3,11 +3,11 @@ set -o errexit CMD="/usr/bin/ceph-mon" -ARGS="-d -i ${MON_NAME} --public-addr ${MON_IP}:6789" +ARGS="-d -i $(hostname) --public-addr ${MON_IP}:6789" # Setup common paths -KEYRING_ADMIN="/etc/ceph/ceph.admin.keyring" -KEYRING_MON="/etc/ceph/ceph.mon.keyring" +KEYRING_ADMIN="/etc/ceph/ceph.client.admin.keyring" +KEYRING_MON="/etc/ceph/ceph.client.mon.keyring" MONMAP="/etc/ceph/ceph.monmap" MON_DIR="/var/lib/ceph/mon/ceph-$(hostname)" @@ -21,7 +21,7 @@ set_configs # of the KOLLA_BOOTSTRAP variable being set, including empty. if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then # Lookup our fsid from the ceph.conf - FSID="$(awk '/^fsid/ {print $3; exit}' ${ceph_conf})" + FSID="$(awk '/^fsid/ {print $3; exit}' /etc/ceph/ceph.conf)" # Generating initial keyrings and monmap ceph-authtool --create-keyring "${KEYRING_MON}" --gen-key -n mon. --cap mon 'allow *' @@ -29,8 +29,8 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then ceph-authtool "${KEYRING_MON}" --import-keyring "${KEYRING_ADMIN}" monmaptool --create --add "$(hostname)" "${MON_IP}" --fsid "${FSID}" "${MONMAP}" - # TODO(SamYaple): Return json parsible output to ansible - exit 0 + echo "Sleeping until keys are fetched" + /bin/sleep infinity fi # This section runs on every mon that does not have a keyring already. |
