Skip to content

Commit

Permalink
Array typecast
Browse files Browse the repository at this point in the history
  • Loading branch information
alvagante committed Sep 25, 2024
1 parent 86ac0b1 commit 1ac7ed1
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 83 deletions.
11 changes: 0 additions & 11 deletions CHANGELOG.md

This file was deleted.

85 changes: 35 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Puppi: Puppet Knowledge to the CLI
# Puppi: Applications deployment as code

Puppi is maintained by Example42 GmbH
Puppi is maintained by Example42

Licence: Apache 2

Puppi is a unique tool that serves both as a Puppet module and a CLI command tool.
It's data is entirely driven by Puppet code.
Example use cases for Puppi may include:

- creating a standardize method to automate the deployment of web applications
- or to provide a set of standard commands to query and check system resources based on "user defined actions".

Expand All @@ -15,33 +16,29 @@ Its structure provides FULL flexibility on the type of "actions" that may be req
The module provides:

* Puppi v1 script

* A set of scripts that can be chained together to automate any kind of deployment.

* Puppet defines that make it easy to prepare a puppi set of commands for a project deployment.

* Puppet defines to populate the output of the different actions.

This module requires functions provided by the [Puppet Labs Stdlib Module](https://github.com/puppetlabs/puppetlabs-stdlib).


## HOW TO INSTALL

Download Puppi from GitHub and place it in your modules directory:
Install the module from the Forge:

```bash
git clone https://github.com/example42/puppi.git /etc/puppet/modules/puppi
```bash {"id":"01J8MJ40BQWMDAJC3F710YREN4"}
puppet module install example42/puppi
```

To use the Puppi just declare or include the puppi class

```ruby
```ruby {"id":"01J8MJ40BQWMDAJC3F7286XQQK"}
include puppi
```

If you have resources conflicts, do not install automatically the Puppi dependencies (commands and packages)

```ruby
```ruby {"id":"01J8MJ40BQWMDAJC3F72Q9E3VZ"}
class { 'puppi':
install_dependencies => false,
}
Expand All @@ -53,34 +50,33 @@ Once Puppi is installed you can use it to:

* Easily define in Puppet manifests Web Applications deploy procedures. For example:

```ruby
puppi::project::war { "myapp":
source => "http://repo.example42.com/deploy/prod/myapp.war",
deploy_root => "/opt/tomcat/myapp/webapps",
}
```
```ruby {"id":"01J8MJ40BQWMDAJC3F748G9HWW"}
puppi::project::war { "myapp":
source => "http://repo.example42.com/deploy/prod/myapp.war",
deploy_root => "/opt/tomcat/myapp/webapps",
}
```

* Integrate with your modules for puppi check, info and log

* Enable Example42 modules integration


## HOW TO USE WITH EXAMPLE42 MODULES

The Example42 modules version 1 provide (optional) Puppi integration.
Once enabled for each module you have puppi check, info and log commands.

To enable Puppi integration in OldGen (version 1) Example42 Modules, set in the scope these variables:

```
```html {"id":"01J8MJ40BQWMDAJC3F74Q6B0KZ"}
$puppi = yes # Enables puppi integration
$monitor = yes # Enables automatic monitoring
$monitor_tool = "puppi" # Sets puppi as monitoring tool
```

## USAGE OF THE PUPPI COMMAND (OLD GEN)

```bash
```bash {"id":"01J8MJ40BQWMDAJC3F7615PETB"}
puppi <action> <project_name> [ -options ]
```

Expand Down Expand Up @@ -119,19 +115,14 @@ In the deploy/rollback/init actions, puppi runs the commands in /etc/puppi/proje
You can also provide some options:

* -f : Force puppi commands execution also on CRITICAL errors

* -i : Interactively ask confirmation for every command

* -t : Test mode. Just show the commands that should be executed without doing anything

* -d <yes|full>: Debug mode. Show debugging info during execution

* -o "parameter=value parameter2=value2" : Set manual options to override defaults. The options must be in parameter=value syntax, separated by spaces and inside double quotes.


Some common puppi commands when you log for an application deployment:

```bash
```bash {"id":"01J8MJ40BQWMDAJC3F790N39R5"}
puppi check
puppi log & # (More readable if done on another window)
puppi deploy myapp
Expand Down Expand Up @@ -178,7 +169,6 @@ Create an info entry with the commands used to provide info on a topic

Read details in the relevant READMEs


## FILE PATHS (all of them are provided, and can be configured, in the puppi module):

A link to the actual version of puppi enabled
Expand Down Expand Up @@ -229,52 +219,47 @@ A runtime configuration file, which is used by all the the scripts invoked by pu

/tmp/puppi/$project/config


## HOW TO CUSTOMIZE

It should be clear that with puppi you have full flexibility in the definition of a deployment
procedure, since the puppi command is basically a wrapper that executes arbitrary scripts with
a given sequence, in pure KISS logic.

The advantanges though, are various:
* You have a common syntax to manage deploys and rollbacks on an host

* You have a common syntax to manage deploys and rollbacks on an host
* In your Puppet manifests, you can set in simple, coherent and still flexible and customizable
defines all the elements, you need for your application deployments.
Think about it: with just a Puppet define you build the whole deploy logic

defines all the elements, you need for your application deployments.
Think about it: with just a Puppet define you build the whole deploy logic
* Reporting for each deploy/rollback is built-in and extensible

* Automatic checks can be built in the deploy procedure

* You have a common, growing, set of general-use scripts for typical actions

* You have quick and useful command to see what's happening on the system (puppi check, log, info)

There are different parts where you can customize the behaviour of puppi:

* The set of general-use scripts in /etc/puppi/scripts/ ( this directory is filled with the content
of puppi/files/scripts/ ) can/should be enhanced. These can be arbitrary scripts in whatever
language. If you want to follow puppi's logic, though, consider that they should import the
common and runtime configuration files and have an exit code logic similar to the one of
Nagios plugins: 0 is OK, 1 is WARNING, 2 is CRITICAL. Note that by default a script that
exits with WARNING doesn't block the deploy procedure, on the other hand, if a script exits
with CRITICAL (exit 2) by default it blocks the procedure.
Take a second, also, to explore the runtime config file created by the puppi command that
contains variables that can be set and used by the scripts invoked by puppi.

of puppi/files/scripts/ ) can/should be enhanced. These can be arbitrary scripts in whatever
language. If you want to follow puppi's logic, though, consider that they should import the
common and runtime configuration files and have an exit code logic similar to the one of
Nagios plugins: 0 is OK, 1 is WARNING, 2 is CRITICAL. Note that by default a script that
exits with WARNING doesn't block the deploy procedure, on the other hand, if a script exits
with CRITICAL (exit 2) by default it blocks the procedure.
Take a second, also, to explore the runtime config file created by the puppi command that
contains variables that can be set and used by the scripts invoked by puppi.
* The custom project defines that describe deploy templates. These are placed in
puppi/manifests/project/ and can request all the arguments you want to feed your scripts with.
Generally is a good idea to design a standard enough template that can be used for all the
cases where the deployment procedure involves similar steps. Consider also that you can handle
exceptions with variables (see the $loadbalancer_ip usage in puppi/manifests/project/maven.pp)

