Changing namevar of resources triggering alias error

17 views
Skip to first unread message

Luke Bigum

unread,
Jul 29, 2016, 11:53:38 AM7/29/16
to puppet-users
Can someone explain this to me? I thought I'd be able to change the title of a nagios_host resource but leave name_var the same to effectively write two nagios_host files to disk with the same content, but instead I'm triggering an error in the resouce alias code. I didn't realise changing namevar was using resource aliases under the hood?

Any ideas on how I could make this work?


[root@localhost ~]# cat test.pp
nagios_host { 'foo':
ensure => present,
host_name => 'foo',
address => 'foo',
target => '/tmp/foo',
}

nagios_host { 'foo_again':
ensure => present,
host_name => 'foo',
address => 'foo',
target => '/tmp/foo_again',
}
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# puppet apply test.pp
Notice: Compiled catalog for localhost in environment production in 0.10 seconds
Error: Cannot alias Nagios_host[foo_again] to ["foo"] at /root/test.pp:13; resource ["Nagios_host", "foo"] already declared at /root/test.pp:6



--
Luke Bigum
Senior Systems Engineer

Information Systems
---

LMAX Exchange, Yellow Building, 1A Nicholas Road, London W11 4AN
http://www.LMAX.com/

Recognised by the most prestigious business and technology awards

2016 Best Trading & Execution, HFM US Technology Awards
2016, 2015, 2014, 2013 Best FX Trading Venue - ECN/MTF, WSL Institutional Trading Awards

2015 Winner, Deloitte UK Technology Fast 50
2015, 2014, 2013, One of the UK's fastest growing technology firms, The Sunday Times Tech Track 100
2015 Winner, Deloitte EMEA Technology Fast 500
2015, 2014, 2013 Best Margin Sector Platform, Profit & Loss Readers' Choice Awards

---

FX and CFDs are leveraged products that can result in losses exceeding your deposit. They are not suitable for everyone so please ensure you fully understand the risks involved.

This message and its attachments are confidential, may not be disclosed or used by any person other than the addressee and are intended only for the named recipient(s). This message is not intended for any recipient(s) who based on their nationality, place of business, domicile or for any other reason, is/are subject to local laws or regulations which prohibit the provision of such products and services. This message is subject to the following terms (http://lmax.com/pdf/general-disclaimers.pdf), if you cannot access these, please notify us by replying to this email and we will send you the terms. If you are not the intended recipient, please notify the sender immediately and delete any copies of this message.

LMAX Exchange is the trading name of LMAX Limited. LMAX Limited operates a multilateral trading facility. LMAX Limited is authorised and regulated by the Financial Conduct Authority (firm registration number 509778) and is a company registered in England and Wales (number 6505809).

LMAX Hong Kong Limited is a wholly-owned subsidiary of LMAX Limited. LMAX Hong Kong is licensed by the Securities and Futures Commission in Hong Kong to conduct Type 3 (leveraged foreign exchange trading) regulated activity with CE Number BDV088.

Craig Dunn

unread,
Aug 2, 2016, 4:21:03 AM8/2/16
to puppet...@googlegroups.com
On Fri, Jul 29, 2016 at 5:53 PM, Luke Bigum <luke....@lmax.com> wrote:
Can someone explain this to me? I thought I'd be able to change the title of a nagios_host resource but leave name_var the same to effectively write two nagios_host files to disk with the same content, but instead I'm triggering an error in the resouce alias code. I didn't realise changing namevar was using resource aliases under the hood?


Short answer here is, you can't - at least without modifying the nagios_host type.   Puppet defines uniqueness by the value of the namevar, in the absence of the namevar being defined, it's value is set from the resource title.   Therefore you can never have two resources with the same namevar.

The theoretical solution to your issue would be to make a composite namevar combining both the target and the host_name - I did an extensive write up of all this recently; 


One slightly hackish approach would be to write your own custom_nagios_host type using composite namevars and write a small provider that doesn't do much else than inherit off the nagios_host default provider.


--
Luke Bigum
Senior Systems Engineer


[ massive snip ]

Polite request; Whilst we are all delighted in the number of awards your employer has received,  if you must have a 58 line signature on emails sent to public forums, could you please format it correctly with "-- " (dash dash space) so compliant mail programs can handle it properly.   Thanks ;)


Reply all
Reply to author
Forward
0 new messages