Setting dnsmasq_config_file with Puppet managed OpenStack installation

asked 2016-05-03 06:19:33 -0600

steima gravatar image

Our OpenStack installation is rolled out with Puppet. We use the excellent puppetlabs-openstack module for that. Due to the slow turnover cycles we are still stuck with version 5.0.2, right now we cannot afford to migrate to a newer version. So this question is related to OpenStack 2014.2.2.

Our current network setup (GRE-tunneled) forces us to announce MTU of 1454 via DHCP to the guest VMs on our compute nodes. We are well aware that we can do that by providing the relevant configuration in /etc/neutron/dnsmasq-neutron.conf and specifying this in /etc/neutron/dhcp_agent.ini. The problem now is that we lack the proper Puppet knowledge to configure these parameters the "Puppet-way".

The current configuration looks like this:

(1) We use a file resource to create the dnsmasq-neutron.conf file in the appropriate location on our single network node. This obviously works very well and I believe we can keep it that way.

    file { 'dnsmasq-neutron.conf':
            name => '/etc/neutron/dnsmasq-neutron.conf',
            mode => '0644',
            owner => 'root',
            group => 'neutron',
            content => template('/etc/puppet/manifests/neutron/dnsmasq-neutron.erb')
    }

(2) Currently we use the following really bad way of injecting the config line into the dhcp_agent.ini file.

    exec { 'dnsmasq_config-file':
            command => '/usr/bin/echo "dnsmasq_config_file=/etc/neutron/dnsmasq-neutron.conf" >> /etc/neutron/dhcp_agent.ini && /usr/sbin/service neutron-dhcp-agent restart',
            user => 'root',
    }

Our first guess was to use Augeas which did not work as intended. And we do know that there must be a way to just set the dnsmasq_config_file property in a clean Puppet managed way. There is in fact a parameter for class neutron::agents::dhcp called dnsmasq_config_file which defaults to undefined.

The question is: How does one properly set this parameter? Our current node config for the network node can be found below.

node 'network.lan' inherits basenode {
    class { '::openstack::role::network' :
        #dnsmasq_config_file => '/etc/neutron/dnsmasq-neutron.conf'
    }

    file { 'dnsmasq-neutron.conf':
        name => '/etc/neutron/dnsmasq-neutron.conf',
        mode => '0644',
        owner => 'root',
        group => 'neutron',
        content => template('/etc/puppet/manifests/neutron/dnsmasq-neutron.erb')
    }

    exec { 'dnsmasq_config-file':
        command => '/usr/bin/echo "dnsmasq_config_file=/etc/neutron/dnsmasq-neutron.conf" >> /etc/neutron/dhcp_agent.ini && /usr/sbin/service neutron-dhcp-agent restart',
        user => 'root',
    } 
}

The solution provided above works. However DHCP agents / dnsmasq restart twice with every Puppet run. Some additional resources such as our firewall settings were stripped from the above code because they would only clutter the example.

Disclaimer: this is a duplicate of a question already asked at ServerFault. I encourage to also answer there to get some extra reputation ;)

edit retag flag offensive close merge delete