puppet-wp/manifests/role.pp
2019-09-17 19:00:27 +10:00

38 lines
718 B
Puppet

# A class for WP-CLI roles.
define wp::role (
$location,
$id,
$rolename,
$ensure = present,
$all = false,
$user = $::wp::user,
$onlyif = "${wp::params::bin_path}/wp core is-installed",
) {
include wp::cli
case $ensure {
enabled: {
$command = "create ${id} ${rolename}"
}
deleted: {
$command = "delete ${id}"
}
reset: {
if ( $all ) {
$command = 'reset --all'
} else {
$command = "reset ${id}"
}
}
default: {
fail( 'Invalid attributes for wp::role' )
}
}
wp::command { "${location} role ${command}":
location => $location,
command => $command,
user => $user,
onlyif => $onlyif,
}
}