how to export path in bashrc via puppet script

1,016 views
Skip to first unread message

ayy...@orzota.com

unread,
Jul 16, 2015, 12:58:53 PM7/16/15
to puppet...@googlegroups.com
 exec { file1:
                  command => "/bin/echo "export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk.x86_64"; >> /home/haas/.bashrc",
        }
}


i try to added java path. facing issue.

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at 'export'; expected '}' at /etc/puppet/modules/a/manifests/init.pp:3 on node ip-10-61-204-93.ec2.internal
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Thanks for your commands.

Thanks,
Ayyanar

Vince Skahan

unread,
Jul 16, 2015, 2:25:07 PM7/16/15
to puppet...@googlegroups.com

On Thursday, July 16, 2015 at 9:58:53 AM UTC-7, ayy...@orzota.com wrote:
 exec { file1:
                  command => "/bin/echo "export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk.x86_64"; >> /home/haas/.bashrc",
        }
}

 
try single quoting the inner or outer pair of quotes ?

ayy...@orzota.com

unread,
Jul 16, 2015, 2:26:34 PM7/16/15
to puppet...@googlegroups.com


Thanks I will try.

Felix Frank

unread,
Jul 17, 2015, 4:13:25 PM7/17/15
to puppet...@googlegroups.com
Hi,

this whole approach is hardly ideal. Try and take a look at the
file_line type in the stdlib module. It will likely do exactly what you
need.

https://github.com/puppetlabs/puppetlabs-stdlib#file_line

As soon as you install the stdlib module, the type becomes available to
your manifests.

HTH,
Felix

Omen Wild

unread,
Jul 18, 2015, 1:39:30 PM7/18/15
to puppet...@googlegroups.com
Quoting Felix Frank <Felix...@Alumni.TU-Berlin.de> on Fri, Jul 17 22:13:
>
> https://github.com/puppetlabs/puppetlabs-stdlib#file_line
>
> As soon as you install the stdlib module, the type becomes available to
> your manifests.

I have had great luck with the file_line, expecially when used with the
'match =>' parameter which keeps there from being multiple lines if you
update the contents of 'line =>' at some point.

file_line { 'sbin_for_root':
path => '/root/.profile',
line => 'export PATH="$PATH:/usr/local/sbin",
match => '^export PATH=',
}

--
Omen Wild
Systems Administrator
Metro Cluster
Reply all
Reply to author
Forward
0 new messages