Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Exported resources where two hosts have the same name in masterless puppet

I'm managing /etc/hosts in openstack projects using puppet in a masterless setup using exported resources as seen below, where I use tag = openstack_project_id 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 $::openstack_project_id { 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('openstack_project_id fact must be set') }