Fix some bugs about ansible deployment
[stor4nfv.git] / ci / ansible / roles / osdsdock / scenarios / ceph.yml
old mode 100755 (executable)
new mode 100644 (file)
index 2b6196c..16aca67
----
-- name: install ceph-common external package when ceph backend enabled
-  apt:
-    name: ceph-common
-  when: enabled_backend == "ceph"
-
-- name: copy opensds ceph backend file if specify ceph backend
-  copy:
-    src: ../../../group_vars/ceph/ceph.yaml
-    dest: "{{ ceph_config_path }}"
-
-- name: check for ceph-ansible source code existed
-  stat:
-    path: /opt/ceph-ansible
-  ignore_errors: yes
-  register: cephansibleexisted
-
-- name: download ceph-ansible source code
-  git:
-    repo: https://github.com/ceph/ceph-ansible.git
-    dest: /opt/ceph-ansible
-  when:
-    - cephansibleexisted.stat.exists is undefined or cephansibleexisted.stat.exists == false
-
-- name: copy ceph inventory host into ceph-ansible directory
-  copy:
-    src: ../../../group_vars/ceph/ceph.hosts
-    dest: /opt/ceph-ansible/ceph.hosts
-
-- name: copy ceph all.yml file into ceph-ansible group_vars directory
-  copy:
-    src: ../../../group_vars/ceph/all.yml
-    dest: /opt/ceph-ansible/group_vars/all.yml
-
-- name: copy ceph osds.yml file into ceph-ansible group_vars directory
-  copy:
-    src: ../../../group_vars/ceph/osds.yml
-    dest: /opt/ceph-ansible/group_vars/osds.yml
-
-- name: copy site.yml.sample to site.yml in ceph-ansible
-  copy:
-    src: /opt/ceph-ansible/site.yml.sample
-    dest: /opt/ceph-ansible/site.yml
-
-- name: ping all hosts
-  shell: ansible all -m ping -i ceph.hosts
-  become: true
-  args:
-    chdir: /opt/ceph-ansible
-
-- name: run ceph-ansible playbook
-  shell: ansible-playbook site.yml -i ceph.hosts | tee /var/log/ceph_ansible.log
-  become: true
-  args:
-    chdir: /opt/ceph-ansible
-
-#- name: Check if ceph osd is running
-#  shell: ps aux | grep ceph-osd | grep -v grep
-#  ignore_errors: false
-#  changed_when: false
-#  register: service_ceph_osd_status
-
-- name: Check if ceph mon is running
-  shell: ps aux | grep ceph-mon | grep -v grep
-  ignore_errors: false
-  changed_when: false
-  register: service_ceph_mon_status
-
-- name: Create a pool and initialize it.
-  shell: ceph osd pool create {{ ceph_pool_name }} 100 && ceph osd pool set {{ ceph_pool_name }} size 1
-  ignore_errors: yes
-  changed_when: false
-  register: ceph_init_pool
-  when: service_ceph_mon_status.rc == 0 # and service_ceph_osd_status.rc == 0
+# Copyright (c) 2018 Huawei Technologies Co., Ltd. All Rights Reserved.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#     http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+\r
+---\r
+- name: install ceph-common external package when ceph backend enabled\r
+  apt:\r
+    name: "{{ item }}"\r
+    state: present\r
+  with_items:\r
+    - ceph-common\r
+\r
+- name: install notario package with pip when ceph backend enabled\r
+  pip:\r
+    name: "{{ item }}"\r
+  with_items:\r
+    - notario\r
+\r
+- name: configure ceph section in opensds global info if specify ceph backend\r
+  shell: |\r
+    cat >> opensds.conf <<OPENSDS_GLOABL_CONFIG_DOC\r
+\r
+    [ceph]\r
+    name = {{ ceph_name }}\r
+    description = {{ ceph_description }}\r
+    driver_name = {{ ceph_driver_name }}\r
+    config_path = {{ ceph_config_path }}\r
+  args:\r
+    chdir: "{{ opensds_config_dir }}"\r
+  ignore_errors: yes\r
+\r
+- name: copy opensds ceph backend file to ceph config file if specify ceph backend\r
+  copy:\r
+    src: ../../../group_vars/ceph/ceph.yaml\r
+    dest: "{{ ceph_config_path }}"\r
+\r
+- name: check for ceph-ansible source code existed\r
+  stat:\r
+    path: /opt/ceph-ansible\r
+  ignore_errors: yes\r
+  register: cephansibleexisted\r
+\r
+- name: download ceph-ansible source code\r
+  git:\r
+    repo: https://github.com/ceph/ceph-ansible.git\r
+    dest: /opt/ceph-ansible\r
+    version: stable-3.0\r
+  when:\r
+    - cephansibleexisted.stat.exists is undefined or cephansibleexisted.stat.exists == false\r
+\r
+- name: copy ceph inventory host into ceph-ansible directory\r
+  copy:\r
+    src: ../../../group_vars/ceph/ceph.hosts\r
+    dest: /opt/ceph-ansible/ceph.hosts\r
+\r
+- name: copy ceph all.yml file into ceph-ansible group_vars directory\r
+  copy:\r
+    src: ../../../group_vars/ceph/all.yml\r
+    dest: /opt/ceph-ansible/group_vars/all.yml\r
+\r
+- name: copy site.yml.sample to site.yml in ceph-ansible\r
+  copy:\r
+    src: /opt/ceph-ansible/site.yml.sample\r
+    dest: /opt/ceph-ansible/site.yml\r
+\r
+- name: ping all hosts and run ceph-ansible playbook\r
+  shell: "{{ item }}"\r
+  become: true\r
+  with_items:\r
+    - ansible all -m ping -i ceph.hosts\r
+    - ansible-playbook site.yml -i ceph.hosts | tee /var/log/ceph_ansible.log\r
+  args:\r
+    chdir: /opt/ceph-ansible\r
+\r
+- name: check if ceph osd is running\r
+  shell: ps aux | grep ceph-osd | grep -v grep\r
+  ignore_errors: true\r
+  changed_when: false\r
+  register: service_ceph_osd_status\r
+\r
+- name: check if ceph mon is running\r
+  shell: ps aux | grep ceph-mon | grep -v grep\r
+  ignore_errors: true\r
+  changed_when: false\r
+  register: service_ceph_mon_status\r
+\r
+- name: configure profile and disable some features in ceph for kernel compatible.\r
+  shell: "{{ item }}"\r
+  become: true\r
+  ignore_errors: yes\r
+  with_items:\r
+    - ceph osd crush tunables hammer\r
+    - grep -q "^rbd default features" /etc/ceph/ceph.conf || sed -i '/\[global\]/arbd default features = 1' /etc/ceph/ceph.conf\r
+  when: service_ceph_mon_status.rc == 0 and service_ceph_osd_status.rc == 0\r
+\r
+- name: create specified pools and initialize them with default pool size.\r
+  shell: ceph osd pool create {{ item }} 100 && ceph osd pool set {{ item }} size 1\r
+  ignore_errors: yes\r
+  changed_when: false\r
+  with_items: "{{ ceph_pools }}"\r
+  when: service_ceph_mon_status.rc == 0 and service_ceph_osd_status.rc == 0\r