Commit 9ffb12d2 authored by Matthieu FAURE's avatar Matthieu FAURE

Merge branch '5-refactor-code-for-managed-services' into 'master'

Resolve "Refactor code for managed services"

Closes #5

See merge request !6
parents 690ccf65 e2b4f88c
Pipeline #6471 passed with stages
in 12 minutes and 51 seconds
......@@ -5,3 +5,10 @@ fixtures:
forge_modules:
stdlib: "puppetlabs/stdlib"
archive: "puppet/archive"
redis: "puppet-redis"
apt: "puppetlabs-apt" # for Redis
augeasproviders_core: "herculesteam-augeasproviders_core" # for Redis
augeasproviders_sysctl: "herculesteam-augeasproviders_sysctl" # for Redis
epel: "stahnma-epel" # for Redis
mariadb: "puppetlabs-mysql"
translate: "puppetlabs/translate" # for Mysql
......@@ -110,31 +110,12 @@ class nextcloud (
# Install Redis
if $manage_redis {
include redis
include nextcloud::redis
}
# Install MariaDB
if $manage_mariadb {
# Install server + client + bindings
class { 'mysql::server':
package_name => 'mariadb-server',
root_password => $db_root_password,
remove_default_accounts => true,
}
class { 'mysql::client':
package_name => 'mariadb-client'
}
class { 'mysql::bindings':
php_enable => true,
}
# Create database for Nextcloud
mysql::db { $db_database_name:
user => $db_username,
password => $db_password,
host => $db_hostname,
grant => ['ALL'],
}
include nextcloud::mariadb
}
# Create NextCloud directory
......
# @summary Install Mariadb and create database
#
# Install Mariadb and create database
#
# @example
# include nextcloud::mariadb
class nextcloud::mariadb {
# Install server + client + bindings
class { 'mysql::server':
package_name => 'mariadb-server',
root_password => $nextcloud::db_root_password,
remove_default_accounts => true,
}
class { 'mysql::client':
package_name => 'mariadb-client'
}
class { 'mysql::bindings':
php_enable => true,
}
# Create database for Nextcloud
mysql::db { $nextcloud::db_database_name:
user => $nextcloud::db_username,
password => $nextcloud::db_password,
host => $nextcloud::db_hostname,
grant => ['ALL'],
}
}
# @summary Install Redis
#
# Install Redis
#
# @example
# include nextcloud::redis
class nextcloud::redis {
include redis
}
......@@ -72,9 +72,6 @@ describe 'NextCloud class' do
# it 'applies idempotently' do
# apply_manifest(pp, catch_changes: true)
# end
# describe service('redis') do
# it { is_expected.to be_running }
# end
#
# # TODO: once actual code is created in the module, add tests here with `describe` and expectations
# end
......
require 'spec_helper'
describe 'nextcloud::mariadb' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) do
os_facts.merge(root_home: '/root') # merging custom fact "root_home" is required for mariadb
end
let(:pre_condition) do
"
class { 'nextcloud':
db_password => 'S3cr#TPassw0rdz',
nc_admin_username => 'ncadmin',
nc_admin_password => 'ncadminPassword',
manage_mariadb => true,
}
"
end
it { is_expected.to compile }
it { is_expected.to contain_class('mysql::server') }
it { is_expected.to contain_class('mysql::client') }
it { is_expected.to contain_class('mysql::bindings') }
it { is_expected.to contain_mysql__db('nextcloud') }
# package_name (mariadb-server) does not seem to be taken in account
it { is_expected.to contain_package('mysql-server') }
it { is_expected.to contain_service('mysqld') }
# it { is_expected.to contain_package('mariadb-server') }
# it { is_expected.to contain_service('mariadb') }
end
end
end
require 'spec_helper'
describe 'nextcloud::redis' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
let(:pre_condition) do
"
class { 'nextcloud':
db_password => 'S3cr#TPassw0rdz',
nc_admin_username => 'ncadmin',
nc_admin_password => 'ncadminPassword',
manage_redis => true,
}
"
end
it { is_expected.to compile }
it do
is_expected.to contain_service('redis-server')
.with_enable(true)
.with_ensure('running')
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment