NAME

Pantry::Model::Pantry - Pantry data model for a pantry directory

VERSION

version 0.012

SYNOPSIS

my $pantry = Pantry::Model::Pantry->new;
my $node = $pantry->node("foo.example.com");

DESCRIPTION

Models a 'pantry' -- a directory containing files used to manage servers with Chef Solo by Opscode.

ATTRIBUTES

path

Path to the pantry directory. Defaults to the current directory.

METHODS

all_nodes

my @nodes = $pantry->all_nodes;

In list context, returns a list of nodes. In scalar context, returns a count of nodes.

node

my $node = $pantry->node("foo.example.com");

Returns a Pantry::Model::Node object corresponding to the given node. If the node exists in the pantry, it will be loaded from the saved node file. Otherwise, it will be created in memory (but will not be persisted to disk).

find_node

my @nodes = $pantry->find_node( $leading_part );

Finds one or more node matching a leading part. For example, given nodes 'foo.example.com' and 'bar.example.com' in a pantry, use <$pantry-find_node("foo")>> to get 'foo.example.com'.

Returns a list of node objects if any are found.

all_roles

my @roles = $pantry->all_roles;

In list context, returns a list of roles. In scalar context, returns a count of roles.

role

my $node = $pantry->role("web");

Returns a Pantry::Model::Role object corresponding to the given role. If the role exists in the pantry, it will be loaded from the saved role file. Otherwise, it will be created in memory (but will not be persisted to disk).

find_role

my @roles = $pantry->find_role( $leading_part );

Finds one or more role matching a leading part. For example, given roles 'web' and 'mysql' in a pantry, use <$pantry-find_role("my")>> to get 'mysql'.

Returns a list of role objects if any are found.

all_environments

my @environments = $pantry->all_environments;

In list context, returns a list of environments. In scalar context, returns a count of environments.

environment

my $node = $pantry->environment("staging");

Returns a Pantry::Model::Environment object corresponding to the given environment.

find_environment

my @environments = $pantry->find_environment( $leading_part );

Finds one or more environment matching a leading part. For example, given environments 'test' and 'staging' in a pantry, use <$pantry-find_environment('sta')>> to get 'staging'.

Returns a list of environment objects if any are found.

cookbook

my $node = $pantry->cookbook("myapp");

Returns a Pantry::Model::Cookbook object corresponding to the given cookbook.

all_bags

my @bags = $pantry->all_bags;

In list context, returns a list of bags. In scalar context, returns a count of bags.

bag

my $node = $pantry->bag("xdg");

Returns a Pantry::Model::DataBag object corresponding to the given bag. If the bag exists in the pantry, it will be loaded from the saved bag file. Otherwise, it will be created in memory (but will not be persisted to disk).

find_bag

my @bags = $pantry->find_bag( $leading_part );

Finds one or more bag matching a leading part. For example, given bags 'web' and 'mysql' in a pantry, use <$pantry-find_bag("my")>> to get 'mysql'.

Returns a list of bag objects if any are found.

AUTHOR

David Golden <dagolden@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2011 by David Golden.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004