<commit_before># Serverkit [![Build Status](https://travis-ci.org/r7kamura/serverkit.svg)](https://travis-ci.org/r7kamura/serverkit) [![Code Climate](https://codeclimate.com/github/r7kamura/serverkit/badges/gpa.svg)](https://codeclimate.com/github/r7kamura/serverkit)
Configuration management toolkit for IT automation.

## Usage
This gem provides `serverkit` executable with 3 actions.
`validate` action validates your recipe format.
`check` action shows the difference between your recipe and the state of the target host.
`apply` action executes migration programs to fill-in the gaps.

```sh
serverkit validate --recipe=recipe.yml
serverkit check --recipe=recipe.yml
serverkit apply --recipe=recipe.yml
```

## Recipe
A recipe describes the desired state of your server.
It is mostly a collection of resources, defined using certain patterns.

### Format
A recipe can be specified as a path to one of the following patterns:

- JSON file
- YAML file named with \*.yaml or \*.yml
- ERB file named with \*.json.erb or \*.yml.erb
- Executable to output JSON
- Directory including recipe files recursively

```sh
serverkit apply --recipe=recipe
serverkit apply --recipe=recipe.json
serverkit apply --recipe=recipe.json.erb
serverkit apply --recipe=recipe.json.erb --variables=variables
serverkit apply --recipe=recipe.json.erb --variables=variables.json
serverkit apply --recipe=recipe.json.erb --variables=variables.json.erb
serverkit apply --recipe=recipe.json.erb --variables=variables.yml
serverkit apply --recipe=recipe.json.erb --variables=variables.yml.erb
serverkit apply --recipe=recipe.yml
serverkit apply --recipe=recipe.yml.erb
serverkit apply --recipe=recipes/
```

### Variables
When using ERB recipe, you can also give optional variables file
that defines configurations in a Hash object for ERB template.
It supports similar format variation with Recipe.
In ERB template, you can refer given variables via `variables` method.

### Example
This is an example recipe to install some packages, clone a git repository, and create a symlink.

```yaml
# variables.yml
dotfiles_repository: r7kamura/dotfiles
user: r7kamura
```

```yaml
# recipe.yml.erb
resources:
  - id: install_mysql
    type: package<commit_msg>Add example of passing variables directory path<commit_after># Serverkit [![Build Status](https://travis-ci.org/r7kamura/serverkit.svg)](https://travis-ci.org/r7kamura/serverkit) [![Code Climate](https://codeclimate.com/github/r7kamura/serverkit/badges/gpa.svg)](https://codeclimate.com/github/r7kamura/serverkit)
Configuration management toolkit for IT automation.

## Usage
This gem provides `serverkit` executable with 3 actions.
`validate` action validates your recipe format.
`check` action shows the difference between your recipe and the state of the target host.
`apply` action executes migration programs to fill-in the gaps.

```sh
serverkit validate --recipe=recipe.yml
serverkit check --recipe=recipe.yml
serverkit apply --recipe=recipe.yml
```

## Recipe
A recipe describes the desired state of your server.
It is mostly a collection of resources, defined using certain patterns.

### Format
A recipe can be specified as a path to one of the following patterns:

- JSON file
- YAML file named with \*.yaml or \*.yml
- ERB file named with \*.json.erb or \*.yml.erb
- Executable to output JSON
- Directory including recipe files recursively

```sh
serverkit apply --recipe=recipe
serverkit apply --recipe=recipe.json
serverkit apply --recipe=recipe.json.erb
serverkit apply --recipe=recipe.json.erb --variables=variables
serverkit apply --recipe=recipe.json.erb --variables=variables.json
serverkit apply --recipe=recipe.json.erb --variables=variables.json.erb
serverkit apply --recipe=recipe.json.erb --variables=variables.yml
serverkit apply --recipe=recipe.json.erb --variables=variables.yml.erb
serverkit apply --recipe=recipe.json.erb --variables=variables/
serverkit apply --recipe=recipe.yml
serverkit apply --recipe=recipe.yml.erb
serverkit apply --recipe=recipes/
```

### Variables
When using ERB recipe, you can also give optional variables file
that defines configurations in a Hash object for ERB template.
It supports similar format variation with Recipe.
In ERB template, you can refer given variables via `variables` method.

### Example
This is an example recipe to install some packages, clone a git repository, and create a symlink.

```yaml
# variables.yml
dotfiles_repository: r7kamura/dotfiles
user: r7kamura
```

```yaml
# recipe.yml.erb
resources:
  - id: install_mysql
    type: package
{'fraction_non_alphanumeric': 0.10316761988561372, 'fraction_numerical': 0.0030796304443466782, 'mean_word_length': 4.741161616161616, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '696168', 'n_tokens_mistral': 1399, 'n_tokens_neox': 1334, 'n_words': 473}