ll be prompted to confirm
deletion.
=head3 show
$ pantry show node NAME
Prints to STDOUT the JSON data for the given C<NAME>.
=head3 apply
$ pantry apply node NAME --recipe nginx --role mail
al string containing 'true' or 'false', it will be
replaced in the configuration data with actual JSON boolean values.
N.B. While the term C<--default> is used for command line consistency, attribute
iable C<EDITOR> on
the configuration file for the C<name> node.
The resulting file must be valid JSON in a form acceptable to Chef. Generally,
you should use the C<apply> or C<strip> commands instea
asename qw/dirname basename/;
use File::Slurp qw/read_file/;
use IPC::Cmd qw/can_run/;
use JSON qw/decode_json/;
use namespace::clean;
sub abstract {
return 'Edit items in a pantry (nodes, roles,
failed!: $!";
eval { decode_json(read_file($path,{ binmode => ":raw" })) };
if ( my $err = $@ ) {
$err =~ s/, at .* line .*//;
warn "Warning: JSON errors in config for $name\n";
ESCRIPTION
This class implements the C<pantry edit> command, which is used to open the node data
JSON file in an editor for direct editing.
=for Pod::Coverage options validate
=head1 AUTHOR
David
,
isa => AbsDir,
coerce => 1,
default => sub { dir(".")->absolute }
);
# where environment JSON files and node subdirectories are stored
sub _environment_dir {
my ($self) = @_;
my $path = $
$path;
}
# file path where environment JSON file is located
sub _environment_path {
my ($self, $env) = @_;
return $self->_environment_dir->file("${env}.json");
}
sub _node_path {
my ($self, $n
rn $self->_node_dir($env)->file("${node_name}.json");
}
sub _role_path {
my ($self, $role_name) = @_;
return $self->_role_dir->file("${role_name}.json");
}
sub _cookbook_path {
my ($self, $coo
run_list ];
}
$data->{json_class} = "Chef::Role";
$data->{chef_type} = "role";
return $data;
}
sub _thaw {
my ($self, $data) = @_;
delete $data->{$_} for qw/json_class chef_type/;
for m
new;
}
$data->{json_class} = "Chef::Environment";
$data->{chef_type} = "environment";
return $data;
}
sub _thaw {
my ($self, $data) = @_;
delete $data->{$_} for qw/json_class chef_type/;
t;
use warnings;
package Pantry::Role::Serializable;
# ABSTRACT: A role to save/load data to/from JSON files
our $VERSION = '0.012'; # VERSION
use MooseX::Role::Parameterized;
use Moose::Util qw/get_
use File::Path qw/mkpath/;
use File::Slurp qw/read_file write_file/;
use Storable qw/dclone/;
use JSON 2;
parameter freezer => (
isa => 'Str',
);
parameter thawer => (
isa => 'Str',
);
role {
w", scalar_ref => 1 } );
# XXX check if string needs UTF-8 decoding?
my $data = $class->_json_thaw( $str_ref );
if ($thawer) {
$data = $class->$thawer($data);
}
$data->{_p
try sync subcommand
our $VERSION = '0.012'; # VERSION
use Pantry::App -command;
use autodie;
use JSON 2;
use Storable qw/dclone/;
use Net::OpenSSH;
use Path::Class;
use Pantry::Model::Util qw/merge_h
# prepare node JSON for upload
# XXX should really check to be sure it exists
my ($node_fh, $node_json) = tempfile( "node.json-XXXXXX", TMPDIR => 1 );
$obj->save_as($node_json);
# XXX Chef
);
if ( -e $env->path ) { # if we have a data file, then merge it
my $base = decode_json( file($node_json)->slurp );
my $env_default = dclone $env->default_attributes;
my $env_override =
ry apply subcommand
our $VERSION = '0.012'; # VERSION
use Pantry::App -command;
use autodie;
use JSON;
use namespace::clean;
sub abstract {
return 'Apply recipes or attributes to a node or role'
my ($self, $value) = @_;
if ($value eq 'false') {
$value = JSON::false;
}
elsif ( $value eq 'true' ) {
$value = JSON::true;
}
return $value;
}
1;
# vim: ts=2 sts=2 sw=2 et:
__
head1 DESCRIPTION
This class implements the C<pantry show> command, which is used to
display the JSON data for a node.
=for Pod::Coverage options validate
=head1 AUTHOR
David Golden <dagolden@cpan
rs or array references,
except for boolean values which should be set as L<JSON::Boolean>
values like C<JSON::true> and C<JSON::false>.
=head2 pantry_host
This optional attribute holds an alternate