|
|
@@ -65,45 +65,45 @@ define ceph::mon (
|
|
|
|
Enum['cephx', 'none'] $authentication_type = 'cephx',
|
|
|
|
Enum['cephx', 'none'] $authentication_type = 'cephx',
|
|
|
|
$key = undef,
|
|
|
|
$key = undef,
|
|
|
|
$keyring = undef,
|
|
|
|
$keyring = undef,
|
|
|
|
$exec_timeout = undef
|
|
|
|
Optional[Float[0]] $exec_timeout = undef,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
include ceph::params
|
|
|
|
include ceph::params
|
|
|
|
$exec_timeout_real = $exec_timeout ? {
|
|
|
|
$exec_timeout_real = $exec_timeout ? {
|
|
|
|
undef => $ceph::params::exec_timeout,
|
|
|
|
undef => $ceph::params::exec_timeout,
|
|
|
|
default => $exec_timeout,
|
|
|
|
default => $exec_timeout,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# a puppet name translates into a ceph id, the meaning is different
|
|
|
|
# a puppet name translates into a ceph id, the meaning is different
|
|
|
|
$id = $name
|
|
|
|
$id = $name
|
|
|
|
|
|
|
|
|
|
|
|
if $cluster {
|
|
|
|
if $cluster {
|
|
|
|
$cluster_name = $cluster
|
|
|
|
$cluster_name = $cluster
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$cluster_name = 'ceph'
|
|
|
|
$cluster_name = 'ceph'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$cluster_option = "--cluster ${cluster_name}"
|
|
|
|
$cluster_option = "--cluster ${cluster_name}"
|
|
|
|
|
|
|
|
|
|
|
|
# NOTE(aschultz): this is the service title for the mon service. It may be
|
|
|
|
# NOTE(aschultz): this is the service title for the mon service. It may be
|
|
|
|
# different than the actual service name.
|
|
|
|
# different than the actual service name.
|
|
|
|
$mon_service = "ceph-mon-${id}"
|
|
|
|
$mon_service = "ceph-mon-${id}"
|
|
|
|
|
|
|
|
|
|
|
|
if $ensure == present {
|
|
|
|
if $ensure == present {
|
|
|
|
|
|
|
|
|
|
|
|
$ceph_mkfs = "ceph-mon-mkfs-${id}"
|
|
|
|
$ceph_mkfs = "ceph-mon-mkfs-${id}"
|
|
|
|
|
|
|
|
|
|
|
|
if $authentication_type == 'cephx' {
|
|
|
|
if $authentication_type == 'cephx' {
|
|
|
|
if ! $key and ! $keyring {
|
|
|
|
if ! $key and ! $keyring {
|
|
|
|
fail("authentication_type ${authentication_type} requires either key or keyring to be set but both are undef")
|
|
|
|
fail("authentication_type ${authentication_type} requires either key or keyring to be set but both are undef")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if $key and $keyring {
|
|
|
|
if $key and $keyring {
|
|
|
|
fail("key (set to ${key}) and keyring (set to ${keyring}) are mutually exclusive")
|
|
|
|
fail("key (set to ${key}) and keyring (set to ${keyring}) are mutually exclusive")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if $key {
|
|
|
|
if $key {
|
|
|
|
$keyring_path = "/tmp/ceph-mon-keyring-${id}"
|
|
|
|
$keyring_path = "/tmp/ceph-mon-keyring-${id}"
|
|
|
|
|
|
|
|
|
|
|
|
Ceph_config<||>
|
|
|
|
Ceph_config<||>
|
|
|
|
-> exec { "create-keyring-${id}":
|
|
|
|
-> exec { "create-keyring-${id}":
|
|
|
|
command => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
command => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
set -ex
|
|
|
|
set -ex
|
|
|
|
cat > ${keyring_path} << EOF
|
|
|
|
cat > ${keyring_path} << EOF
|
|
|
|
[mon.]
|
|
|
|
[mon.]
|
|
|
@@ -113,42 +113,42 @@ EOF
|
|
|
|
|
|
|
|
|
|
|
|
chmod 0444 ${keyring_path}
|
|
|
|
chmod 0444 ${keyring_path}
|
|
|
|
",
|
|
|
|
",
|
|
|
|
unless => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
unless => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
set -ex
|
|
|
|
set -ex
|
|
|
|
mon_data=\$(ceph-mon ${cluster_option} --id ${id} --show-config-value mon_data) || exit 1
|
|
|
|
mon_data=\$(ceph-mon ${cluster_option} --id ${id} --show-config-value mon_data) || exit 1
|
|
|
|
# if ceph-mon fails then the mon is probably not configured yet
|
|
|
|
# if ceph-mon fails then the mon is probably not configured yet
|
|
|
|
test -e \$mon_data/done
|
|
|
|
test -e \$mon_data/done
|
|
|
|
",
|
|
|
|
",
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Exec["create-keyring-${id}"] -> Exec[$ceph_mkfs]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$keyring_path = $keyring
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Exec["create-keyring-${id}"] -> Exec[$ceph_mkfs]
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$keyring_path = '/dev/null'
|
|
|
|
$keyring_path = $keyring
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if $public_addr {
|
|
|
|
} else {
|
|
|
|
ceph_config {
|
|
|
|
$keyring_path = '/dev/null'
|
|
|
|
"mon.${id}/public_addr": value => $public_addr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ceph_config<||>
|
|
|
|
if $public_addr {
|
|
|
|
# prevent automatic creation of the client.admin key by ceph-create-keys
|
|
|
|
ceph_config {
|
|
|
|
-> exec { "ceph-mon-${cluster_name}.client.admin.keyring-${id}":
|
|
|
|
"mon.${id}/public_addr": value => $public_addr;
|
|
|
|
command => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ceph_config<||>
|
|
|
|
|
|
|
|
# prevent automatic creation of the client.admin key by ceph-create-keys
|
|
|
|
|
|
|
|
-> exec { "ceph-mon-${cluster_name}.client.admin.keyring-${id}":
|
|
|
|
|
|
|
|
command => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
set -ex
|
|
|
|
set -ex
|
|
|
|
touch /etc/ceph/${cluster_name}.client.admin.keyring",
|
|
|
|
touch /etc/ceph/${cluster_name}.client.admin.keyring",
|
|
|
|
unless => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
unless => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
set -ex
|
|
|
|
set -ex
|
|
|
|
test -e /etc/ceph/${cluster_name}.client.admin.keyring",
|
|
|
|
test -e /etc/ceph/${cluster_name}.client.admin.keyring",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-> exec { $ceph_mkfs:
|
|
|
|
-> exec { $ceph_mkfs:
|
|
|
|
command => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
command => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
set -ex
|
|
|
|
set -ex
|
|
|
|
mon_data=\$(ceph-mon ${cluster_option} --id ${id} --show-config-value mon_data)
|
|
|
|
mon_data=\$(ceph-mon ${cluster_option} --id ${id} --show-config-value mon_data)
|
|
|
|
if [ ! -d \$mon_data ] ; then
|
|
|
|
if [ ! -d \$mon_data ] ; then
|
|
|
@@ -177,61 +177,61 @@ if [ ! -d \$mon_data ] ; then
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
",
|
|
|
|
",
|
|
|
|
unless => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
unless => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
set -ex
|
|
|
|
set -ex
|
|
|
|
mon_data=\$(ceph-mon ${cluster_option} --id ${id} --show-config-value mon_data)
|
|
|
|
mon_data=\$(ceph-mon ${cluster_option} --id ${id} --show-config-value mon_data)
|
|
|
|
test -d \$mon_data
|
|
|
|
test -d \$mon_data
|
|
|
|
",
|
|
|
|
",
|
|
|
|
logoutput => true,
|
|
|
|
logoutput => true,
|
|
|
|
timeout => $exec_timeout_real,
|
|
|
|
timeout => $exec_timeout_real,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-> service { $mon_service:
|
|
|
|
-> service { $mon_service:
|
|
|
|
ensure => running,
|
|
|
|
ensure => running,
|
|
|
|
enable => $mon_enable,
|
|
|
|
enable => $mon_enable,
|
|
|
|
name => "ceph-mon@${id}",
|
|
|
|
name => "ceph-mon@${id}",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# if the service is running before we setup the configs, notify service
|
|
|
|
# if the service is running before we setup the configs, notify service
|
|
|
|
Ceph_config<||>
|
|
|
|
Ceph_config<||>
|
|
|
|
~> Service[$mon_service]
|
|
|
|
~> Service[$mon_service]
|
|
|
|
|
|
|
|
|
|
|
|
if $authentication_type == 'cephx' {
|
|
|
|
if $authentication_type == 'cephx' {
|
|
|
|
if $key {
|
|
|
|
if $key {
|
|
|
|
Exec[$ceph_mkfs] -> Exec["rm-keyring-${id}"]
|
|
|
|
Exec[$ceph_mkfs] -> Exec["rm-keyring-${id}"]
|
|
|
|
|
|
|
|
|
|
|
|
exec { "rm-keyring-${id}":
|
|
|
|
exec { "rm-keyring-${id}":
|
|
|
|
command => "/bin/rm ${keyring_path}",
|
|
|
|
command => "/bin/rm ${keyring_path}",
|
|
|
|
unless => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
unless => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
set -ex
|
|
|
|
set -ex
|
|
|
|
test ! -e ${keyring_path}
|
|
|
|
test ! -e ${keyring_path}
|
|
|
|
",
|
|
|
|
",
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
service { $mon_service:
|
|
|
|
service { $mon_service:
|
|
|
|
ensure => stopped,
|
|
|
|
ensure => stopped,
|
|
|
|
enable => $mon_enable,
|
|
|
|
enable => $mon_enable,
|
|
|
|
name => "ceph-mon@${id}",
|
|
|
|
name => "ceph-mon@${id}",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-> exec { "remove-mon-${id}":
|
|
|
|
-> exec { "remove-mon-${id}":
|
|
|
|
command => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
command => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
set -ex
|
|
|
|
set -ex
|
|
|
|
mon_data=\$(ceph-mon ${cluster_option} --id ${id} --show-config-value mon_data)
|
|
|
|
mon_data=\$(ceph-mon ${cluster_option} --id ${id} --show-config-value mon_data)
|
|
|
|
rm -fr \$mon_data
|
|
|
|
rm -fr \$mon_data
|
|
|
|
",
|
|
|
|
",
|
|
|
|
unless => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
unless => "/bin/true # comment to satisfy puppet syntax requirements
|
|
|
|
set -ex
|
|
|
|
set -ex
|
|
|
|
which ceph-mon || exit 0 # if ceph-mon is not available we already uninstalled ceph and there is nothing to do
|
|
|
|
which ceph-mon || exit 0 # if ceph-mon is not available we already uninstalled ceph and there is nothing to do
|
|
|
|
mon_data=\$(ceph-mon ${cluster_option} --id ${id} --show-config-value mon_data)
|
|
|
|
mon_data=\$(ceph-mon ${cluster_option} --id ${id} --show-config-value mon_data)
|
|
|
|
test ! -d \$mon_data
|
|
|
|
test ! -d \$mon_data
|
|
|
|
",
|
|
|
|
",
|
|
|
|
logoutput => true,
|
|
|
|
logoutput => true,
|
|
|
|
timeout => $exec_timeout_real,
|
|
|
|
timeout => $exec_timeout_real,
|
|
|
|
}
|
|
|
|
|
|
|
|
-> ceph_config {
|
|
|
|
|
|
|
|
"mon.${id}/public_addr": ensure => absent;
|
|
|
|
|
|
|
|
} -> Package<| tag == 'ceph' |>
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-> ceph_config {
|
|
|
|
|
|
|
|
"mon.${id}/public_addr": ensure => absent;
|
|
|
|
|
|
|
|
} -> Package<| tag == 'ceph' |>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|