openstack-ansible-lxc_conta.../tests/test-create-zfs-dev.yml
Jonathan Rosser 3f07f8ad90 Convert remaining ansible_ fact variables to ansible_facts[]
Change-Id: I6909d6e91eb2211c1015625fee4f39c34189dc69
2021-03-17 08:35:47 +00:00

54 lines
1.6 KiB
YAML

---
# Copyright 2017, BBC R&D
#
# 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: Configure ZFS backing storage
hosts: localhost
user: root
become: true
connection: local
tasks:
- block:
- name: Install ZFS packages
package:
name: "{{ zfs_package[ansible_facts['distribution'] | lower] }}"
state: present
- name: Create base directories
file:
path: "{{ item }}"
state: "directory"
with_items:
- /openstack
- /var/lib/lxc
- name: Create sparse ZFS backing file
command: "truncate -s 1024G /openstack/lxc-zfs.img"
args:
creates: /openstack/lxc-zfs.img
register: lxc_zfs_create
- name: Create the ZFS pool
command: zpool create pool /openstack/lxc-zfs.img
args:
creates: /pool
- name: Create the ZFS pool/lxc volume
shell: "(zfs list | grep lxc) || zfs create -o mountpoint=/var/lib/lxc pool/lxc"
when:
- lxc_container_backing_store == 'zfs'
vars:
zfs_package:
ubuntu: "zfsutils-linux"