Initial commit
[ta/infra-ansible.git] / playbooks / bare_lvm_backend.yml
1 # cmframework.requires:os-nova-install.yml
2 ---
3
4 # Copyright 2019 Nokia
5
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 - hosts: baremetal-nodes
19   become: yes
20   become_method: sudo
21   become_user: root
22   gather_facts: no
23   roles:
24   - role: cleanup_disks
25     vars:
26       disks: "{{ bare_lvm.disks }}"
27       creates_file: "/etc/storage/bare_lvm_disks_cleaned"
28     when: bare_lvm is defined
29   post_tasks:
30   - name: create /etc/storage/bare_lvm_disks_cleaned
31     command: "touch /etc/storage/bare_lvm_disks_cleaned"
32     args:
33       creates: /etc/storage/bare_lvm_disks_cleaned
34     when: bare_lvm is defined
35
36 - name: Create bare LVM backend
37   hosts: baremetal-nodes
38   become: yes
39   become_method: sudo
40   become_user: root
41   gather_facts: no
42   vars:
43
44   tasks:
45   - name: initialize storage percentage
46     set_fact:
47       bare_lvm_storage_percent: "{{ 100 - instance_lv_percentage|default(0) }}"
48     when:
49       - bare_lvm is defined
50
51   - include_tasks: make_instance_disk_partitions.yml
52     vars:
53       instance_disks: "{{ bare_lvm.disks }}"
54       partition_number: "1"
55     when:
56       - bare_lvm is defined
57
58   - include_tasks: prepare_lvm_backend.yml
59     vars:
60       instance_physical_volumes: "{{ bare_lvm.physical_volumes }}"
61       lv_percentage: "{{ bare_lvm_storage_percent }}"
62       vgname: 'nova'
63       lvname: '{{ bare_lvm.name }}'
64       filesystem: 'xfs'
65       mountdir: '{{ bare_lvm.mount_dir }}'
66       mountpoint: '{{ bare_lvm.mount_dir }}'
67       mountoptions: '{{ bare_lvm.mount_options }}'
68       owner: root
69       group: root
70     when:
71       - bare_lvm is defined