Using facts that don't exist yet...

41 views
Skip to first unread message

Krist van Besien

unread,
Jan 31, 2014, 3:57:02 AM1/31/14
to puppet...@googlegroups.com

Hello,

I run puppet with foreman, and want to do the following:


- Initalize a network interface
- Start a service, bound to that interface.


eg:

#Start an interface for vlan 301 on interface em1
   network::if::dynamic { 'em1.301':
      ensure => up,
   }

#Start an openstack L2 agent

   class { 'neutron::agents::ovs':
    local_ip         => $::ipaddress_em1_301,
    enable_tunneling => true,
    after          => Network::If::Dynamic['em1.301']
  }



My problem is that the ::ipaddress_em1_301 fact doesn't exist yet the moment the catalog gets retreived. So it throws an error. Is there a way around this?

Krist



José Luis Ledesma

unread,
Jan 31, 2014, 4:27:05 AM1/31/14
to puppet...@googlegroups.com

I  don't know which is the best solution, what I do is:

if $::factX != undef {

....
}

Regards

--
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/3377a441-bfd3-4b29-b700-611ebdb57f76%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Daniele Sluijters

unread,
Jan 31, 2014, 5:27:49 AM1/31/14
to puppet...@googlegroups.com
Facts get sent at the start to the Puppet master so bringing an interface online during a Puppet run won't make it available as a Fact during that run, only on the next run as then the Facts are collected again. Your best bet is to make it conditional, check for the existence of the Fact and only if it is set do something.

Krist van Besien

unread,
Jan 31, 2014, 5:39:14 AM1/31/14
to puppet...@googlegroups.com


On Friday, January 31, 2014 11:27:49 AM UTC+1, Daniele Sluijters wrote:
Facts get sent at the start to the Puppet master so bringing an interface online during a Puppet run won't make it available as a Fact during that run, only on the next run as then the Facts are collected again. Your best bet is to make it conditional, check for the existence of the Fact and only if it is set do something.


That's indeed what I've ended up doing...

 
Reply all
Reply to author
Forward
0 new messages