puppet-wp/manifests/option.pp
2019-09-03 18:59:18 +10:00

36 lines
686 B
Puppet

# A class for WordPress options.
define wp::option (
$location,
$key = $title,
$value = undef,
$ensure = present,
$format = 'plaintext',
$autoload = true,
$user = $::wp::user,
) {
include wp::cli
case $ensure {
present: {
$command = "add ${key} --format=${format} --autoload=${autoload}"
}
equal: {
if $value == undef {
fail('Option value must be specified')
}
$command = "update ${key} ${value}"
}
absent: {
$command = "delete ${key}"
}
default: {
fail('Invalid option operation')
}
}
wp::command { "${location} option ${command}":
location => $location,
command => "option ${command}",
user => $user,
}
}