Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M #-: Add SQLite DB backend #35

Merged
merged 2 commits into from
Feb 28, 2024
Merged
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
2 changes: 1 addition & 1 deletion roles/database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Role Variables

| Name | Type | Default | Example | Description |
|---------------|-------|--------------|---------|-------------------------------------------------------|
| `db_backend` | `str` | `MariaDB` | | Can be `MariaDB` or `PostgreSQL`. |
| `db_backend` | `str` | `MariaDB` | | Can be `MariaDB`, `PostgreSQL` or `SQLite`. |
| `db_name` | `str` | `opennebula` | | Name of the database/schema used by OpenNebula. |
| `db_owner` | `str` | `oneadmin` | | User used by OpenNebula to access the database. |
| `db_password` | `str` | `opennebula` | | Password used by OpenNebula to authenticate the user. |
Expand Down
2 changes: 2 additions & 0 deletions roles/database/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
db_supported_backends:
- MariaDB
- PostgreSQL
- SQLite

db_backend_types:
MariaDB: mysql
PostgreSQL: postgresql
SQLite: sqlite

db_backend: MariaDB

Expand Down
4 changes: 4 additions & 0 deletions roles/database/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
Debian:
MariaDB: [mariadb-server]
PostgreSQL: [postgresql]
SQLite: [sqlite]
RedHat:
MariaDB: [mariadb-server]
PostgreSQL: [postgresql-server]
SQLite: [sqlite]
register: package
until: package is success
retries: 12
Expand Down Expand Up @@ -50,6 +52,7 @@
RedHat:
MariaDB: mariadb
PostgreSQL: postgresql
when: db_backend != 'SQLite'

- name: Create DB instance for OpenNebula
ansible.builtin.shell:
Expand All @@ -75,3 +78,4 @@
MariaDB: root
PostgreSQL: postgres
changed_when: false
when: db_backend != 'SQLite'
2 changes: 1 addition & 1 deletion roles/opennebula/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Role Variables
| `one_vip` | `str` | undefined | `10.11.12.13` | When OpenNebula is in HA mode it points to the Leader. |
| `one_vip_if` | `str` | undefined | `eth0` | NIC device to assign the `one_vip` address to (on Frontends). |
| `one_vip_cidr` | `int` | undefined | `24` | CIDR prefix of the subnet `one_vip` is allocated in. |
| `db_backend` | `str` | `MariaDB` | | Can be `MariaDB` or `PostgreSQL`. |
| `db_backend` | `str` | `MariaDB` | | Can be `MariaDB`, `PostgreSQL` or `SQLite`. |
| `db_name` | `str` | `opennebula` | | Name of the database/schema used by OpenNebula. |
| `db_owner` | `str` | `oneadmin` | | User used by OpenNebula to access the database. |
| `db_password` | `str` | `opennebula` | | Password used by OpenNebula to authenticate the user. |
Expand Down
10 changes: 10 additions & 0 deletions roles/precheck/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,13 @@
- "{{ groups[node_group | d('node')] if groups[node_group | d('node')] is defined else [] }}"
_hosts: "{{ _tmp | flatten | unique }}"
tags: [preinstall]

- name: Check if DB backend is supported for the HA setup
ansible.builtin.assert:
that: ((_frontend_count | int == 1) and (_force_ha is false))
or
(db_backend != 'SQLite')
msg: Please use either PostgreSQL or MariaDB as DB backend for HA setup.
vars:
_frontend_count: "{{ groups[frontend_group | d('frontend')] | count }}"
_force_ha: "{{ force_ha | d(false) | bool }}"