Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
puppet-syntax: Validate hiera keys
For a long time puppet-syntax has support to validate hiera keys and
eyaml. We should use this functionality.

https://github.com/voxpupuli/puppet-syntax?tab=readme-ov-file#configuration

From my local testing. The default output:

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

Now that's a bug in puppet-syntax. It always prints the subtasks, even
if they aren't executed.

If I break a hiera data file:

```diff
$ git diff data/common.yaml
diff --git a/data/common.yaml b/data/common.yaml
index ad8bb3d..4243024 100644
--- a/data/common.yaml
+++ b/data/common.yaml
@@ -19,5 +19,5 @@ lookup_options:
     merge: 'unique'

 # Default is currently yum path
-yum::plugin::versionlock::path: /etc/yum/pluginconf.d/versionlock.list
+::yum::plugin::versionlock::path: /etc/yum/pluginconf.d/versionlock.list
 yum::settings::mainconf: /etc/yum.conf
 ```

 I get the following output:

 ```terminal
$ bundle exec rake syntax
---> syntax:manifests
---> syntax:templates
---> syntax:hiera:yaml
WARNING: data/common.yaml: Key ::yum::plugin::versionlock::path: Puppet automatic lookup will not use leading '::'
 ```

 by default puppet-syntax uses the following paths for hiera files:

 ```ruby
  @hieradata_paths = [
    '**/data/**/*.*{yaml,yml}',
    'hieradata/**/*.*{yaml,yml}',
    'hiera*.*{yaml,yml}',
  ]
```

https://github.com/voxpupuli/puppet-syntax/blob/master/lib/puppet-syntax.rb#L9-L13
  • Loading branch information
bastelfreak committed Mar 8, 2024
commit f5a001613f391f214b0e4f977af18dfac893f7a3
1 change: 1 addition & 0 deletions lib/puppetlabs_spec_helper/rake_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
PuppetSyntax.exclude_paths << 'vendor/**/*'
PuppetSyntax.exclude_paths << '.vendor/**/*'
PuppetSyntax.exclude_paths << 'plans/**/*'
PuppetSyntax.check_hiera_keys = true

desc 'Check syntax of Ruby files and call :syntax and :metadata_lint'
task :validate do
Expand Down