Discussion:
[Puppet Users] How can we add multiple lines to a file ?
Vikas Kumar
2014-08-12 06:57:14 UTC
Permalink
Hello,

I am looking for an option to add multiple lines to a */etc/bashrc* and
*/etc/profile*. I can do this with *file_line*, but is there any other
alternative. *file_line* does the job but for each line I will have to
create a *file_line* resource, which does not sound good for multiple lines.

Regards,
Vikas
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/e56de655-943c-46d3-95db-3365ea4d34ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sijis Aviles
2014-08-12 16:49:47 UTC
Permalink
Post by Vikas Kumar
Hello,
I am looking for an option to add multiple lines to a */etc/bashrc* and
*/etc/profile*. I can do this with *file_line*, but is there any other
alternative. *file_line* does the job but for each line I will have to
create a *file_line* resource, which does not sound good for multiple lines.
Regards,
Vikas
Vikas,

Maybe try using concat module
(https://github.com/puppetlabs/puppetlabs-concat)? But i think you'll still
have multiple concat::fragment entries.

Sijis
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/72ec07d4-2f78-4889-94d4-938d331d324c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Lakshmi Thampi
2015-01-27 06:40:49 UTC
Permalink
Could you please tell me which of the solutions worked in this case
As i am also trying to do the same
I am trying to do it with concat like this for /etc/profile file editing

class postgresql::profilechange{

include concat::setup

concat { '/etc/profile':

mode => '0775',

owner => 'root',

group => 'root',

ensure => present,


}


concat::fragment { 'file04_fa':

target => '/etc/profile',

content => "PATH=$PATH:/usr/local/pgsql/bin\n",

order => 01

}


}
But it is giving me this error
---------------------------------------------------

Info: Retrieving plugin

Info: Loading facts in
/etc/puppet/modules/stdlib/lib/facter/puppet_vardir.rb

Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/facter_dot_d.rb

Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/root_home.rb

Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/pe_version.rb

Info: Loading facts in
/etc/puppet/modules/concat/lib/facter/concat_basedir.rb

Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
Could not find class concat::setup for sys-server on node sys-server

Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Any pointers are appreciated
Post by Sijis Aviles
Post by Vikas Kumar
Hello,
I am looking for an option to add multiple lines to a */etc/bashrc* and
*/etc/profile*. I can do this with *file_line*, but is there any other
alternative. *file_line* does the job but for each line I will have to
create a *file_line* resource, which does not sound good for multiple lines.
Regards,
Vikas
Vikas,
Maybe try using concat module (
https://github.com/puppetlabs/puppetlabs-concat)? But i think you'll
still have multiple concat::fragment entries.
Sijis
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/f950c7b9-e200-43b6-ba04-6784b21316d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Vikas Kumar
2015-01-28 15:16:36 UTC
Permalink
Hi Laxmi,

I could not find a way out to add multiple lines. I did this, which served
my purpose. May be it is not suitable for your requirement.

file { "/etc/mytweaks":
owner => 'root',
group => 'root',
mode => '0755',
source => "puppet:///modules/tweaks-history_shellprompt/mytweaks",
}

file_line { 'Adding-To-Bashrc':
ensure => present,
line => 'source /etc/mytweaks',
path => "$bashrc_location",
}

Regards,
Vikas
Post by Lakshmi Thampi
Could you please tell me which of the solutions worked in this case
As i am also trying to do the same
I am trying to do it with concat like this for /etc/profile file editing
class postgresql::profilechange{
include concat::setup
mode => '0775',
owner => 'root',
group => 'root',
ensure => present,
}
target => '/etc/profile',
content => "PATH=$PATH:/usr/local/pgsql/bin\n",
order => 01
}
}
But it is giving me this error
---------------------------------------------------
Info: Retrieving plugin
Info: Loading facts in
/etc/puppet/modules/stdlib/lib/facter/puppet_vardir.rb
Info: Loading facts in
/etc/puppet/modules/stdlib/lib/facter/facter_dot_d.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/root_home.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/pe_version.rb
Info: Loading facts in
/etc/puppet/modules/concat/lib/facter/concat_basedir.rb
Could not find class concat::setup for sys-server on node sys-server
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Any pointers are appreciated
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/0012a833-5caf-485c-8304-0175d4099a9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
jcbollinger
2015-01-28 14:55:00 UTC
Permalink
Post by Vikas Kumar
Hello,
I am looking for an option to add multiple lines to a */etc/bashrc* and
*/etc/profile*. I can do this with *file_line*, but is there any other
alternative. *file_line* does the job but for each line I will have to
create a *file_line* resource, which does not sound good for multiple lines.
If all the lines you want to add are available from one source, then you
could join them with semicolons and add them as one line.

Alternatively, some Linux distributions (RedHat-family distros for sure)
ship with a built-in mechanism for this. On CentOS, for example, both
/etc/profile and /etc/bashrc process shell code from each and every file in
/etc/profile.d/*.sh. On such systems, you can inject your own code into
the shell configuration by dropping a world-readable file of whatever
length you want into /etc/profile.d. This is incredibly useful.

If your systems are not built that way by default then you can use a
File_line to insert a (complex) one-liner into /etc/profile and /etc/bashrc
to enable such a feature, and then proceed as above.


John
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/33a0b177-00b0-4df7-acc2-44eeea62602f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...