Alternately, you can create a small definition for this requirement. I keep
this in manifests/utils.pp:

define regex_replace ( $match, $replace ) {
exec { "ruby -i -p -e 'gsub(%r{$match}, \"$replace\")' $name":
onlyif => "grep -E '$match' $name",
logoutput => on_failure,
}
}


You can use it from a manifest like this:

regex_replace { "/etc/hosts":
match  => "template-name-placeholder",
replace => $::hostname,
}

On Fri, Jul 24, 2015 at 4:14 AM, <puppet-users@googlegroups.com> wrote:

>     puppet-users@googlegroups.com
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/puppet-users/topics>
>   Google
> Groups
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email/#!overview>
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email/#!overview>
>   Today's topic summary
>  View all topics
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/puppet-users/topics>
>
>    -  Advice on Puppet update to 4 <#14ebfc57e8710cb2_group_thread_0> - 1
>    Update
>    -  Razor and Dashboard for Puppet 4 <#14ebfc57e8710cb2_group_thread_1>
>    - 2 Updates
>    -  Memory leak in Passenger ? <#14ebfc57e8710cb2_group_thread_2> - 1
>    Update
>    -  How to enable/create environments for new puppetserver setup (not
>    puppetmaster) <#14ebfc57e8710cb2_group_thread_3> - 2 Updates
>    -  Puppet4, Hiera3, and environments <#14ebfc57e8710cb2_group_thread_4>
>    - 6 Updates
>    -  puppetserver puppetdb and storeconfigs=true
>    <#14ebfc57e8710cb2_group_thread_5> - 4 Updates
>    -  How to search and replace a word in file
>    <#14ebfc57e8710cb2_group_thread_6> - 2 Updates
>
>   Advice on Puppet update to 4
> <http://groups.google.com/group/puppet-users/t/acfed71699c46f8d?utm_source=digest&utm_medium=email>
>   Felix Frank <felix.fr...@alumni.tu-berlin.de>: Jul 24 12:59PM +0200
>
> On 07/23/2015 12:45 AM, Stack Kororā wrote:
>
> > It also appears to me that puppet dashboard is not yet ready for 4.
> > Anyone have any thoughts on that?
>
> Hi,
>
> the dashboard was discontinued, ...more
> <http://groups.google.com/group/puppet-users/msg/a9eb3785f323fa40?utm_source=digest&utm_medium=email>
>   Back to top <#14ebfc57e8710cb2_digest_top>
>   Razor and Dashboard for Puppet 4
> <http://groups.google.com/group/puppet-users/t/44b2dccc018ed72d?utm_source=digest&utm_medium=email>
>   "Stack Kororā" <i.am.st...@gmail.com>: Jul 23 02:27PM -0700
>
> Greetings,
>
> I am building out a new puppet master system based on 4. Razor and
> Dashboard are two projects that I never got around to implementing before,
> but since I have some motivation (and ...more
> <http://groups.google.com/group/puppet-users/msg/db5fc2990fb2177c?utm_source=digest&utm_medium=email>
>   Stefan Heijmans <heijm...@gmail.com>: Jul 24 02:01AM -0700
>
> Hi,
> For Dashboard, Aaron Stone is doing it now @
> https://github.com/sodabrew/puppet-dashboard.
> Looking at this issue (
> https://github.com/sodabrew/puppet-dashboard/issues/320), seems that it
> ...more
> <http://groups.google.com/group/puppet-users/msg/6e17bc928f30e7d6?utm_source=digest&utm_medium=email>
>   Back to top <#14ebfc57e8710cb2_digest_top>
>   Memory leak in Passenger ?
> <http://groups.google.com/group/puppet-users/t/f9ba19054d83ce21?utm_source=digest&utm_medium=email>
>   "Michael Wörz" <michael.wo...@gmail.com>: Jul 24 12:56AM -0700
>
> Hello,
>
> in the past months we are observing raising memory usage on our puppet
> server and we have to restart it once a week when it starts swapping.
>
> Mainly there are 5 Passenger processes that ...more
> <http://groups.google.com/group/puppet-users/msg/9e24087cef013269?utm_source=digest&utm_medium=email>
>   Back to top <#14ebfc57e8710cb2_digest_top>
>   How to enable/create environments for new puppetserver setup (not
> puppetmaster)
> <http://groups.google.com/group/puppet-users/t/9f9f415508249eef?utm_source=digest&utm_medium=email>
>   Kevin Corcoran <kevin.corco...@puppetlabs.com>: Jul 23 09:50AM -0700
>
> Hi Gene,
>
> That looks like a problem with the permissions on that directory. I'd
> start by making sure that the 'puppet' user has read permissions on
> /etc/puppet/modules/production.
>
> - Kevin
> ...more
> <http://groups.google.com/group/puppet-users/msg/ba3580105f23e79f?utm_source=digest&utm_medium=email>
>   Gene Fontanilla <ginofontani...@gmail.com>: Jul 24 12:38AM -0700
>
> Hi kevin,
>
> I already tried changing the ownership to puppet:puppet, and even change
> file permission to 777 just to be sure, I still get the same error,
> I also noticed that all puppet files are ...more
> <http://groups.google.com/group/puppet-users/msg/c18454571552bb48?utm_source=digest&utm_medium=email>
>   Back to top <#14ebfc57e8710cb2_digest_top>
>   Puppet4, Hiera3, and environments
> <http://groups.google.com/group/puppet-users/t/b4b231c26af17121?utm_source=digest&utm_medium=email>
>   "Stack Kororā" <i.am.st...@gmail.com>: Jul 23 02:23PM -0700
>
> Greetings,
>
> I need help; I have been going in circles for too long now and I am sure
> it
> is something silly that I over looked. I am attempting to use environments
> with a new server build for ...more
> <http://groups.google.com/group/puppet-users/msg/b36ead8e95c4082?utm_source=digest&utm_medium=email>
>   Ellison Marks <gty...@gmail.com>: Jul 23 03:15PM -0700
>
> As far as I'm aware, in the default setup, there is no top level
> hieradata.
> as the comment says, the default datadir is
>
> /etc/puppetlabs/code/environments/%{environment}/hieradata
> ...more
> <http://groups.google.com/group/puppet-users/msg/c0e55e302e921ecb?utm_source=digest&utm_medium=email>
>   Ellison Marks <gty...@gmail.com>: Jul 23 03:19PM -0700
>
> Ah, sorry, forgot the .yaml part of the filenames. hieradata would
> actually
> look like this:
>
> ...more
> <http://groups.google.com/group/puppet-users/msg/1617953e685fee41?utm_source=digest&utm_medium=email>
>   ~Stack~ <i.am.st...@gmail.com>: Jul 23 05:21PM -0500
>
> Greetings,
>
> Thanks for the suggestions. I stepped out for a bit, but will try it as
> soon as I get back.
>
> On 07/23/2015 05:15 PM, Ellison Marks wrote:
> ...more
> <http://groups.google.com/group/puppet-users/msg/884c8cbdef6c9dfd?utm_source=digest&utm_medium=email>
>   Ellison Marks <gty...@gmail.com>: Jul 23 04:05PM -0700
>
> No, the environment variable is set in the puppet.conf of every host. I'm
> not even sure what the effect would be of trying to define environment in
> hiera.
>
> Please see: ...more
> <http://groups.google.com/group/puppet-users/msg/66974c714c4af18?utm_source=digest&utm_medium=email>
>   "Stack Kororā" <i.am.st...@gmail.com>: Jul 23 07:01PM -0700
>
> On Thursday, July 23, 2015 at 6:05:27 PM UTC-5, Ellison Marks wrote:
> > hiera.
>
> > Please see:
> >
> https://docs.puppetlabs.com/puppet/latest/reference/environments_assigning.html
> ...more
> <http://groups.google.com/group/puppet-users/msg/c602fcabfbf796fb?utm_source=digest&utm_medium=email>
>   Back to top <#14ebfc57e8710cb2_digest_top>
>   puppetserver puppetdb and storeconfigs=true
> <http://groups.google.com/group/puppet-users/t/8d179d99c74178ff?utm_source=digest&utm_medium=email>
>   Steph Gosling <st...@chuci.org>: Jul 23 05:25PM +0100
>
> Hi all,
>
> I'm attempting a migration from a PuppetDB 2.x and rack Puppet 3.8.1
> install over to the all new 'pc1' puppetserver puppet-agent PuppetDB v3
> stack[0].
>
> On the two nodes I've tried so ...more
> <http://groups.google.com/group/puppet-users/msg/681f71f77e40c584?utm_source=digest&utm_medium=email>
>   Ken Barber <k...@puppetlabs.com>: Jul 23 05:58PM +0100
>
>
> > I've completely purge all of the old Puppet installations and even
> > dropped the Postgres DB so I think my stack reall should work.
>
> > Does anyone have any pointers as to how I should debug ...more
> <http://groups.google.com/group/puppet-users/msg/35788cfe7e88bfd0?utm_source=digest&utm_medium=email>
>   Kevin Corcoran <kevin.corco...@puppetlabs.com>: Jul 23 10:06AM -0700
>
> Hi Steph,
>
> Just to be sure, you've ensured that the clock is correct on all of your
> nodes, right? I don't have a great understanding of this problem, but from
> what I know, the underlying issue is ...more
> <http://groups.google.com/group/puppet-users/msg/d31119857c6ffb0?utm_source=digest&utm_medium=email>
>   Steph Gosling <st...@chuci.org>: Jul 23 11:11PM +0100
>
> Ken, Kevin, good evening.
>
> On Thu, 23 Jul 2015 17:58:20 +0100
>
> > This can sometimes be caused by a timing issue, due to the cache
> > looking like its expired (even though it was just written) so ...more
> <http://groups.google.com/group/puppet-users/msg/af915468f878c3cf?utm_source=digest&utm_medium=email>
>   Back to top <#14ebfc57e8710cb2_digest_top>
>   How to search and replace a word in file
> <http://groups.google.com/group/puppet-users/t/22870c813536e5e5?utm_source=digest&utm_medium=email>
>   Christopher Wood <christopher_w...@pobox.com>: Jul 23 08:52AM -0400
>
> Look into templates.
>
> https://docs.puppetlabs.com/guides/templating.html
>
> https://docs.puppetlabs.com/puppet/latest/reference/lang_template.html
>
> On Thu, Jul 23, 2015 at 12:27:03AM -0700, ...more
> <http://groups.google.com/group/puppet-users/msg/26f06f6055381bad?utm_source=digest&utm_medium=email>
>   jcbollinger <john.bollin...@stjude.org>: Jul 23 06:43AM -0700
>
> On Thursday, July 23, 2015 at 2:27:03 AM UTC-5, Ayyanar wrote:
> > system.com "
>
> > I want to replace a word $$HISTORY$$ with puppet text into /etc/
> system.com
> > file.
>
> You have to take care ...more
> <http://groups.google.com/group/puppet-users/msg/40564b2925ef2fe8?utm_source=digest&utm_medium=email>
>   Back to top <#14ebfc57e8710cb2_digest_top>
>    You received this digest because you're subscribed to updates for this
> group. You can change your settings on the group membership page
> <https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/puppet-users/join>
> .
> To unsubscribe from this group and stop receiving emails from it send an
> email to puppet-users+unsubscr...@googlegroups.com.
>

-- 
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/CAH8X0%2BF%2Bk365rtfKT%2Bd7M%3D9FVf7BykF1%3DThdbudOj6R4oyF7Lg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to