Multiple hosts with same name in masterless puppet and exported resources

asked 2016-12-22 10:05:02 -0600

davideagle gravatar image

I'm managing /etc/hosts in openstack projects using puppet in a masterless setup using exported resources as seen below, where I use tag = openstackprojectid where the ID is a unique id of an openstack project/tennant. But the problem is when I have hosts with the same name in two different projects I run into some kind of a race condition, where hosts start to disappear randomly from /etc/hosts, I'd think the tag would prevent this but I'm not too familiar with how stored configs work in PupptDB.

Any suggestions how I could fix this, since I do not have the luxury of ensuring unique hostnames

if $::openstackprojectid { resources { 'host': purge => true, }

@@host { "${::openstack_project_id}-${::fqdn}":
  name         => $::fqdn,
  ensure       => present,
  ip           => $::ipaddress,
  host_aliases => $::hostname,
  tag          => $::openstack_project_id,
}

Host <<| tag == $::openstack_project_id |>>

} else { warning('openstackprojectid fact must be set') }

edit retag flag offensive close merge delete

Comments

1

Why's there no DNS? You only fill /etc/hosts that far it is necessary. Since you're in a masterless setup, I'm afraid, there's no solution for your situation.

Kai Burghardt gravatar imageKai Burghardt ( 2016-12-22 18:10:16 -0600 )edit

Could there be a way to use mysql for storeconfigs and use separate dbs for each project? for example I have projectA and projectB where they would connect to the same db host but would use different dbs (puppetdba and puppetdbb) to store configs?

davideagle gravatar imagedavideagle ( 2017-01-04 08:30:00 -0600 )edit