Regex and Hyphen in node definitions

59 views
Skip to first unread message

Matt Shields

unread,
Nov 16, 2015, 4:44:57 PM11/16/15
to Puppet Users
I'm having an issue with trying to use regex with hostnames that have a hyphen in their name.  How can I get this to work?

node /^(.*)-(db00)(.*)$/ {
  include role::db
}

[root@ops-db001 ~]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid tag '-db00.' on node ops-db001.example.dom
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Henrik Lindberg

unread,
Nov 16, 2015, 10:50:00 PM11/16/15
to puppet...@googlegroups.com
Which version of Puppet are you using? This problem sounds familiar and
may have be fixed in a more recent version of Puppet.

- henrik

--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

Matt Shields

unread,
Nov 17, 2015, 8:38:33 AM11/17/15
to Puppet Users
I'm running Puppet 3.7.4-1

Matt Shields

unread,
Nov 17, 2015, 10:22:03 AM11/17/15
to Puppet Users
I just updated to 3.8.4-1 and I'm still seeing the same issue

Matt Shields

unread,
Nov 17, 2015, 10:57:46 AM11/17/15
to Puppet Users
If there are any other suggestions on how to regex the nodes, that would be extremely helpful.  We name our hosts like. 

{clientname}-{purpose}{001-999}
Ex.
ops-db001 -> uses db profile
ops-bidb001 -> uses bidb profile
ops-sdb001 -> uses sdb profile
ops-web001 -> uses web profile

client1-db001
client1-bidb001
client1-sdb001
client1-web001

Thanks
Matt

Peter Bukowinski

unread,
Nov 17, 2015, 11:01:47 AM11/17/15
to puppet...@googlegroups.com
Is consider removing the ^ and $ anchors. I think I you'll find it works without them.

-- Peter
--
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/e8a7c513-3026-4166-86f8-48658b135700%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

R.I.Pienaar

unread,
Nov 17, 2015, 11:05:02 AM11/17/15
to puppet-users


----- Original Message -----
> From: "Peter Bukowinski" <pmb...@gmail.com>
> To: "puppet-users" <puppet...@googlegroups.com>
> Sent: Tuesday, November 17, 2015 4:01:38 PM
> Subject: Re: [Puppet Users] Regex and Hyphen in node definitions

> Is consider removing the ^ and $ anchors. I think I you'll find it works without
> them.
>
> -- Peter
>
>> On Nov 17, 2015, at 9:57 AM, Matt Shields <ma...@mattshields.org> wrote:
>>
>> If there are any other suggestions on how to regex the nodes, that would be
>> extremely helpful. We name our hosts like.
>>
>> {clientname}-{purpose}{001-999}
>> Ex.
>> ops-db001 -> uses db profile
>> ops-bidb001 -> uses bidb profile
>> ops-sdb001 -> uses sdb profile
>> ops-web001 -> uses web profile
>>
>> client1-db001
>> client1-bidb001
>> client1-sdb001
>> client1-web001

anything without - really, so \W would work in this particular case /^(.*)\W(db00)(.*)$/

Matt Shields

unread,
Nov 17, 2015, 11:09:31 AM11/17/15
to Puppet Users
That didn't work.  Same error (Invalid tag)

Matt Shields

unread,
Nov 17, 2015, 11:33:06 AM11/17/15
to puppet...@googlegroups.com
Excellent.  That works.  Thank you very much

Matt

--
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.
Reply all
Reply to author
Forward
0 new messages