Ask Your Question

(<unknown>): did not find expected key while parsing a block mapping

asked 2015-03-11 07:08:18 -0600

Chutki gravatar image


I know this question was posted many times. but I have no clue how to find out solution. I am getting below error in agent.

(<unknown>): did not find expected key while parsing a block mapping
at line 5
    column 3

Below is my hiera.yaml file

  - yaml
  :datadir: /etc/puppet/hiera
  - '%{::env}/test/nodes'
  - '%{::env}/test/sudo'

I tried run with --trace but it is not giving much, printing same error.

edit retag flag offensive close merge delete


What are you trying to do? A bit more info would be nice. Did you try using hiera from the command line to check if it ouputs the data you think it does? hiera -d (your key) environment=(your env).

PorkCharSui gravatar imagePorkCharSui ( 2015-03-11 10:31:59 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2015-05-13 03:59:46 -0600

Sgaduuw gravatar image

updated 2015-05-15 02:27:56 -0600

There is a formatting problem in your yaml file(s). You can try using yaml-lint to find out where the problem is. You can install it with gem install yaml-lint, or use the following code snippet:

package { 'yaml-lint':
  ensure   => installed,
  provider => 'gem',

Then run yaml-lint on your hiera datadir: yaml-lint /etc/puppet/hiera.

edit flag offensive delete link more


I didn't find "yaml-lint" package in my repo. so unable to run it. do you know where we can get the package.

Chutki gravatar imageChutki ( 2015-05-14 05:27:23 -0600 )edit

Yaml-lint is not part of any defauly yum repository I know of. I have expanded my answer with a code snippet that installs yaml-lint for you

Sgaduuw gravatar imageSgaduuw ( 2015-05-15 02:25:47 -0600 )edit

yes I tried to run "gem install yaml-lint" but getting "gem install yaml-lint ERROR: does not appear to be a repository ERROR: Could not find a valid gem 'yaml-lint' (>= 0) in any repository"

Chutki gravatar imageChutki ( 2015-05-15 03:36:04 -0600 )edit

"yaml-lint" package is not available in gem package. when i run $gem list getting rspec-puppet (1.0) puppet-lint (0.3) how to get yaml-lint pacakge

Chutki gravatar imageChutki ( 2015-05-25 02:07:01 -0600 )edit

Thank you. I downloaded yaml-lint gem, it really reduced my formatting problem in yaml file.

Chutki gravatar imageChutki ( 2015-06-22 05:55:06 -0600 )edit

answered 2015-05-12 08:33:49 -0600

helenp gravatar image

updated 2015-05-12 08:34:47 -0600

In my case there was a formatting error in the yaml hiera file for the node. I had an extra quote mark within a password. I found this by opening the file in sublime the text was highlighted in white.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-03-11 07:08:18 -0600

Seen: 9,796 times

Last updated: May 15 '15