diff --git a/playbooks/ansible.cfg b/playbooks/ansible.cfg index f722999307..76a7bbae05 100644 --- a/playbooks/ansible.cfg +++ b/playbooks/ansible.cfg @@ -1,6 +1,7 @@ [defaults] # Additional plugins lookup_plugins = plugins/lookups +filter_plugins = plugins/filters gathering = smart hostfile = inventory diff --git a/playbooks/plugins/filters/osad-filters.py b/playbooks/plugins/filters/osad-filters.py new file mode 100644 index 0000000000..e532d14580 --- /dev/null +++ b/playbooks/plugins/filters/osad-filters.py @@ -0,0 +1,40 @@ +# Copyright 2015, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# (c) 2015, Kevin Carter + +"""Filter usage: + +Simple filters that may be useful from within the stack +""" + + +def bit_length_power_of_2(value): + """Return the smallest power of 2 greater than a numeric value. + + :param value: Number to find the smallest power of 2 + :type value: ``int`` + :returns: ``int`` + """ + return 2**(int(value)-1).bit_length() + + +class FilterModule(object): + """Ansible jinja2 filters.""" + + @staticmethod + def filters(): + return { + 'bit_length_power_of_2': bit_length_power_of_2 + } diff --git a/playbooks/roles/openstack_hosts/defaults/main.yml b/playbooks/roles/openstack_hosts/defaults/main.yml index 3528353252..59963c1d1b 100644 --- a/playbooks/roles/openstack_hosts/defaults/main.yml +++ b/playbooks/roles/openstack_hosts/defaults/main.yml @@ -74,6 +74,14 @@ openstack_host_apt_packages: - vlan - wget +# The following garbage collection values are set to better support lots of neutron networks/routers. +# Used for setting the net.ipv4/6.neigh.default.gc_thresh* values. This assumes that facts were +# gathered to obtain the total amount of memory available on a given host. If no facts are gathered +# the default set will be 1024 unless its defined by the user. +gc_val: "{{ ansible_memtotal_mb | default(1024) | bit_length_power_of_2 }}" +# The ste value has a Max allowable value of 8192 unless set by the user. +set_gc_val: "{{ gc_val if (gc_val | int <= 8192) else 8192 }}" + # System control kernel tuning openstack_kernel_options: - { key: 'fs.inotify.max_user_watches', value: 36864 } @@ -84,3 +92,15 @@ openstack_kernel_options: - { key: 'vm.dirty_background_ratio', value: 5 } - { key: 'vm.dirty_ratio', value: 10 } - { key: 'vm.swappiness', value: 5 } + - { key: 'net.ipv4.neigh.default.gc_thresh1', value: "{{ set_gc_val | int // 2 }}" } + - { key: 'net.ipv4.neigh.default.gc_thresh2', value: "{{ set_gc_val | int }}" } + - { key: 'net.ipv4.neigh.default.gc_thresh3', value: "{{ set_gc_val | int * 2 }}" } + - { key: 'net.ipv4.route.gc_thresh', value: "{{ set_gc_val | int * 2 }}" } + - { key: 'net.ipv4.neigh.default.gc_interval', value: 60 } + - { key: 'net.ipv4.neigh.default.gc_stale_time', value: 120 } + - { key: 'net.ipv6.neigh.default.gc_thresh1', value: "{{ set_gc_val | int // 2 }}" } + - { key: 'net.ipv6.neigh.default.gc_thresh2', value: "{{ set_gc_val | int }}" } + - { key: 'net.ipv6.neigh.default.gc_thresh3', value: "{{ set_gc_val | int * 2 }}" } + - { key: 'net.ipv6.route.gc_thresh', value: "{{ set_gc_val | int * 2 }}" } + - { key: 'net.ipv6.neigh.default.gc_interval', value: 60 } + - { key: 'net.ipv6.neigh.default.gc_stale_time', value: 120 }