Make the storage use ceph 39/38839/9
authorwutianwei <wutianwei1@huawei.com>
Mon, 7 Aug 2017 12:03:34 +0000 (20:03 +0800)
committerwutianwei <wutianwei1@huawei.com>
Tue, 15 Aug 2017 01:22:02 +0000 (09:22 +0800)
1. ceph.yml define which host install ceph-mon and ceph-osd
2. user_ceph.yml define variables of ceph and cinder backend
3. user_variables_ceph.yml.j2 define variables of ceph for user

Change-Id: Iafea998f4603eb4b5c15a26f2387e6cb04c35d4c
Signed-off-by: wutianwei <wutianwei1@huawei.com>
deploy/adapters/ansible/roles/config-osa/files/user_ceph.yml [new file with mode: 0644]
deploy/adapters/ansible/roles/config-osa/tasks/main.yml
deploy/adapters/ansible/roles/config-osa/templates/ceph.yml.j2 [new file with mode: 0644]
deploy/adapters/ansible/roles/config-osa/templates/user_variables.yml.j2
deploy/adapters/ansible/roles/config-osa/templates/user_variables_ceph.yml.j2 [new file with mode: 0644]
deploy/adapters/ansible/roles/config-osa/vars/main.yml
deploy/adapters/ansible/roles/storage/tasks/ceph.yml [new file with mode: 0644]
deploy/adapters/ansible/roles/storage/tasks/main.yml
deploy/adapters/ansible/roles/storage/vars/main.yml [new file with mode: 0644]

diff --git a/deploy/adapters/ansible/roles/config-osa/files/user_ceph.yml b/deploy/adapters/ansible/roles/config-osa/files/user_ceph.yml
new file mode 100644 (file)
index 0000000..9d5f13a
--- /dev/null
@@ -0,0 +1,16 @@
+---
+# The OSA ceph_client role does not support loading IPs from an inventory group,
+# so we have to feed it a list of IPs
+# yamllint disable rule:line-length
+ceph_mons: "[ {% for host in groups[mon_group_name] %}'{{ hostvars[host]['ansible_host'] }}'{% if not loop.last %},{% endif %}{% endfor %} ]"
+# yamllint enable rule:line-length
+cinder_backends:
+  "RBD":
+    volume_driver: cinder.volume.drivers.rbd.RBDDriver
+    rbd_pool: volumes
+    rbd_ceph_conf: /etc/ceph/ceph.conf
+    rbd_store_chunk_size: 8
+    volume_backend_name: rbddriver
+    rbd_user: cinder
+    rbd_secret_uuid: "{{ cinder_ceph_client_uuid }}"
+    report_discard_supported: true
index b1b32f7..cd1e90e 100644 (file)
   copy:
     src: fetch-files.yml
     dest: /opt/openstack-ansible/playbooks/fetch-files.yml
+
+- name: copy user_ceph.yml
+  copy:
+    src: user_ceph.yml
+    dest: /etc/openstack_deploy/user_ceph.yml
+  when:
+    - "{{ hostvars[inventory_hostname]['groups']['ceph_mon'] |length > 0 }}"
+    - "{{ hostvars[inventory_hostname]['groups']['ceph_osd'] | length > 0 }}"
+
+- name: render ceph.yml.j2
+  template:
+    src: ceph.yml.j2
+    dest: /etc/openstack_deploy/conf.d/ceph.yml
+  when:
+    - "{{ hostvars[inventory_hostname]['groups']['ceph_mon'] |length > 0 }}"
+    - "{{ hostvars[inventory_hostname]['groups']['ceph_osd'] | length > 0 }}"
+
+- name: render user_variables_ceph.yml.j2
+  template:
+    src: user_variables_ceph.yml.j2
+    dest: /etc/openstack_deploy/user_variables_ceph.yml
+  when:
+    - "{{ hostvars[inventory_hostname]['groups']['ceph_mon'] |length > 0 }}"
+    - "{{ hostvars[inventory_hostname]['groups']['ceph_osd'] | length > 0 }}"
diff --git a/deploy/adapters/ansible/roles/config-osa/templates/ceph.yml.j2 b/deploy/adapters/ansible/roles/config-osa/templates/ceph.yml.j2
new file mode 100644 (file)
index 0000000..c85dd59
--- /dev/null
@@ -0,0 +1,14 @@
+# The infra nodes where the Ceph mon services will run
+ceph-mon_hosts:
+{% for host in groups.ceph_mon%}
+  {{host}}:
+    ip: {{ hostvars[host]['ansible_ssh_host'] }}
+{% endfor %}
+
+# The nodes that the Ceph OSD disks will be running on
+ceph-osd_hosts:
+{% for host in groups.ceph_osd%}
+  {{host}}:
+    ip: {{ hostvars[host]['ansible_ssh_host'] }}
+{% endfor %}
+
index 2b4a959..a6cefd7 100644 (file)
@@ -27,6 +27,10 @@ haproxy_keepalived_external_interface: br-external
 haproxy_keepalived_internal_interface: br-mgmt
 keepalived_ping_address: "{{ ntp_server }}"
 
