From 4a9fee81e86c3af863d85118fde0378309c6e416 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Thu, 6 Aug 2015 14:00:50 +0200 Subject: [PATCH] Add neutron DHCP agent resource Signed-off-by: Bogdan Dobrelya --- example-puppet.py | 7 +++ .../neutron_agents_dhcp_puppet/README.md | 58 +++++++++++++++++++ .../actions/remove.pp | 16 +++++ .../neutron_agents_dhcp_puppet/actions/run.pp | 45 ++++++++++++++ .../neutron_agents_dhcp_puppet/meta.yaml | 57 ++++++++++++++++++ 5 files changed, 183 insertions(+) create mode 100644 resources/neutron_agents_dhcp_puppet/README.md create mode 100644 resources/neutron_agents_dhcp_puppet/actions/remove.pp create mode 100644 resources/neutron_agents_dhcp_puppet/actions/run.pp create mode 100644 resources/neutron_agents_dhcp_puppet/meta.yaml diff --git a/example-puppet.py b/example-puppet.py index 0c3c8db7..0ec4efa4 100644 --- a/example-puppet.py +++ b/example-puppet.py @@ -253,6 +253,13 @@ def setup_resources(): })[0] signals.connect(node1, neutron_agents_ovs) + # NEUTRON DHCP, L3, metadata agents + + neutron_agents_dhcp = vr.create('neutron_agents_dhcp', 'resources/neutron_agents_dhcp_puppet', { + 'use_namespaces': False, + })[0] + signals.connect(node1, neutron_agents_dhcp) + # NEUTRON FOR COMPUTE (node2) # Deploy chain neutron -> (plugins) -> ( agents ) neutron_puppet2 = vr.create('neutron_puppet2', 'resources/neutron_puppet', {})[0] diff --git a/resources/neutron_agents_dhcp_puppet/README.md b/resources/neutron_agents_dhcp_puppet/README.md new file mode 100644 index 00000000..f75b4ebf --- /dev/null +++ b/resources/neutron_agents_dhcp_puppet/README.md @@ -0,0 +1,58 @@ +# Neutron DHCP agent puppet resource + +Setups Neutron DHCP agent. + +# Parameters + +https://github.com/openstack/puppet-neutron/blob/5.1.0/manifests/agents/dhcp.pp + + + ``package_ensure`` + (optional) Ensure state for package. Defaults to 'present'. + + ``debug`` + (optional) Show debugging output in log. Defaults to false. + + ``state_path`` + (optional) Where to store dnsmasq state files. This directory must be + writable by the user executing the agent. Defaults to '/var/lib/neutron'. + + ``resync_interval`` + (optional) The DHCP agent will resync its state with Neutron to recover + from any transient notification or rpc errors. The interval is number of + seconds between attempts. Defaults to 30. + + ``interface_driver`` + (optional) Defaults to 'neutron.agent.linux.interface.OVSInterfaceDriver'. + + ``dhcp_driver`` + (optional) Defaults to 'neutron.agent.linux.dhcp.Dnsmasq'. + + ``root_helper`` + (optional) Defaults to 'sudo neutron-rootwrap /etc/neutron/rootwrap.conf'. + Addresses bug: https://bugs.launchpad.net/neutron/+bug/1182616 + Note: This can safely be removed once the module only targets the Havana release. + + ``use_namespaces`` + (optional) Allow overlapping IP (Must have kernel build with + CONFIG_NET_NS=y and iproute2 package that supports namespaces). + Defaults to true. + + ``dnsmasq_config_file`` + (optional) Override the default dnsmasq settings with this file. + Defaults to undef + + ``dhcp_delete_namespaces`` + (optional) Delete namespace after removing a dhcp server + Defaults to false. + + ``enable_isolated_metadata`` + (optional) enable metadata support on isolated networks. + Defaults to false. + + ``enable_metadata_network`` + (optional) Allows for serving metadata requests coming from a dedicated metadata + access network whose cidr is 169.254.169.254/16 (or larger prefix), and is + connected to a Neutron router from which the VMs send metadata request. + This option requires enable_isolated_metadata = True + Defaults to false. \ No newline at end of file diff --git a/resources/neutron_agents_dhcp_puppet/actions/remove.pp b/resources/neutron_agents_dhcp_puppet/actions/remove.pp new file mode 100644 index 00000000..72dc2b1a --- /dev/null +++ b/resources/neutron_agents_dhcp_puppet/actions/remove.pp @@ -0,0 +1,16 @@ +class { 'neutron::agents::dhcp': + package_ensure => 'absent', + enabled => false, +} + +include neutron::params + +package { 'neutron': + ensure => 'absent', + name => $::neutron::params::package_name, +} + +# Remove external class dependency +Service <| title == 'neutron-dhcp-service' |> { + require => undef +} \ No newline at end of file diff --git a/resources/neutron_agents_dhcp_puppet/actions/run.pp b/resources/neutron_agents_dhcp_puppet/actions/run.pp new file mode 100644 index 00000000..c0c9cae1 --- /dev/null +++ b/resources/neutron_agents_dhcp_puppet/actions/run.pp @@ -0,0 +1,45 @@ +$resource = hiera($::resource_name) + +$ip = $resource['input']['ip']['value'] + +$package_ensure = $resource['input']['package_ensure']['value'] +$debug = $resource['input']['debug']['value'] +$state_path = $resource['input']['state_path']['value'] +$resync_interval = $resource['input']['resync_interval']['value'] +$interface_driver = $resource['input']['interface_driver']['value'] +$dhcp_driver = $resource['input']['dhcp_driver']['value'] +$root_helper = $resource['input']['root_helper']['value'] +$use_namespaces = $resource['input']['use_namespaces']['value'] +$dnsmasq_config_file = $resource['input']['dnsmasq_config_file']['value'] +$dhcp_delete_namespaces = $resource['input']['dhcp_delete_namespaces']['value'] +$enable_isolated_metadata = $resource['input']['enable_isolated_metadata']['value'] +$enable_metadata_network = $resource['input']['enable_metadata_network']['value'] + +class { 'neutron::agents::dhcp': + enabled => true, + manage_service => true, + package_ensure => $package_ensure, + debug => $debug, + state_path => $state_path, + resync_interval => $resync_interval, + interface_driver => $interface_driver, + dhcp_driver => $dhcp_driver, + root_helper => $root_helper, + use_namespaces => $use_namespaces, + dnsmasq_config_file => $dnsmasq_config_file, + dhcp_delete_namespaces => $dhcp_delete_namespaces, + enable_isolated_metadata => $enable_isolated_metadata, + enable_metadata_network => $enable_metadata_network, +} + +include neutron::params + +package { 'neutron': + ensure => $package_ensure, + name => $::neutron::params::package_name, +} + +# Remove external class dependency +Service <| title == 'neutron-dhcp-service' |> { + require => undef +} \ No newline at end of file diff --git a/resources/neutron_agents_dhcp_puppet/meta.yaml b/resources/neutron_agents_dhcp_puppet/meta.yaml new file mode 100644 index 00000000..9893e2e7 --- /dev/null +++ b/resources/neutron_agents_dhcp_puppet/meta.yaml @@ -0,0 +1,57 @@ +handler: puppet +id: 'neutron_agents_dhcp_puppet' +input: + ip: + schema: str! + value: + ssh_key: + schema: str! + value: + ssh_user: + schema: str! + value: + + package_ensure: + schema: str + value: present + debug: + schema: bool + value: false + state_path: + schema: str + value: '/var/lib/neutron' + resync_interval: + schema: int + value: 30 + interface_driver: + schema: str + value: 'neutron.agent.linux.interface.OVSInterfaceDriver' + dhcp_driver: + schema: str + value: 'neutron.agent.linux.dhcp.Dnsmasq' + root_helper: + schema: str + value: 'sudo neutron-rootwrap /etc/neutron/rootwrap.conf' + use_namespaces: + schema: bool + value: true + dnsmasq_config_file: + schema: str + value: + dhcp_delete_namespaces: + schema: bool + value: false + enable_isolated_metadata: + schema: bool + value: false + enable_metadata_network: + schema: bool + value: false + + git: + schema: {repository: str!, branch: str!} + value: {repository: 'https://github.com/openstack/puppet-neutron', branch: '5.1.0'} + +puppet_module: 'neutron' +tags: [resource/neutron, resource/neutron_agents_dhcp] +version: 1.0.0