Did you omit the "$" here for the $color hash or is it missing in the source ?
-- Lowe Schmidt | +46 723 867 157 On 1 February 2017 at 00:20, Joshua Schaeffer <jschaeffer0...@gmail.com> wrote: > I'm new to Puppet and learning the program and language so this question > might seem novice. I'm confused why I can assign an escape character to a > variable but not inside any collection types (arrays or hashes). I was > doing the simply motd puppet module and I created this: > > $red = "^[[0;31m" > $green = "^[[0;32m" > $white = "^[[0;33m" > $bold = "^[[1m" > $unbold = "^[[22m" > ... > > Those "^[" characters are actual escape characters (a.k.a. echo -e > \033[0;31m...). When I define my motd variable (which has the contents of > /etc/motd) I can do this: > > $motd = @("END") > You are connecting to: *$**{bold}*${facts[hostname]}.${facts[networking][ > 'domain']} > > > > *${unbold}......END* > > This works when I apply my manifest. Well, I thought having all those > variables is stupid so I wanted to put them in a hash and just reference > them by key: > > color = { > 'red' => "^[[0;31m", > 'green' => "^[[0;32m", > 'white' => "^[[0;33m", > 'bold' => "^[[1m", > 'unbold' => "^[[22m", > } > ... > $motd = @("END") > You are connecting to: *$**{color['bold']}*${facts[hostname]}.${facts[ > networking]['domain']}${color['unbold']} > > > *......END* > > However this produces an error > > $puppet apply --environment sandbox ./manifests/ > Error: Illegal attempt to assign to 'a Name'. Not an assignable reference > at /etc/puppetlabs/code/environments/sandbox/modules/motd/manifests/init. > pp:53:2 on node fenix.harmonywave.com > > I get the same issue if I try using an array as well. I'm fine using a > variable for each color, I'm just curious why they can't be assigned to > collection types. > > Thanks, > Joshua > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/puppet-users/12bb88f5-07be-4ae8-9bfb-c4b044d26dd5%40googlegroups.com > <https://groups.google.com/d/msgid/puppet-users/12bb88f5-07be-4ae8-9bfb-c4b044d26dd5%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAC-wWcQ_7%3DbWrhB%2BmwAXVOrGeDbjoT7N1YK5WKj3Uq0SRYp1hw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.