From 764e69718682864b3f468a0e62643ee163bf32f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Mon, 28 Aug 2017 23:23:36 +0200 Subject: [PATCH] ceph-docker-common: detect ceph version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By detecting the ceph version running in the container we can easily apply conditions like: ceph_release_num.{{ ceph_release }} >= ceph_release_num.luminous We do that already, in ceph-docker-common/tasks/fetch_configs.yml. This fixes the error: TASK [ceph-docker-common : register rbd bootstrap key] ****************************************************** fatal: [magna005]: FAILED! => {"failed": true, "msg": "The conditional check 'ceph_release_num.{{ ceph_release }} >= ceph_release_num.luminous' failed. The error was: error while evaluating conditional (ceph_release_num.{{ ceph_release }} >= ceph_release_num.luminous): 'dict object' has no attribute 'dummy'\n\nThe error appears to have been in '/home/ubuntu/ceph-ansible/roles/ceph-docker-common/tasks/fetch_configs.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: register rbd bootstrap key\n ^ here\n"} Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1486062 Signed-off-by: Sébastien Han --- roles/ceph-docker-common/tasks/main.yml | 21 ++++++++++++++++----- roles/ceph-docker-common/tasks/release.yml | 13 +++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 roles/ceph-docker-common/tasks/release.yml diff --git a/roles/ceph-docker-common/tasks/main.yml b/roles/ceph-docker-common/tasks/main.yml index 3701fd90e..9c16f5d62 100644 --- a/roles/ceph-docker-common/tasks/main.yml +++ b/roles/ceph-docker-common/tasks/main.yml @@ -44,28 +44,39 @@ - ceph_health.rc != 0 - not "{{ rolling_update | default(false) }}" -- include: "./misc/ntp_atomic.yml" +- include: ./misc/ntp_atomic.yml when: - is_atomic - ansible_os_family == 'RedHat' - ntp_service_enabled -- include: "./misc/ntp_redhat.yml" +- include: ./misc/ntp_redhat.yml when: - not is_atomic - ansible_os_family == 'RedHat' - ntp_service_enabled -- include: "./misc/ntp_debian.yml" +- include: ./misc/ntp_debian.yml when: - ansible_os_family == 'Debian' - ntp_service_enabled -- include: "./fetch_image.yml" +- include: fetch_image.yml + +- name: get ceph version + command: docker run --entrypoint /usr/bin/ceph {{ ceph_docker_registry}}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} --version + changed_when: false + always_run: yes + register: ceph_version + +- set_fact: + ceph_version: "{{ ceph_version.stdout.split(' ')[2] }}" + +- include: release.yml # NOTE (jimcurtis): dirs_permissions.yml must precede fetch_configs.yml # # because it creates the directories needed by the latter. -- include: ./dirs_permissions.yml +- include: dirs_permissions.yml - include: create_configs.yml diff --git a/roles/ceph-docker-common/tasks/release.yml b/roles/ceph-docker-common/tasks/release.yml new file mode 100644 index 000000000..f8301ca75 --- /dev/null +++ b/roles/ceph-docker-common/tasks/release.yml @@ -0,0 +1,13 @@ +--- +- set_fact: + ceph_release: jewel + when: ceph_version.split('.')[0] | version_compare('10', '==') + +- set_fact: + ceph_release: kraken + when: ceph_version.split('.')[0] | version_compare('11', '==') + +- set_fact: + ceph_release: luminous + when: ceph_version.split('.')[0] | version_compare('12', '==') +