+cinder_cinder_conf_overrides:
+  DEFAULT:
+    public_endpoint: "https://{{ public_vip.ip }}"
+
 {% if "openvswitch" == NEUTRON_MECHANISM_DRIVERS[0] or
    "opendaylight" == NEUTRON_MECHANISM_DRIVERS[0]
 %}
diff --git a/deploy/adapters/ansible/roles/config-osa/templates/user_variables_ceph.yml.j2 b/deploy/adapters/ansible/roles/config-osa/templates/user_variables_ceph.yml.j2
new file mode 100644 (file)
index 0000000..de3c029
--- /dev/null
@@ -0,0 +1,31 @@
+---
+# Copyright 2017, Logan Vig <logan2211@gmail.com>
+#
+# 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.
+
+## ceph-ansible settings
+devices: {{ hostvars[ceph_host]['fact_for_ceph'] }}
+common_single_host_mode: true
+monitor_interface: eth1
+public_network: "{{ mgmt_cidr }} "
+cluster_network: "{{ storage_cidr }}"
+journal_size: 100
+journal_collocation: true
+pool_default_pg_num: 32
+openstack_config: true # Ceph ansible automatically creates pools & keys
+cinder_ceph_client: cinder
+cinder_default_volume_type: RBD
+glance_ceph_client: glance
+glance_default_store: rbd
+glance_rbd_store_pool: images
+nova_libvirt_images_rbd_pool: vms
index 783ea0d..3c95bc6 100644 (file)
@@ -8,3 +8,4 @@
 # #############################################################################
 ---
 LOCAL_REPOSITORY_IP: "192.168.137.222"
+ceph_host: "{{ hostvars[inventory_hostname]['groups']['ceph_osd'][0] }}"
diff --git a/deploy/adapters/ansible/roles/storage/tasks/ceph.yml b/deploy/adapters/ansible/roles/storage/tasks/ceph.yml
new file mode 100644 (file)
index 0000000..e024c67
--- /dev/null
@@ -0,0 +1,45 @@
+---
+# Copyright 2016, Logan Vig <logan2211@gmail.com>
+#
+# 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: Create sparse ceph OSD files
+  command: truncate -s {{ host_loopback_ceph_size }} /var/{{ item }}.img
+  args:
+    creates: "/var/{{ item }}.img"
+  with_items: "{{ ceph_osd_images }}"
+  register: ceph_create
+  changed_when: false
+
+- name: Create the ceph loopback device
+  command: losetup -f /var/{{ item.item }}.img --show
+  with_items: "{{ ceph_create.results }}"
+  register: ceph_loopback
+  when: not item|skipped
+  changed_when: false
+
+- name: register ceph_loopback to localhost
+  set_fact:
+    fact_for_ceph: "{{ ceph_loopback.results | map(attribute='stdout') | list | to_yaml | trim }}"
+
+- name: Ensure that rc.local exists
+  file:
+    path: "{{ rc_local }}"
+    state: touch
+    mode: "u+x"
+
+- name: Create ceph loopback at boot time
+  lineinfile:
+    dest: "{{ rc_local }}"
+    line: "losetup -f /var/{{ item }}.img"
+    insertbefore: "{{ rc_local_insert_before }}"
+  with_items: "{{ ceph_osd_images }}"
index b054be9..3d9635c 100755 (executable)
   tags:
     - storage
 
+- name: load ceph.yml
+  include: ceph.yml
+  when:
+    - "{{ hostvars[inventory_hostname]['groups']['ceph_mon'] |length > 0 }}"
+    - "{{ hostvars[inventory_hostname]['groups']['ceph_osd'] | length > 0 }}"
+  tags:
+    - storage
+
 - meta: flush_handlers
diff --git a/deploy/adapters/ansible/roles/storage/vars/main.yml b/deploy/adapters/ansible/roles/storage/vars/main.yml
new file mode 100644 (file)
index 0000000..28e2ad0
--- /dev/null
@@ -0,0 +1,18 @@
+##############################################################################
+# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+---
+host_loopback_ceph_size: "100G"
+rc_local: /etc/rc.local
+rc_local_insert_before: "^exit 0$"
+bootstrap_host_data_disk_device: null
+bootstrap_host_data_disk_device_force: "no"
+ceph_osd_images:
+  - 'ceph1'
+  - 'ceph2'
+  - 'ceph3'