Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions roles/datastore/frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ N/A
Role Variables
--------------

| Name | Type | Default | Example | Description |
|--------------|--------|-----------|---------------|--------------------------------------------------------------------------------|
| `ds.mode` | `str` | `ssh` | | OpenNebula Datastore configuration mode: `ssh`, `shared`, `ceph` or `generic`. |
| `ds.config` | `dict` | `{}` | (check below) | OpenNebula Datastore configuration for a specifc mode. |
| `node_group` | `str` | `node` | | Custom name of the Node group in the inventory. |
| `leader` | `str` | undefined | `10.11.12.13` | When OpenNebula is in HA mode it points to the Leader. |
| Name | Type | Default | Example | Description |
|--------------|--------|-----------|---------------|----------------------------------------------------------------------------------------------|
| `ds.mode` | `str` | `ssh` | | OpenNebula Datastore configuration mode: `ssh`, `shared`, `ceph`, `fs_lvm_ssh` or `generic`. |
| `ds.config` | `dict` | `{}` | (check below) | OpenNebula Datastore configuration for a specifc mode. |
| `node_group` | `str` | `node` | | Custom name of the Node group in the inventory. |
| `leader` | `str` | undefined | `10.11.12.13` | When OpenNebula is in HA mode it points to the Leader. |

Dependencies
------------
Expand Down Expand Up @@ -64,6 +64,19 @@ Example Playbook
- role: opennebula.deploy.helper.facts
- role: opennebula.deploy.datastore.frontend

- hosts: frontend
vars:
# Configure OpenNebula to use "fs_lvm_ssh" image and system datastores.
# LVM devices are specified per SYSTEM_DS
ds:
mode: fs_lvm_ssh
config:
SYSTEM_DS:
device: /dev/mapper/mpatha
roles:
- role: opennebula.deploy.helper.facts
- role: opennebula.deploy.datastore.frontend

- hosts: frontend
vars:
# Configure OpenNebula to use "shared" image and system datastores.
Expand Down
1 change: 1 addition & 0 deletions roles/datastore/frontend/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ssh: simple
ceph: simple
shared: simple
fs_lvm_ssh: simple
generic: generic
when:
- ds.mode is defined
1 change: 1 addition & 0 deletions roles/datastore/node/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ssh: simple
ceph: simple
shared: simple
fs_lvm_ssh: simple
generic: generic
when:
- ds.mode is defined
12 changes: 12 additions & 0 deletions roles/datastore/simple/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,15 @@ ds_defaults:
FILE_DS:
template:
TM_MAD: ssh
fs_lvm_ssh:
SYSTEM_DS:
template:
TM_MAD: fs_lvm_ssh
BRIDGE_LIST: "{{ groups[node_group | d('node')] | map('extract', hostvars, ['ansible_host']) | join(' ') }}"
device: ""
IMAGE_DS:
template:
TM_MAD: fs_lvm_ssh
FILE_DS:
template:
TM_MAD: ssh
38 changes: 38 additions & 0 deletions roles/datastore/simple/tasks/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,44 @@
- ansible.builtin.import_tasks:
file: "{{ role_path }}/tasks/common.yml"

- name: Ensure LVM PV and VG exist (fs_lvm_ssh system)
ansible.builtin.shell: &lvm_shell
cmd: |
set -o errexit

if ! [[ -b '{{ _device }}' ]]; then
echo "Device '{{ _device }}' does not exist or is not a block device." >&2
exit 1
fi

if ! pvdisplay '{{ _device }}' &>/dev/null; then
if ! pvcreate '{{ _device }}'; then
echo "Failed to create PV '{{ _device }}'" >&2
exit 1
fi
fi

if ! vgdisplay "vg-one-{{ _ds_id }}" &>/dev/null; then
if ! vgcreate "vg-one-{{ _ds_id }}" '{{ _device }}'; then
echo "Failed to create VG 'vg-one-{{ _ds_id }}'" >&2
exit 1
fi
fi

exit 78
executable: /bin/bash
loop: "{{ ds_items.system | default([]) }}"
loop_control:
loop_var: item
vars:
_ds_id: "{{ item.1.ID }}"
_device: "{{ ds.config.SYSTEM_DS.device | default(ds_defaults[ds.mode].SYSTEM_DS.device) }}"
when: ds.mode == "fs_lvm_ssh"
register: lvm_shell
changed_when: lvm_shell.rc == 78
failed_when: lvm_shell.rc != 0 and lvm_shell.rc != 78
run_once: true

- when: ds.mode != 'ssh'
block:
- name: Setup datastore symlinks (image)
Expand Down