Ask Your Question
1

Hiera files, fqdn and windows nodes

asked 2013-10-02 10:11:54 -0500

vanyans gravatar image

Hello,

We are managing our systems using hiera files. Systems consists of both windows and linux machines.

We generate all the system configuration files (including hiera files) before even system is build and then use all that info to automate deployment of the system. Hiera files are named based on fqdn. E.g. node1.exaple.com.yaml In case of windows machines, hiera file names are generated with capital case for machine name: e.g. DC01.example.com , APP01.example.com And when system is built all windows machines indeed have their name in capital case. Except, for some reason ... (more)

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted
2

answered 2013-11-26 03:01:06 -0500

haf gravatar image

@Ancillas, sorry but your code gave me the creeps ;) what about this?

Facter.add("fqdn_lower") do
  setcode { (Facter.value('fqdn') || '').downcase }
end
edit flag offensive delete link more

Comments

A Ruby expert I am not :). This looks much better to me.

Ancillas gravatar imageAncillas ( 2013-11-28 04:33:17 -0500 )edit
1

answered 2013-12-03 10:44:56 -0500

vanyans gravatar image

Thanks for all the answers. I did a little bit of research and it seems that Windows host names are always upper case. So I fixed my generator tool (that generates hiera files) to generate hiera files for windows machines with uppercase. e.g. HOSTENAME.domain.com

I do like facter solution provided by Ancillas and haf

edit flag offensive delete link more
1

answered 2013-10-02 12:18:03 -0500

GregLarkin gravatar image

The hackish way to do what you want is to generate symlinks with all lowercase filenames linking to your original generated YAML files, e.g. dc01.example.com.yaml -> DC01.example.com.yaml.

I think the right way to do it would be to make sure that your YAML files are all generated with lowercase filenames. Then you would not have to worry about case-sensitivity when Hiera looks for its data. Would that work in your environment?

edit flag offensive delete link more

Comments

Thanks for the tip. Originally all the files were lowercase but this did not work with windows machines. If a windows machine name is uppercase, hiera file name also needs ...(more)

vanyans gravatar imagevanyans ( 2013-10-02 13:39:19 -0500 )edit

It sounds like the only option is to either make sure that the Windows machine names are lowercase (if possible) or set up those symlinks. Maybe the latter option wouldn ...(more)

GregLarkin gravatar imageGregLarkin ( 2013-10-02 13:54:08 -0500 )edit
0

answered 2013-10-06 02:58:40 -0500

Ancillas gravatar image

updated 2013-10-06 03:07:50 -0500

I like Greg's approach, but another way might be to write a custom fact called $fqdn_lower. The fact would simply read in $fqdn, and then return the lowercase value. You'd then use $fqdn_lower in hiera.yaml instead of $fqdn.

Update

I didn't test this (sorry), but here's my stab at a simple fact for this purpose.

Facter.add("fqdn_lower") do
    setcode do
    fqdn_lower = nil
    fqdn       = Facter.value('fqdn')
    unless fqdn.nil?
        fqdn_lower = fqdn.downcase
    end
    fqdn_lower
end
edit flag offensive delete link more

Comments

http://docs.puppetlabs.com/guides/custom_facts.html

haf gravatar imagehaf ( 2013-11-26 03:02:30 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-10-02 10:11:54 -0500

Seen: 1,351 times

Last updated: Dec 03 '13