@ -21,19 +21,14 @@ sub has_role
{
{
my ( $ self , $ hostname , $ role ) = @ _ ;
my ( $ self , $ hostname , $ role ) = @ _ ;
my $ li_check = 1 ;
if ( $ role eq '*' ) {
$ role = '.+' ;
$ li_check = 0 ;
}
if ( not defined $ self - > { config } { hosts } { $ hostname } ) {
if ( not defined $ self - > { config } { hosts } { $ hostname } ) {
$ hostname = 'self' ;
$ hostname = 'self' ;
}
}
# The LI role has a virtual role counterpart, which is active only in
# The LI role has a virtual role counterpart, which is active only in
# distributed mode.
# distributed mode. We only check for exact matches, as we do not want
if ( $ li_check && 'li_dist' =~ m/^$role$/ ) {
# to grab a regex that would match multiple cases.
if ( 'li_dist' eq $ role ) {
if ( $ self - > { config } { cluster_sets } { type } eq 'distributed' ) {
if ( $ self - > { config } { cluster_sets } { type } eq 'distributed' ) {
$ role = 'li' ;
$ role = 'li' ;
} else {
} else {
@ -44,7 +39,7 @@ sub has_role
if ( any { m/^$role$/ } @ { $ self - > { config } { hosts } { $ hostname } { role } } ) {
if ( any { m/^$role$/ } @ { $ self - > { config } { hosts } { $ hostname } { role } } ) {
# The LI roles are a bit special, they use additional keys to get
# The LI roles are a bit special, they use additional keys to get
# enabled, so we handle them here.
# enabled, so we handle them here.
if ( $ li_check && 'li' =~ m/^$role$/ ) {
if ( 'li' =~ m/^$role$/ ) {
return $ self - > { config } { intercept } { enable } eq 'yes' ;
return $ self - > { config } { intercept } { enable } eq 'yes' ;
} else {
} else {
# Otherwise, unconditionally enable the role.
# Otherwise, unconditionally enable the role.