From: Guillaume Abrioux Date: Wed, 12 Apr 2017 17:57:33 +0000 (+0200) Subject: Refact code X-Git-Tag: v2.2.10^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8da73547b8979baf33c1e228e0c360f976a0fbbf;p=ceph-ansible.git Refact code `ceph-docker-common`: At the moment there is a lot of duplicated tasks in each `./roles/ceph-/tasks/docker/main.yml` that could be refactored in `./roles/ceph-docker-common/tasks/main.yml`. `*_containerized_deployment` variables: All `*_containerized_deployment` have been refactored to a single variable `containerized_deployment` duplicate `cephx` variables in `group_vars/* have been removed. Signed-off-by: Guillaume Abrioux --- diff --git a/defaults/main.yml b/defaults/main.yml index d64009490..699aa8b27 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -378,10 +378,10 @@ docker: false ceph_docker_image: "ceph/daemon" ceph_docker_image_tag: latest -# Do not comment the following variables mon_containerized_deployment_* here. These variables are being used +# Do not comment the following variables containerized_deployment_* here. These variables are being used # by ceph.conf.j2 template. so it should always be defined -mon_containerized_deployment_with_kv: false -mon_containerized_deployment: false +containerized_deployment_with_kv: false +containerized_deployment: false mon_containerized_default_ceph_conf_with_kv: false # Confiure the type of NFS gatway access. At least one must be enabled for an diff --git a/tasks/docker/fetch_image.yml b/tasks/docker/fetch_image.yml deleted file mode 100644 index 57c76ed85..000000000 --- a/tasks/docker/fetch_image.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# Normal case - pull image from registry -- name: "pull {{ ceph_docker_image }} image" - command: "docker pull {{ ceph_docker_registry}}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}" - changed_when: false - when: ceph_docker_dev_image is undefined or not ceph_docker_dev_image - -# Dev case - export local dev image and send it across -- name: export local ceph dev image - local_action: command docker save -o "/tmp/{{ ceph_docker_username }}-{{ ceph_docker_imagename }}-{{ ceph_docker_image_tag }}.tar" "{{ ceph_docker_username }}/{{ ceph_docker_imagename }}:{{ ceph_docker_image_tag }}" - when: ceph_docker_dev_image is defined and ceph_docker_dev_image - run_once: true - -- name: copy ceph dev image file - copy: - src: "/tmp/{{ ceph_docker_username }}-{{ ceph_docker_imagename }}-{{ ceph_docker_image_tag }}.tar" - dest: "/tmp/{{ ceph_docker_username }}-{{ ceph_docker_imagename }}-{{ ceph_docker_image_tag }}.tar" - when: ceph_docker_dev_image is defined and ceph_docker_dev_image - -- name: load ceph dev image - command: "docker load -i /tmp/{{ ceph_docker_username }}-{{ ceph_docker_imagename }}-{{ ceph_docker_image_tag }}.tar" - when: ceph_docker_dev_image is defined and ceph_docker_dev_image - -- name: remove tmp ceph dev image file - command: "rm /tmp/{{ ceph_docker_username }}-{{ ceph_docker_imagename }}-{{ ceph_docker_image_tag }}.tar" - when: ceph_docker_dev_image is defined and ceph_docker_dev_image diff --git a/tasks/facts.yml b/tasks/facts.yml index 0e444e00f..2056ce9dc 100644 --- a/tasks/facts.yml +++ b/tasks/facts.yml @@ -87,4 +87,3 @@ when: - rbd_client_directory_mode is not defined or not rbd_client_directory_mode - diff --git a/tasks/generate_cluster_fsid.yml b/tasks/generate_cluster_fsid.yml index bd4d2abe5..5f49612ca 100644 --- a/tasks/generate_cluster_fsid.yml +++ b/tasks/generate_cluster_fsid.yml @@ -22,3 +22,8 @@ become: false always_run: true when: generate_fsid + +- name: set fsid fact when generate_fsid = true + set_fact: + fsid: "{{ cluster_uuid.stdout }}" + when: generate_fsid diff --git a/templates/ceph.conf.j2 b/templates/ceph.conf.j2 index d9b3df159..59ff882e9 100644 --- a/templates/ceph.conf.j2 +++ b/templates/ceph.conf.j2 @@ -11,7 +11,7 @@ auth supported = none {% if ip_version == 'ipv6' %} ms bind ipv6 = true {% endif %} -{% if not mon_containerized_deployment_with_kv and not mon_containerized_deployment %} +{% if not containerized_deployment_with_kv and not containerized_deployment %} fsid = {{ fsid }} {% endif %} max open files = {{ max_open_files }} @@ -30,7 +30,7 @@ mon initial members = {% for host in groups[mon_group_name] %} {% endfor %} {% endif %} -{% if not mon_containerized_deployment and not mon_containerized_deployment_with_kv %} +{% if not containerized_deployment and not containerized_deployment_with_kv %} {% if monitor_address_block %} mon host = {% for host in groups[mon_group_name] %}{{ hostvars[host]['ansible_all_ipv4_addresses'] | ipaddr(monitor_address_block) | first }}{% if not loop.last %},{% endif %}{% endfor %} {% elif groups[mon_group_name] is defined %} @@ -50,12 +50,12 @@ mon host = {% for host in groups[mon_group_name] %} {% endfor %} {% endif %} {% endif %} -{% if mon_containerized_deployment %} +{% if containerized_deployment %} fsid = {{ fsid }} {% if groups[mon_group_name] is defined %} mon host = {% for host in groups[mon_group_name] %} {% set interface = ["ansible_",ceph_mon_docker_interface]|join %} - {% if mon_containerized_deployment -%} + {% if containerized_deployment -%} {{ hostvars[host][interface]['ipv4']['address'] }} {%- elif hostvars[host]['monitor_address'] is defined -%} {{ hostvars[host]['monitor_address'] }}