puppi/manifests/project/ and can request all the arguments you want to feed your scripts with.
Generally is a good idea to design a standard enough template that can be used for all the
cases where the deployment procedure involves similar steps. Consider also that you can handle
exceptions with variables (see the $loadbalancer_ip usage in puppi/manifests/project/maven.pp)

## (NO) DEPENDENCIES AND CONFLICTS

Puppi is self contained. It doesn't require other modules.
(And is required by all Example42 modules).

For correct functionality by default some extra packages are installed.
If you have conflicts with your existing modules, set the argument:

install_dependencies => false
install_dependencies => false

9 changes: 1 addition & 8 deletions manifests/info.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@
require puppi
require puppi::params

if $run.type == Array {
$array_run = $run
} else {
$array_run = $run ? {
'' => [],
default => split($run, ','),
}
}
$array_run = Array($run)

file { "${puppi::params::infodir}/${name}":
ensure => file,
Expand Down
6 changes: 1 addition & 5 deletions manifests/log.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
require puppi
require puppi::params

if $log.type == Array {
$array_log = $log
} else {
$array_log = split($log, ',')
}
$array_log = Array($log)

file { "${puppi::params::logsdir}/${name}":
ensure => 'file',
Expand Down
9 changes: 1 addition & 8 deletions manifests/todo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,7 @@
require puppi
require puppi::params

if $run.type == Array {
$array_run = $run
} else {
$array_run = $run ? {
'' => [],
default => split($run, ','),
}
}
$array_run = Array($run)

file { "${puppi::params::tododir}/${name}":
ensure => file,
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 3.0.0 < 9.0.0"
"version_requirement": ">= 5.0.0 < 9.0.0"
}
],
"description": "This module provides the Puppi libraries required by Example42 modules and, if explicitly included, the puppi command, its working environment, the defines and procedures to deploy applications",
Expand Down

0 comments on commit 1ac7ed1

Please sign in to comment.