Fix some bugs about ansible deployment
[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: install notario package with pip when ceph backend enabled\r
24   pip:\r
25     name: "{{ item }}"\r
26   with_items:\r
27     - notario\r
28 \r
29 - name: configure ceph section in opensds global info if specify ceph backend\r
30   shell: |\r
31     cat >> opensds.conf <<OPENSDS_GLOABL_CONFIG_DOC\r
32 \r
33     [ceph]\r
34     name = {{ ceph_name }}\r
35     description = {{ ceph_description }}\r
36     driver_name = {{ ceph_driver_name }}\r
37     config_path = {{ ceph_config_path }}\r
38   args:\r
39     chdir: "{{ opensds_config_dir }}"\r
40   ignore_errors: yes\r
41 \r
42 - name: copy opensds ceph backend file to ceph config file if specify ceph backend\r
43   copy:\r
44     src: ../../../group_vars/ceph/ceph.yaml\r
45     dest: "{{ ceph_config_path }}"\r
46 \r
47 - name: check for ceph-ansible source code existed\r
48   stat:\r
49     path: /opt/ceph-ansible\r
50   ignore_errors: yes\r
51   register: cephansibleexisted\r
52 \r
53 - name: download ceph-ansible source code\r
54   git:\r
55     repo: https://github.com/ceph/ceph-ansible.git\r
56     dest: /opt/ceph-ansible\r
57     version: stable-3.0\r
58   when:\r
59     - cephansibleexisted.stat.exists is undefined or cephansibleexisted.stat.exists == false\r
60 \r
61 - name: copy ceph inventory host into ceph-ansible directory\r
62   copy:\r
63     src: ../../../group_vars/ceph/ceph.hosts\r
64     dest: /opt/ceph-ansible/ceph.hosts\r
65 \r
66 - name: copy ceph all.yml file into ceph-ansible group_vars directory\r
67   copy:\r
68     src: ../../../group_vars/ceph/all.yml\r
69     dest: /opt/ceph-ansible/group_vars/all.yml\r
70 \r
71 - name: copy site.yml.sample to site.yml in ceph-ansible\r
72   copy:\r
73     src: /opt/ceph-ansible/site.yml.sample\r
74     dest: /opt/ceph-ansible/site.yml\r
75 \r
76 - name: ping all hosts and run ceph-ansible playbook\r
77   shell: "{{ item }}"\r
78   become: true\r
79   with_items:\r
80     - ansible all -m ping -i ceph.hosts\r
81     - ansible-playbook site.yml -i ceph.hosts | tee /var/log/ceph_ansible.log\r
82   args:\r
83     chdir: /opt/ceph-ansible\r
84 \r
85 - name: check if ceph osd is running\r
86   shell: ps aux | grep ceph-osd | grep -v grep\r
87   ignore_errors: true\r
88   changed_when: false\r
89   register: service_ceph_osd_status\r
90 \r
91 - name: check if ceph mon is running\r
92   shell: ps aux | grep ceph-mon | grep -v grep\r
93   ignore_errors: true\r
94   changed_when: false\r
95   register: service_ceph_mon_status\r
96 \r
97 - name: configure profile and disable some features in ceph for kernel compatible.\r
98   shell: "{{ item }}"\r
99   become: true\r
100   ignore_errors: yes\r
101   with_items:\r
102     - ceph osd crush tunables hammer\r
103     - grep -q "^rbd default features" /etc/ceph/ceph.conf || sed -i '/\[global\]/arbd default features = 1' /etc/ceph/ceph.conf\r
104   when: service_ceph_mon_status.rc == 0 and service_ceph_osd_status.rc == 0\r
105 \r
106 - name: create specified pools and initialize them with default pool size.\r
107   shell: ceph osd pool create {{ item }} 100 && ceph osd pool set {{ item }} size 1\r
108   ignore_errors: yes\r
109   changed_when: false\r
110   with_items: "{{ ceph_pools }}"\r
111   when: service_ceph_mon_status.rc == 0 and service_ceph_osd_status.rc == 0\r