Defined Type: sqlite::db

Defined in:
modules/sqlite/manifests/db.pp

Summary

define to create and manage sqlite db

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: 'present')

    ensurable parameter

  • owner (String) (defaults to: 'root')

    owner to use for files and execution

  • group (String) (defaults to: 'root')

    group to use for files and execution

  • mode (Stdlib::Filemode) (defaults to: '0660')

    mode to use for created files

  • db_path (Optional[Stdlib::Unixpath]) (defaults to: undef)

    path to the database

  • sql_schema (Optional[Stdlib::Unixpath]) (defaults to: undef)

    sql schema to install



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'modules/sqlite/manifests/db.pp', line 9

define sqlite::db (
    Wmflib::Ensure             $ensure     = 'present',
    String                     $owner      = 'root',
    String                     $group      = 'root',
    Stdlib::Filemode           $mode       = '0660',
    Optional[Stdlib::Unixpath] $db_path    = undef,
    Optional[Stdlib::Unixpath] $sql_schema = undef,
) {
    include sqlite
    $_db_path = $db_path ? {
        undef   => "${sqlite::default_db_path}/${title}.db",
        default => $db_path,
    }
    file {$_db_path:
        ensure => $ensure,
        owner  => $owner,
        group  => $group,
    }
    if $sql_schema {
        exec{"sqlite_initialist_db_${title}":
            path        => ['/bin', '/usr/bin'],
            user        => $owner,
            group       => $group,
            command     => "cat ${sql_schema} | ${sqlite::sqlite_cmd} ${_db_path}",
            refreshonly => true,
            subscribe   => File[$_db_path],
            require     => Package[$sqlite::package],
        }
    }
}