Skip to content

Commit

Permalink
cleanup README.md / fix markdown linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Jan 30, 2020
1 parent a925899 commit 6c43263
Showing 1 changed file with 64 additions and 35 deletions.
99 changes: 64 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

# Puppet::Syntax

Puppet::Syntax checks for correct syntax in Puppet manifests, templates, and Hiera YAML.
Puppet::Syntax checks for correct syntax in Puppet manifests, templates, and
Hiera YAML.

## Version support

Expand All @@ -17,85 +18,112 @@ For the specific versions that we test against, see the [TravisCI config](.travi

## Installation

To install Puppet::Syntax, either add it to your module's Gemfile or install the gem manually.
To install Puppet::Syntax, either add it to your module's Gemfile or install
the gem manually.

* To install with the Gemfile, add:

gem 'puppet-syntax'
```ruby
gem 'puppet-syntax'
```

And then execute:

$ bundle install
```sh
bundle install
```

* To install the gem yourself, run:

$ gem install puppet-syntax
```sh
gem install puppet-syntax
```

## Configuration

To configure Puppet::Syntax, add any of the following settings to your `Rakefile`.

* To exclude certain paths from the syntax checks, set:

PuppetSyntax.exclude_paths = ["vendor/**/*"]
```ruby
PuppetSyntax.exclude_paths = ["vendor/**/*"]
```

* To configure specific paths for the Hiera syntax check, specify `hieradata_paths`. This is useful if you use Hiera data inside your module.

PuppetSyntax.hieradata_paths = ["**/data/**/*.yaml", "hieradata/**/*.yaml", "hiera*.yaml"]
```ruby
PuppetSyntax.hieradata_paths = ["**/data/**/*.yaml", "hieradata/**/*.yaml", "hiera*.yaml"]
```

* To configure specific paths for the Puppet syntax checks or for the templates checks, specify `manifests_paths` or `templates_paths` respectively. This is useful if you want to check specific paths only.

PuppetSyntax.manifests_paths = ["**/environments/future/*.pp"]
PuppetSyntax.templates_paths = ["**/modules/**/templates/*.erb"]
```ruby
PuppetSyntax.manifests_paths = ["**/environments/future/*.pp"]
PuppetSyntax.templates_paths = ["**/modules/**/templates/*.erb"]
```

* To ignore deprecation warnings, disable `fail_on_deprecation_notices`. By default, `puppet-syntax` fails if it encounters Puppet deprecation notices. If you are working with a legacy code base and want to ignore such non-fatal warnings, you might want to override the default behavior.

PuppetSyntax.fail_on_deprecation_notices = false
```ruby
PuppetSyntax.fail_on_deprecation_notices = false
```

* To enable a syntax check on Hiera keys, set:

PuppetSyntax.check_hiera_keys = true
```ruby
PuppetSyntax.check_hiera_keys = true
```

This reports common mistakes in key names in Hiera files, such as:
This reports common mistakes in key names in Hiera files, such as:

- Leading `::` in keys, such as: `::notsotypical::warning2: true`.
- Single colon scope separators, such as: `:picky::warning5: true`.
- Invalid camel casing, such as: `noCamelCase::warning3: true`.
- Use of hyphens, such as: `no-hyphens::warning4: true`.
* Leading `::` in keys, such as: `::notsotypical::warning2: true`.
* Single colon scope separators, such as: `:picky::warning5: true`.
* Invalid camel casing, such as: `noCamelCase::warning3: true`.
* Use of hyphens, such as: `no-hyphens::warning4: true`.

## Usage

* To enable Puppet::Syntax, include the following in your module's `Rakefile`:

require 'puppet-syntax/tasks/puppet-syntax'
```ruby
require 'puppet-syntax/tasks/puppet-syntax'
```

For Continuous Integration, use Puppet::Syntax in conjunction with `puppet-lint` and spec tests. Add the following to your module's `Rakefile`:
For Continuous Integration, use Puppet::Syntax in conjunction with `puppet-lint`
and spec tests. Add the following to your module's `Rakefile`:

task :test => [
:syntax,
:lint,
:spec,
]
```ruby
task :test => [
:syntax,
:lint,
:spec,
]
```

* To test all manifests and templates, relative to the location of the `Rakefile`, run:

$ bundle exec rake syntax
---> syntax:manifests
---> syntax:templates
---> syntax:hiera:yaml
```
$ bundle exec rake syntax
---> syntax:manifests
---> syntax:templates
---> syntax:hiera:yaml
```

* To return a non-zero exit code and an error message on any failures, run:

$ bundle exec rake syntax
---> syntax:manifests
rake aborted!
Could not parse for environment production: Syntax error at end of file at demo.pp:2
Tasks: TOP => syntax => syntax:manifests
(See full trace by running task with --trace)
```
$ bundle exec rake syntax
---> syntax:manifests
rake aborted!
Could not parse for environment production: Syntax error at end of file at demo.pp:2
Tasks: TOP => syntax => syntax:manifests
(See full trace by running task with --trace)
```

## Checks

Puppet::Syntax makes the following checks in the directories and subdirectories of the module, relative to the location of the `Rakefile`.
Puppet::Syntax makes the following checks in the directories and subdirectories
of the module, relative to the location of the `Rakefile`.

### Hiera

Expand All @@ -121,7 +149,8 @@ Checks `.erb` files in the module for syntax errors.

Checks `.epp` files in the module for syntax errors.

EPP checks are supported in Puppet 4 or greater, or in Puppet 3 with the future parser enabled.
EPP checks are supported in Puppet 4 or greater, or in Puppet 3 with the future
parser enabled.

## Contributing

Expand Down

0 comments on commit 6c43263

Please sign in to comment.