1 package System::Introspector::Config;
5 has config => (is => 'lazy');
7 has config_file => (is => 'ro', required => 1);
11 my $reader = Config::General->new($self->config_file);
12 my %config = $reader->getall;
16 sub sudo_user { $_[0]->config->{sudo_user} }
18 sub groups { keys %{ $_[0]->config->{group} || {} } }
20 sub has_group { exists $_[0]->config->{group}{ $_[1] } }
24 my $host_spec = $self->config->{host};
25 return ref($host_spec) ? @$host_spec : $host_spec;
28 sub user { $_[0]->config->{user} }
30 my $_get_inherited = sub {
34 map { ($_ => $data->{$_}) }
35 grep { exists $data->{$_} }
39 sub config_for_group {
40 my ($self, $name) = @_;
42 my $config = $self->config;
43 %common = (%common, $config->$_get_inherited);
44 my $group = $config->{group}{ $name };
45 %common = (%common, $group->$_get_inherited);
51 %{ $group->{introspect}{ $_ } || {} },
53 } keys %{ $group->{introspect} || {} },