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