feat: add cephfs shared volume define
- add ceph class to manage ceph client configuration/packages - add cephfs define for mounting volumes - add ceph keyring define to manage secrets used to mount cephfs
This commit is contained in:
parent
8eca497ea2
commit
5631f07e6e
@ -120,6 +120,9 @@ lookup_options:
|
|||||||
mysql::db:
|
mysql::db:
|
||||||
merge:
|
merge:
|
||||||
strategy: deep
|
strategy: deep
|
||||||
|
profiles::ceph::client::keyrings:
|
||||||
|
merge:
|
||||||
|
strategy: deep
|
||||||
|
|
||||||
facts_path: '/opt/puppetlabs/facter/facts.d'
|
facts_path: '/opt/puppetlabs/facter/facts.d'
|
||||||
|
|
||||||
@ -294,7 +297,11 @@ networking::routes:
|
|||||||
netmask: 0.0.0.0
|
netmask: 0.0.0.0
|
||||||
network: default
|
network: default
|
||||||
|
|
||||||
|
profiles::ceph::client::fsid: 7f7f00cb-95de-498c-8dcc-14b54e4e9ca8
|
||||||
|
profiles::ceph::client::mons:
|
||||||
|
- 10.18.15.1
|
||||||
|
- 10.18.15.2
|
||||||
|
- 10.18.15.3
|
||||||
#profiles::base::hosts::additional_hosts:
|
#profiles::base::hosts::additional_hosts:
|
||||||
# - ip: 198.18.17.9
|
# - ip: 198.18.17.9
|
||||||
# hostname: prodinf01n09.main.unkin.net
|
# hostname: prodinf01n09.main.unkin.net
|
||||||
|
|||||||
43
site/profiles/manifests/ceph/client.pp
Normal file
43
site/profiles/manifests/ceph/client.pp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# profiles::ceph::client
|
||||||
|
class profiles::ceph::client (
|
||||||
|
String $fsid,
|
||||||
|
Array[Stdlib::Host] $mons,
|
||||||
|
Stdlib::Absolutepath $config_file = '/etc/ceph/ceph.conf',
|
||||||
|
String $owner = 'ceph',
|
||||||
|
String $group = 'ceph',
|
||||||
|
Stdlib::Filemode $mode = '0644',
|
||||||
|
Hash $keyrings = {},
|
||||||
|
) {
|
||||||
|
|
||||||
|
# dont run this on proxmox nodes
|
||||||
|
if $facts['enc_role'] != 'roles::infra::proxmox::node' {
|
||||||
|
|
||||||
|
# install the ceph client package
|
||||||
|
package { 'ceph-common':
|
||||||
|
ensure => installed,
|
||||||
|
}
|
||||||
|
|
||||||
|
# manage the ceph directory
|
||||||
|
file { '/etc/ceph':
|
||||||
|
ensure => directory,
|
||||||
|
owner => $owner,
|
||||||
|
group => $group,
|
||||||
|
mode => $mode,
|
||||||
|
require => Package['ceph-common'],
|
||||||
|
}
|
||||||
|
|
||||||
|
# create a basic client config
|
||||||
|
file { $config_file:
|
||||||
|
ensure => file,
|
||||||
|
owner => $owner,
|
||||||
|
group => $group,
|
||||||
|
mode => $mode,
|
||||||
|
content => template('profiles/ceph/client.conf.erb'),
|
||||||
|
require => Package['ceph-common'],
|
||||||
|
}
|
||||||
|
|
||||||
|
# manage ceph keyrings
|
||||||
|
create_resources('profiles::ceph::keyring', $keyrings)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
21
site/profiles/manifests/ceph/keyring.pp
Normal file
21
site/profiles/manifests/ceph/keyring.pp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# profiles::ceph::keyring
|
||||||
|
define profiles::ceph::keyring (
|
||||||
|
String $key,
|
||||||
|
String $user = $name,
|
||||||
|
String $type = 'client',
|
||||||
|
Stdlib::Filemode $mode = '0600',
|
||||||
|
String $owner = 'ceph',
|
||||||
|
String $group = 'ceph',
|
||||||
|
Stdlib::Absolutepath $keyring_dir = '/etc/ceph',
|
||||||
|
) {
|
||||||
|
$keyring_file = "${keyring_dir}/ceph.${type}.${user}.keyring"
|
||||||
|
|
||||||
|
file { $keyring_file:
|
||||||
|
ensure => file,
|
||||||
|
owner => $owner,
|
||||||
|
group => $group,
|
||||||
|
mode => $mode,
|
||||||
|
content => Sensitive(template('profiles/ceph/keyring.erb')),
|
||||||
|
require => File[$keyring_dir],
|
||||||
|
}
|
||||||
|
}
|
||||||
69
site/profiles/manifests/storage/cephfsvol.pp
Normal file
69
site/profiles/manifests/storage/cephfsvol.pp
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# profiles::storage::cephfsvol
|
||||||
|
define profiles::storage::cephfsvol (
|
||||||
|
Enum['present', 'absent', 'mounted'] $ensure = 'mounted',
|
||||||
|
String $owner = 'root',
|
||||||
|
String $group = 'root',
|
||||||
|
Stdlib::Filemode $mode = '0755',
|
||||||
|
Stdlib::Absolutepath $mount = '/shared',
|
||||||
|
Array[Enum[
|
||||||
|
'defaults', 'ro', 'rw', 'sync', 'async',
|
||||||
|
'noatime', 'nodiratime', 'noexec', 'nosuid',
|
||||||
|
'nodev', 'remount', 'auto', 'noauto'
|
||||||
|
]] $mount_options = ['noatime', 'nodiratime'],
|
||||||
|
Variant[Stdlib::Host, Array[Stdlib::Host]] $cephfs_mon = 'ceph-mon.service.consul',
|
||||||
|
Stdlib::Absolutepath $cephfs_path = '/',
|
||||||
|
String $cephfs_name = 'admin',
|
||||||
|
String $cephfs_fs = 'cephfs',
|
||||||
|
Optional[Stdlib::Absolutepath] $keyring = undef,
|
||||||
|
) {
|
||||||
|
|
||||||
|
# mkdir -p $mount_path
|
||||||
|
mkdir::p {$mount: }
|
||||||
|
|
||||||
|
# ensure the mount path exists
|
||||||
|
file { $mount:
|
||||||
|
ensure => directory,
|
||||||
|
owner => $owner,
|
||||||
|
group => $group,
|
||||||
|
mode => $mode,
|
||||||
|
require => [
|
||||||
|
Mkdir::P[$mount],
|
||||||
|
Package['ceph-common']
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
# join options into a comma seperated list
|
||||||
|
$options = join($mount_options, ',')
|
||||||
|
|
||||||
|
# if a ceph keyring is required, it will be added here
|
||||||
|
if $keyring {
|
||||||
|
$mount_options_string = "${options},fs=${cephfs_fs},name=${cephfs_name},secretfile=${keyring}"
|
||||||
|
} else {
|
||||||
|
$mount_options_string = "${options},fs=${cephfs_fs},name=${cephfs_name}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# convert cephfs_servers (monitors) into a list
|
||||||
|
$mon_addresses = $cephfs_mon ? {
|
||||||
|
Array => join($cephfs_mon, ','),
|
||||||
|
default => $cephfs_mon,
|
||||||
|
}
|
||||||
|
|
||||||
|
# manage the mount
|
||||||
|
mount { $mount:
|
||||||
|
ensure => $ensure,
|
||||||
|
atboot => true,
|
||||||
|
device => "${mon_addresses}:${cephfs_path}",
|
||||||
|
fstype => 'ceph',
|
||||||
|
options => $mount_options_string,
|
||||||
|
require => File[$mount],
|
||||||
|
}
|
||||||
|
|
||||||
|
# unmount when the mount should be removed
|
||||||
|
if $ensure == 'absent' {
|
||||||
|
exec { "umount_${mount}":
|
||||||
|
command => "umount ${mount}",
|
||||||
|
onlyif => "mount | grep ${mount}",
|
||||||
|
before => Mount[$mount],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
site/profiles/templates/ceph/client.conf.erb
Normal file
3
site/profiles/templates/ceph/client.conf.erb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[global]
|
||||||
|
fsid = <%= @fsid %>
|
||||||
|
mon_host = <%= @mons.join(' ') %>
|
||||||
1
site/profiles/templates/ceph/keyring.erb
Normal file
1
site/profiles/templates/ceph/keyring.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
<%= @key %>
|
||||||
Loading…
Reference in New Issue
Block a user