NAME

App::Puppet::Environment::Updater - Update a Puppet environment in a Git branch

VERSION

version 0.001002

SYNOPSIS

use App::Puppet::Environment::Updater;

App::Puppet::Environment::Updater->new_with_options()->run();

DESCRIPTION

App::Puppet::Environment::Updater is intended to update Puppet environments which are in Git branches. There are many ways to organize a Puppet setup and Puppet environments, and this application supports the following approach:

  • There is one Git repository with four branches, each of which represents a Puppet environment:

    • development

    • test

    • staging

    • production

  • Each branch contains a site.pp with the Puppet nodes that are present in the environment represented by the branch.

  • Puppet modules are included as Git submodules, usually below modules. It's not necessary to use Git submodules, but it simplifies reuse of the Puppet modules in other projects.

The sandbox of the Git repository usually looks about as follows:

.
|-- modules
|   |-- module1
|   |   |-- manifests
|   |   |   `-- init.pp
|   |   `-- templates
|   |       `-- template1.erb
|   `-- module2
|       |-- files
|       |   `-- file1.pl
|       `-- manifests
|           `-- init.pp
`-- site.pp

In order to move a change from eg. development to testing, one can usually simply merge the development branch into the testing branch and update the submodules. This application tries to automate this and work around some of the pitfalls that exist on the way.

METHODS

new

Constructor, creates new instance of the application.

Parameters

This method expects its parameters as a hash reference. See --usage to see which parameters can be passed on the command line.

from

The branch to merge from.

environment

The branch to merge to.

remote

The Git remote where changes can be fetched from and should be pushed to. This application does currently not push any changes. Defaults to origin.

workdir

Directory with the Git sandbox that should be used. Defaults to the current directory, but should point to the toplevel of the working tree.

git

The Git::Wrapper instance to use.

logger

The Log::Dispatchouli instance to use.

get_proxy_logger

Get a proxy logger with a given prefix.

Parameters

This method expects positional parameters.

prefix

A prefix which should be set in the proxy logger.

Result

A Log::Dispatchouli::Proxy instance.

run

Run the application.

Result

Nothing on success, an exception otherwise.

get_local_branches

Get a list with local branches.

Result

The local branches.

remote_branch_for

Construct the name of a remote branch given a branch name.

Parameters

This method expects positional parameters.

branch

Name of the branch the remote branch name should be constructed for.

Result

The name of the remote branch.

create_and_switch_to_branch

Create a local branch starting at the corresponding remote branch and switch to it.

Parameters

This method expects positional parameters.

branch

Name of the branch.

Result

Nothing on success, an exception otherwise.

update_branch

Update a local branch from the corresponding remote branch, using a fast-forward merge.

Parameters

This method expects positional parameters.

branch

The name of the branch which should be updated.

Result

Nothing on success, an exception otherwise.

merge

Merge a given branch into another branch.

Parameters

This method expects positional parameters.

from

The branch to merge from.

to

The branch to merge to.

Result

Nothing on success, an exception otherwise.

update_submodules

Update the submodules.

Result

Nothing on success, an exception otherwise.

SEE ALSO

AUTHOR

Manfred Stock <mstock@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by Manfred Stock.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.