1 # == Class: neutron::agents::dhcp
3 # Setups Neutron DHCP agent.
8 # (optional) Ensure state for package. Defaults to 'present'.
11 # (optional) Enable state for service. Defaults to 'true'.
14 # (optional) Whether to start/stop the service
18 # (optional) Show debugging output in log. Defaults to false.
21 # (optional) Where to store dnsmasq state files. This directory must be
22 # writable by the user executing the agent. Defaults to '/var/lib/neutron'.
25 # (optional) The DHCP agent will resync its state with Neutron to recover
26 # from any transient notification or rpc errors. The interval is number of
27 # seconds between attempts. Defaults to 30.
29 # [*interface_driver*]
30 # (optional) Defaults to 'neutron.agent.linux.interface.OVSInterfaceDriver'.
33 # (optional) Defaults to 'neutron.agent.linux.dhcp.Dnsmasq'.
36 # (optional) Defaults to 'sudo neutron-rootwrap /etc/neutron/rootwrap.conf'.
37 # Addresses bug: https://bugs.launchpad.net/neutron/+bug/1182616
38 # Note: This can safely be removed once the module only targets the Havana release.
41 # (optional) Allow overlapping IP (Must have kernel build with
42 # CONFIG_NET_NS=y and iproute2 package that supports namespaces).
45 # [*dnsmasq_config_file*]
46 # (optional) Override the default dnsmasq settings with this file.
49 # [*dhcp_delete_namespaces*]
50 # (optional) Delete namespace after removing a dhcp server
53 # [*enable_isolated_metadata*]
54 # (optional) enable metadata support on isolated networks.
57 # [*enable_metadata_network*]
58 # (optional) Allows for serving metadata requests coming from a dedicated metadata
59 # access network whose cidr is 169.254.169.254/16 (or larger prefix), and is
60 # connected to a Neutron router from which the VMs send metadata request.
61 # This option requires enable_isolated_metadata = True
64 class neutron::agents::dhcp (
65 $package_ensure = present,
67 $manage_service = true,
69 $state_path = '/var/lib/neutron',
70 $resync_interval = 30,
71 $interface_driver = 'neutron.agent.linux.interface.OVSInterfaceDriver',
72 $dhcp_driver = 'neutron.agent.linux.dhcp.Dnsmasq',
73 $root_helper = 'sudo neutron-rootwrap /etc/neutron/rootwrap.conf',
74 $use_namespaces = true,
75 $dnsmasq_config_file = undef,
76 $dhcp_delete_namespaces = false,
77 $enable_isolated_metadata = false,
78 $enable_metadata_network = false
81 include neutron::params
83 Neutron_config<||> ~> Service['neutron-dhcp-service']
84 Neutron_dhcp_agent_config<||> ~> Service['neutron-dhcp-service']
88 Package[$::neutron::params::dnsmasq_packages] -> Package<| title == 'neutron-dhcp-agent' |>
89 ensure_packages($::neutron::params::dnsmasq_packages)
92 ensure_packages($::neutron::params::midonet_server_package)
95 fail("Unsupported dhcp_driver ${dhcp_driver}")
99 if (! $enable_isolated_metadata) and $enable_metadata_network {
100 fail('enable_metadata_network to true requires enable_isolated_metadata also enabled.')
102 neutron_dhcp_agent_config {
103 'DEFAULT/enable_isolated_metadata': value => $enable_isolated_metadata;
104 'DEFAULT/enable_metadata_network': value => $enable_metadata_network;
108 # The DHCP agent loads both neutron.ini and its own file.
109 # This only lists config specific to the agent. neutron.ini supplies
111 neutron_dhcp_agent_config {
112 'DEFAULT/debug': value => $debug;
113 'DEFAULT/state_path': value => $state_path;
114 'DEFAULT/resync_interval': value => $resync_interval;
115 'DEFAULT/interface_driver': value => $interface_driver;
116 'DEFAULT/dhcp_driver': value => $dhcp_driver;
117 'DEFAULT/use_namespaces': value => $use_namespaces;
118 'DEFAULT/root_helper': value => $root_helper;
119 'DEFAULT/dhcp_delete_namespaces': value => $dhcp_delete_namespaces;
122 if $dnsmasq_config_file {
123 neutron_dhcp_agent_config {
124 'DEFAULT/dnsmasq_config_file': value => $dnsmasq_config_file;
127 neutron_dhcp_agent_config {
128 'DEFAULT/dnsmasq_config_file': ensure => absent;
132 if $::neutron::params::dhcp_agent_package {
133 Package['neutron'] -> Package['neutron-dhcp-agent']
134 Package['neutron-dhcp-agent'] -> Neutron_config<||>
135 Package['neutron-dhcp-agent'] -> Neutron_dhcp_agent_config<||>
136 package { 'neutron-dhcp-agent':
137 ensure => $package_ensure,
138 name => $::neutron::params::dhcp_agent_package,
141 # Some platforms (RedHat) do not provide a neutron DHCP agent package.
142 # The neutron DHCP agent config file is provided by the neutron package.
143 Package['neutron'] -> Neutron_dhcp_agent_config<||>
148 $service_ensure = 'running'
150 $service_ensure = 'stopped'
154 service { 'neutron-dhcp-service':
155 ensure => $service_ensure,
156 name => $::neutron::params::dhcp_agent_service,
158 require => Class['neutron'],