{"action":"created","issue":{"url":"https://api.github.com/repos/TomPoulton/hiera-eyaml/issues/124","repository_url":"https://api.github.com/repos/TomPoulton/hiera-eyaml","labels_url":"https://api.github.com/repos/TomPoulton/hiera-eyaml/issues/124/labels{/name}","comments_url":"https://api.github.com/repos/TomPoulton/hiera-eyaml/issues/124/comments","events_url":"https://api.github.com/repos/TomPoulton/hiera-eyaml/issues/124/events","html_url":"https://github.com/TomPoulton/hiera-eyaml/issues/124","id":49443525,"number":124,"title":"invalid byte sequence in UTF-8 on encrypted binary","user":{"login":"djtecha","id":3084627,"avatar_url":"https://avatars.githubusercontent.com/u/3084627?v=3","gravatar_id":"","url":"https://api.github.com/users/djtecha","html_url":"https://github.com/djtecha","followers_url":"https://api.github.com/users/djtecha/followers","following_url":"https://api.github.com/users/djtecha/following{/other_user}","gists_url":"https://api.github.com/users/djtecha/gists{/gist_id}","starred_url":"https://api.github.com/users/djtecha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djtecha/subscriptions","organizations_url":"https://api.github.com/users/djtecha/orgs","repos_url":"https://api.github.com/users/djtecha/repos","events_url":"https://api.github.com/users/djtecha/events{/privacy}","received_events_url":"https://api.github.com/users/djtecha/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2014-11-19T19:42:26Z","updated_at":"2016-06-20T18:36:23Z","closed_at":null,"body":"After encrypting a binary file and placing the blob into the eyaml file using yum, all eyaml edits to the file fail with the following:\r\n\r\n[hiera-eyaml-core] !!! invalid byte sequence in UTF-8\r\n[hiera-eyaml-core] [\"/usr/local/rvm/gems/ruby-2.0.0-p247/gems/hiera-eyaml-2.0.3/lib/hiera/backend/eyaml/parser/parser.rb:45:in `match?'\", \"/usr/local/rvm/gems/ruby-2.0.0-p247/gems/hiera-eyaml-2.0.3/lib/hiera/backend/eyaml/parser/parser.rb:45:in `block in parse_scanner'\", \"/usr/local/rvm/gems/ruby-2.0.0-p247/gems/hiera-eyaml-2.0.3/lib/hiera/backend/eyaml/parser/parser.rb:44:in `each'\", \"/usr/local/rvm/gems/ruby-2.0.0-p247/gems/hiera-eyaml-2.0.3/lib/hiera/backend/eyaml/parser/parser.rb:44:in `find'\", \"/usr/local/rvm/gems/ruby-2.0.0-p247/gems/hiera-eyaml-2.0.3/lib/hiera/backend/eyaml/parser/parser.rb:44:in `parse_scanner'\", \"/usr/local/rvm/gems/ruby-2.0.0-p247/gems/hiera-eyaml-2.0.3/lib/hiera/backend/eyaml/parser/parser.rb:36:in `parse'\", \"/usr/local/rvm/gems/ruby-2.0.0-p247/gems/hiera-eyaml-2.0.3/lib/hiera/backend/eyaml/subcommands/edit.rb:57:in `execute'\", \"/usr/local/rvm/gems/ruby-2.0.0-p247/gems/hiera-eyaml-2.0.3/lib/hiera/backend/eyaml/CLI.rb:45:in `execute'\", \"/usr/local/rvm/gems/ruby-2.0.0-p247/gems/hiera-eyaml-2.0.3/bin/eyaml:13:in `<top (required)>'\", \"/usr/local/rvm/gems/ruby-2.0.0-p247/bin/eyaml:23:in `load'\", \"/usr/local/rvm/gems/ruby-2.0.0-p247/bin/eyaml:23:in `<main>'\", \"/usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'\", \"/usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'\"] "},"comment":{"url":"https://api.github.com/repos/TomPoulton/hiera-eyaml/issues/comments/227229967","html_url":"https://github.com/TomPoulton/hiera-eyaml/issues/124#issuecomment-227229967","issue_url":"https://api.github.com/repos/TomPoulton/hiera-eyaml/issues/124","id":227229967,"user":{"login":"sblatnick","id":2575534,"avatar_url":"https://avatars.githubusercontent.com/u/2575534?v=3","gravatar_id":"","url":"https://api.github.com/users/sblatnick","html_url":"https://github.com/sblatnick","followers_url":"https://api.github.com/users/sblatnick/followers","following_url":"https://api.github.com/users/sblatnick/following{/other_user}","gists_url":"https://api.github.com/users/sblatnick/gists{/gist_id}","starred_url":"https://api.github.com/users/sblatnick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sblatnick/subscriptions","organizations_url":"https://api.github.com/users/sblatnick/orgs","repos_url":"https://api.github.com/users/sblatnick/repos","events_url":"https://api.github.com/users/sblatnick/events{/privacy}","received_events_url":"https://api.github.com/users/sblatnick/received_events","type":"User","site_admin":false},"created_at":"2016-06-20T18:36:23Z","updated_at":"2016-06-20T18:36:23Z","body":"I found a work around that can be implemented two ways, for those that need a way around this:\r\nThe problem is with loading binary in hiera, so instead, let's convert the binary to text:\r\n1. base64 encode the binary manually:\r\n```\r\nbase64 /path/to/binary > file.txt\r\n```\r\n2. store the base64 text in your yaml and convert it to eyaml so it's encrypted\r\n3. load it in puppet from hiera:\r\n```\r\n$base64 = hiera('key::name::here')\r\nexec { 'create binary':\r\n    command => \"/usr/bin/base64 -d <<< \\\"${base64}\\\" > /path/to/binary\",\r\n}\r\n```\r\nAlternatively, if you want to control permissions and other things, you can use (untested):\r\n```\r\n  $base64 = hiera('key::name::here')\r\n  $binary = inline_template(\"<%= `/usr/bin/base64 -d <<< \\\"${base64}\\\"` %>\")\r\n  file { '/path/to/binary':\r\n    ensure  => 'present',\r\n    path    => '/path/to/binary',\r\n    owner   => 'root',\r\n    group   => 'root',\r\n    mode    => 0644,\r\n    content  => \"$binary\",\r\n    force => true,\r\n    replace => true,\r\n  }\r\n```"}}
{"actor":{"display_login":"sblatnick"}}