Ask Your Question

Configuring hiera (yaml) data for Optional abstract data types - does not work if type is UPPERCASE

asked 2018-09-13 20:19:00 -0600

tdk gravatar image

updated 2018-09-14 08:49:55 -0600

DarylW gravatar image


Ok so not sure I understand the abstract data types and how to configure my yaml data. As an example Im borrowing the following code :

type Keepalived::Virtual_server::Real_server = Struct[{
  Optional[virtual_server] => String,
  Optional[weight] => Integer[1],
  Optional[lvs_method] => Keepalived::Virtual_server::Lvs_methods,
  Optional[inhibit_on_failure] => Boolean,
  Optional[notify_up] => String,
  Optional[notify_down] => String,
  Optional["HTTP_GET"] => Keepalived::Virtual_server::Real_server::Http_check,
  Optional["SSL_GET"] => Keepalived::Virtual_server::Real_server::Http_check,
  Optional["TCP_CHECK"] => Keepalived::Virtual_server::Real_server::Tcp_check,
  Optional["SMTP_CHECK"] => Keepalived::Virtual_server::Real_server::Smtp_check,
  Optional["DNS_CHECK"] => Keepalived::Virtual_server::Real_server::Dns_check,
  Optional["MISC_CHECK"] => Keepalived::Virtual_server::Real_server::Misc_check

type Keepalived::Virtual_server::Real_server::Tcp_check = Struct[{
  connect_ip => String,
  connect_port => Integer[1, 65535],
  Optional[bindto] => String,
  Optional[bind_port] => Integer[1, 65535],
  Optional[connect_timeout] => Integer[1],
  Optional[fwmark] => Integer,
  Optional[warmup] => Integer[1]

If I look at the docs for Optional in I see :

Optional[String]        : will match any String or undef
Optional["present"]  : will match exactly "present"

My questions : What does :

Optional[virtual_server] = String

really match? Seems to me only 'virtual_server'. Is that correct?

Next question: In the code above there is :

Optional["TCP_CHECK"] => Keepalived::Virtual_server::Real_server::Tcp_check

Which does not seem to do what the puppet docs state. If I define my data in yaml as :

  connect_ip: ''
  connect_port: 443

I get a failure that TCP_CHECK is not a valid parameter for the real_server struct. HOWEVER, if I modify the definition above to be lowercase and the yaml data to be lowercase then all works fine.

Did something change between hiera 3 to 5 or something w/ puppet 4 that affects Optional flexible data types? Im sure this used to work as written above as this code is from a module on puppet labs. For now, Ive written the author and modified the code to set "TCP_CHECK" to be tcp_check but Id rather not modify a downloaded module. (I had to modify another portion where that value is required to be uppercase)

Is Optional["TCP_CHECK"] still valid or is the fact that 1st letter is uppercase making puppet think its a defined type like String?

Any ideas, suggestions welcome.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-09-13 20:20:48 -0600

tdk gravatar image

wow... formatting gets all screwed up when you submit a question... apologies in advance

edit flag offensive delete link more


Cleaned up formatting for you a bit

DarylW gravatar imageDarylW ( 2018-09-14 08:50:09 -0600 )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


Asked: 2018-09-13 20:19:00 -0600

Seen: 111 times

Last updated: Sep 14