Rex-CMDB-TOML

 view release on metacpan or  search on metacpan

lib/Rex/CMDB/TOML.pm  view on Meta::CPAN

			if ( !exists $template_vars{$key} ) {
				$template_vars{$key} = $config_values->{$key};
			}
		}
		$template_vars{environment} = Rex::Commands::environment();

		for my $file (@files) {
			Rex::Logger::debug("CMDB - Opening $file");
			if ( -f $file ) {

				my $content = eval { local ( @ARGV, $/ ) = ($file); <>; };
				my $t       = Rex::Config->get_template_function();
				$content .= "\n";    # for safety
				$content = $t->( $content, \%template_vars );

				my ( $ref, $parse_error ) = from_toml($content);

				# only merge it if we have a actual result
				if ( defined($ref) ) {
					$result = $self->{merger}->merge( $result, $ref );
				}

lib/Rex/CMDB/TOML.pm  view on Meta::CPAN

	{
		Rex::Logger::debug("CMDB - Starting role processing");

		# load each role
		foreach my $role ( @{ $result->{roles} } ) {
			Rex::Logger::debug( "CMDB - Processing role '" . $role . "'" );
			my $role_file = File::Spec->join( $self->{roles_path}, $role . '.toml' );

			# if the file exists, load it
			if ( -f $role_file ) {
				my $content = eval { local ( @ARGV, $/ ) = ($role_file); <>; };
				my $t       = Rex::Config->get_template_function();
				$content .= "\n";    # for safety
				$content = $t->( $content, \%template_vars );

				my ( $ref, $parse_error ) = from_toml($content);

				# only merge it if we have a actual result
				# undef causes the merge feature to wipe it all out
				# that and it did error... so we need to handle the error
				if ( defined($ref) ) {



( run in 0.496 second using v1.01-cache-2.11-cpan-49f99fa48dc )