Update stor4nfv install scripts according to opensds aruba release
[stor4nfv.git] / ci / ansible / roles / osdsdock / scenarios / ceph.yml
1 # Copyright (c) 2018 Huawei Technologies Co., Ltd. All Rights Reserved.\r
2 #\r
3 # Licensed under the Apache License, Version 2.0 (the "License");\r
4 # you may not use this file except in compliance with the License.\r
5 # You may obtain a copy of the License at\r
6 #\r
7 #     http://www.apache.org/licenses/LICENSE-2.0\r
8 #\r
9 # Unless required by applicable law or agreed to in writing, software\r
10 # distributed under the License is distributed on an "AS IS" BASIS,\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
12 # See the License for the specific language governing permissions and\r
13 # limitations under the License.\r
14 \r
15 ---\r
16 - name: install ceph-common external package when ceph backend enabled\r
17   apt:\r
18     name: "{{ item }}"\r
19     state: present\r
20   with_items:\r
21     - ceph-common\r
22 \r
23 - name: configure ceph section in opensds global info if specify ceph backend\r
24   shell: |\r
25     cat >> opensds.conf <<OPENSDS_GLOABL_CONFIG_DOC\r
26 \r
27     [ceph]\r
28     name = {{ ceph_name }}\r
29     description = {{ ceph_description }}\r
30     driver_name = {{ ceph_driver_name }}\r
31     config_path = {{ ceph_config_path }}\r
32   args:\r
33     chdir: "{{ opensds_config_dir }}"\r
34   ignore_errors: yes\r
35 \r
36 - name: copy opensds ceph backend file to ceph config file if specify ceph backend\r
37   copy:\r
38     src: ../../../group_vars/ceph/ceph.yaml\r
39     dest: "{{ ceph_config_path }}"\r
40 \r
41 - name: check for ceph-ansible source code existed\r
42   stat:\r
43     path: /opt/ceph-ansible\r
44   ignore_errors: yes\r
45   register: cephansibleexisted\r
46 \r
47 - name: download ceph-ansible source code\r
48   git:\r
49     repo: https://github.com/ceph/ceph-ansible.git\r
50     dest: /opt/ceph-ansible\r
51     version: stable-3.0\r
52   when:\r
53     - cephansibleexisted.stat.exists is undefined or cephansibleexisted.stat.exists == false\r
54 \r
55 - name: copy ceph inventory host into ceph-ansible directory\r
56   copy:\r
57     src: ../../../group_vars/ceph/ceph.hosts\r
58     dest: /opt/ceph-ansible/ceph.hosts\r
59 \r
60 - name: copy ceph all.yml file into ceph-ansible group_vars directory\r
61   copy:\r
62     src: ../../../group_vars/ceph/all.yml\r
63     dest: /opt/ceph-ansible/group_vars/all.yml\r
64 \r
65 - name: copy site.yml.sample to site.yml in ceph-ansible\r
66   copy:\r
67     src: /opt/ceph-ansible/site.yml.sample\r
68     dest: /opt/ceph-ansible/site.yml\r
69 \r
70 - name: ping all hosts and run ceph-ansible playbook\r
71   shell: "{{ item }}"\r
72   become: true\r
73   with_items:\r
74     - ansible all -m ping -i ceph.hosts\r
75     - ansible-playbook site.yml -i ceph.hosts | tee /var/log/ceph_ansible.log\r
76   args:\r
77     chdir: /opt/ceph-ansible\r
78 \r
79 - name: check if ceph osd is running\r
80   shell: ps aux | grep ceph-osd | grep -v grep\r
81   ignore_errors: false\r
82   changed_when: false\r
83   register: service_ceph_osd_status\r
84 \r
85 - name: check if ceph mon is running\r
86   shell: ps aux | grep ceph-mon | grep -v grep\r
87   ignore_errors: false\r
88   changed_when: false\r
89   register: service_ceph_mon_status\r
90 \r
91 - name: configure profile and disable some features in ceph for kernel compatible.\r
92   shell: "{{ item }}"\r
93   become: true\r
94   ignore_errors: yes\r
95   with_items:\r
96     - ceph osd crush tunables hammer\r
97     - grep -q "^rbd default features" /etc/ceph/ceph.conf || sed -i '/\[global\]/arbd default features = 1' /etc/ceph/ceph.conf\r
98   when: service_ceph_mon_status.rc == 0 and service_ceph_osd_status.rc == 0\r
99 \r
100 - name: create specified pools and initialize them with default pool size.\r
101   shell: ceph osd pool create {{ item }} 100 && ceph osd pool set {{ item }} size 1\r
102   ignore_errors: yes\r
103   changed_when: false\r
104   with_items: "{{ ceph_pools }}"\r
105   when: service_ceph_mon_status.rc == 0 and service_ceph_osd_status.rc == 0\r