Initial commit
[ta/infra-ansible.git] / roles / bootstrap-host / tasks / prepare_ceph.yml
1 ---
2 # Copyright 2016, Logan Vig <logan2211@gmail.com>
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 - name: Create sparse ceph OSD files
17   command: truncate -s {{ bootstrap_host_loopback_ceph_size }}G /openstack/{{ item }}.img
18   args:
19     creates: "/openstack/{{ item }}.img"
20   with_items: "{{ ceph_osd_images }}"
21   register: ceph_create
22   changed_when: false
23   tags:
24     - ceph-file-create
25
26 - name: Create the ceph loopback device
27   command: losetup -f /openstack/{{ item.item }}.img --show
28   with_items: "{{ ceph_create.results }}"
29   register: ceph_create_loopback
30   when: not item|skipped
31   changed_when: false
32   tags:
33     - skip_ansible_lint
34
35 - name: Ensure that rc.local exists
36   file:
37     path: /etc/rc.local
38     state: touch
39     mode: "u+x"
40   tags:
41     - ceph-rc-file
42
43 - name: Create ceph loopback at boot time
44   lineinfile:
45     dest: /etc/rc.local
46     line: "losetup -f /openstack/{{ item }}.img"
47   with_items: "{{ ceph_osd_images }}"
48
49 # TODO(logan): Move these vars to user_variables.ceph.yml.j2 once LP #1649381
50 # is fixed and eliminate this task.
51 - name: Write ceph cluster config
52   copy:
53     content: |
54       ---
55       devices: {{ ceph_create_loopback.results | map(attribute='stdout') | list | to_yaml | trim }}
56       # The OSA ceph_client role does not support loading IPs from an inventory group,
57       # so we have to feed it a list of IPs
58       ceph_mons: "{% raw %}[ {% for host in groups[mon_group_name] %}'{{ hostvars[host]['ansible_host'] }}'{% if not loop.last %},{% endif %}{% endfor %} ]{% endraw %}"
59       cinder_backends:
60         "RBD":
61           volume_driver: cinder.volume.drivers.rbd.RBDDriver
62           rbd_pool: volumes
63           rbd_ceph_conf: /etc/ceph/ceph.conf
64           rbd_store_chunk_size: 8
65           volume_backend_name: rbddriver
66           rbd_user: cinder
67           rbd_secret_uuid: "{% raw %}{{ cinder_ceph_client_uuid }}{% endraw %}"
68           report_discard_supported: true
69     dest: /etc/openstack_deploy/user_ceph_aio.yml
70     force: no
71   become: false
72   when: not ceph_create_loopback|skipped
73   tags:
74     - skip_ansible_lint