Merge pull request #57 from salt-formulas/pr_hostname
dont touch hostname if not needed
diff --git a/.gitignore b/.gitignore
index bacd7c7..aa8e42a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+.kitchen
tests/build/
*.swp
*.pyc
diff --git a/Makefile b/Makefile
index fc83783..1043fbe 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,38 @@
DESTDIR=/
SALTENVDIR=/usr/share/salt-formulas/env
RECLASSDIR=/usr/share/salt-formulas/reclass
-FORMULANAME=$(shell grep name: metadata.yml|head -1|cut -d : -f 2|grep -Eo '[a-z0-9\-]*')
+FORMULANAME=$(shell grep name: metadata.yml|head -1|cut -d : -f 2|grep -Eo '[a-z0-9\-\_]*')
+VERSION=$(shell grep version: metadata.yml|head -1|cut -d : -f 2|grep -Eo '[a-z0-9\.\-\_]*')
+VERSION_MAJOR := $(shell echo $(VERSION)|cut -d . -f 1-2)
+VERSION_MINOR := $(shell echo $(VERSION)|cut -d . -f 3)
+
+NEW_MAJOR_VERSION ?= $(shell date +%Y.%m|sed 's,\.0,\.,g')
+NEW_MINOR_VERSION ?= $(shell /bin/bash -c 'echo $$[ $(VERSION_MINOR) + 1 ]')
+
+MAKE_PID := $(shell echo $$PPID)
+JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(shell ps T | grep "^\s*$(MAKE_PID).*$(MAKE)")))
+
+ifneq ($(subst -j,,$(JOB_FLAG)),)
+JOBS := $(subst -j,,$(JOB_FLAG))
+else
+JOBS := 1
+endif
+
+KITCHEN_LOCAL_YAML?=.kitchen.yml
+KITCHEN_OPTS?="--concurrency=$(JOBS)"
+KITCHEN_OPTS_CREATE?=""
+KITCHEN_OPTS_CONVERGE?=""
+KITCHEN_OPTS_VERIFY?=""
+KITCHEN_OPTS_TEST?=""
all:
@echo "make install - Install into DESTDIR"
@echo "make test - Run tests"
+ @echo "make kitchen - Run Kitchen CI tests (create, converge, verify)"
@echo "make clean - Cleanup after tests run"
+ @echo "make release-major - Generate new major release"
+ @echo "make release-minor - Generate new minor release"
+ @echo "make changelog - Show changes since last release"
install:
# Formula
@@ -14,6 +40,7 @@
cp -a $(FORMULANAME) $(DESTDIR)/$(SALTENVDIR)/
[ ! -d _modules ] || cp -a _modules $(DESTDIR)/$(SALTENVDIR)/
[ ! -d _states ] || cp -a _states $(DESTDIR)/$(SALTENVDIR)/ || true
+ [ ! -d _grains ] || cp -a _grains $(DESTDIR)/$(SALTENVDIR)/ || true
# Metadata
[ -d $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) ] || mkdir -p $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
cp -a metadata/service/* $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
@@ -21,6 +48,71 @@
test:
[ ! -d tests ] || (cd tests; ./run_tests.sh)
+release-major: check-changes
+ @echo "Current version is $(VERSION), new version is $(NEW_MAJOR_VERSION)"
+ @[ $(VERSION_MAJOR) != $(NEW_MAJOR_VERSION) ] || (echo "Major version $(NEW_MAJOR_VERSION) already released, nothing to do. Do you want release-minor?" && exit 1)
+ echo "$(NEW_MAJOR_VERSION)" > VERSION
+ sed -i 's,version: .*,version: "$(NEW_MAJOR_VERSION)",g' metadata.yml
+ [ ! -f debian/changelog ] || dch -v $(NEW_MAJOR_VERSION) -m --force-distribution -D `dpkg-parsechangelog -S Distribution` "New version"
+ make genchangelog-$(NEW_MAJOR_VERSION)
+ (git add -u; git commit -m "Version $(NEW_MAJOR_VERSION)")
+ git tag -s -m $(NEW_MAJOR_VERSION) $(NEW_MAJOR_VERSION)
+
+release-minor: check-changes
+ @echo "Current version is $(VERSION), new version is $(VERSION_MAJOR).$(NEW_MINOR_VERSION)"
+ echo "$(VERSION_MAJOR).$(NEW_MINOR_VERSION)" > VERSION
+ sed -i 's,version: .*,version: "$(VERSION_MAJOR).$(NEW_MINOR_VERSION)",g' metadata.yml
+ [ ! -f debian/changelog ] || dch -v $(VERSION_MAJOR).$(NEW_MINOR_VERSION) -m --force-distribution -D `dpkg-parsechangelog -S Distribution` "New version"
+ make genchangelog-$(VERSION_MAJOR).$(NEW_MINOR_VERSION)
+ (git add -u; git commit -m "Version $(VERSION_MAJOR).$(NEW_MINOR_VERSION)")
+ git tag -s -m $(NEW_MAJOR_VERSION) $(VERSION_MAJOR).$(NEW_MINOR_VERSION)
+
+check-changes:
+ @git log --pretty=oneline --decorate $(VERSION)..HEAD | grep -Eqc '.*' || (echo "No new changes since version $(VERSION)"; exit 1)
+
+changelog:
+ git log --pretty=short --invert-grep --grep="Merge pull request" --decorate $(VERSION)..HEAD
+
+genchangelog: genchangelog-$(VERSION_MAJOR).$(NEW_MINOR_VERSION)
+
+genchangelog-%:
+ $(eval NEW_VERSION := $(patsubst genchangelog-%,%,$@))
+ (echo "=========\nChangelog\n=========\n"; \
+ (echo $(NEW_VERSION);git tag) | sort -r | grep -E '^[0-9\.]+' | while read i; do \
+ cur=$$i; \
+ test $$i = $(NEW_VERSION) && i=HEAD; \
+ prev=`(echo $(NEW_VERSION);git tag)|sort|grep -E '^[0-9\.]+'|grep -B1 "$$cur\$$"|head -1`; \
+ echo "Version $$cur\n=============================\n"; \
+ git log --pretty=short --invert-grep --grep="Merge pull request" --decorate $$prev..$$i; \
+ echo; \
+ done) > CHANGELOG.rst
+
+kitchen-check:
+ @[ -e $(KITCHEN_LOCAL_YAML) ] || (echo "Kitchen tests not available, there's no $(KITCHEN_LOCAL_YAML)." && exit 1)
+
+kitchen: kitchen-check kitchen-create kitchen-converge kitchen-verify kitchen-list
+
+kitchen-create: kitchen-check
+ kitchen create ${KITCHEN_OPTS} ${KITCHEN_OPTS_CREATE}
+ [ "$(shell echo $(KITCHEN_LOCAL_YAML)|grep -Eo docker)" = "docker" ] || sleep 120
+
+kitchen-converge: kitchen-check
+ kitchen converge ${KITCHEN_OPTS} ${KITCHEN_OPTS_CONVERGE} &&\
+ kitchen converge ${KITCHEN_OPTS} ${KITCHEN_OPTS_CONVERGE}
+
+kitchen-verify: kitchen-check
+ [ ! -d tests/integration ] || kitchen verify -t tests/integration ${KITCHEN_OPTS} ${KITCHEN_OPTS_VERIFY}
+ [ -d tests/integration ] || kitchen verify ${KITCHEN_OPTS} ${KITCHEN_OPTS_VERIFY}
+
+kitchen-test: kitchen-check
+ [ ! -d tests/integration ] || kitchen test -t tests/integration ${KITCHEN_OPTS} ${KITCHEN_OPTS_TEST}
+ [ -d tests/integration ] || kitchen test ${KITCHEN_OPTS} ${KITCHEN_OPTS_TEST}
+
+kitchen-list: kitchen-check
+ kitchen list
+
clean:
+ [ ! -x "$(shell which kitchen)" ] || kitchen destroy
+ [ ! -d .kitchen ] || rm -rf .kitchen
[ ! -d tests/build ] || rm -rf tests/build
[ ! -d build ] || rm -rf build
diff --git a/README.rst b/README.rst
index bf966e4..28619e0 100644
--- a/README.rst
+++ b/README.rst
@@ -217,6 +217,49 @@
cpu:
governor: performance
+Huge Pages
+~~~~~~~~~~~~
+
+Huge Pages give a performance boost to applications that intensively deal
+with memory allocation/deallocation by decreasing memory fragmentation.
+
+.. code-block:: yaml
+
+ linux:
+ system:
+ kernel:
+ hugepages:
+ small:
+ size: 2M
+ count: 107520
+ mount_point: /mnt/hugepages_2MB
+ mount: false/true # default false
+ large:
+ default: true # default automatically mounted
+ size: 1G
+ count: 210
+ mount_point: /mnt/hugepages_1GB
+
+Note: not recommended to use both pagesizes in concurrently.
+
+Intel SR-IOV
+~~~~~~~~~~~~
+
+PCI-SIG Single Root I/O Virtualization and Sharing (SR-IOV) specification defines a standardized mechanism to virtualize PCIe devices. The mechanism can virtualize a single PCIe Ethernet controller to appear as multiple PCIe devices.
+
+.. code-block:: yaml
+
+ linux:
+ system:
+ kernel:
+ sriov: True
+ unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
+ rc:
+ local: |
+ #!/bin/sh -e
+ # Enable 7 VF on eth1
+ echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
+ exit 0
Repositories
@@ -774,3 +817,36 @@
* https://www.archlinux.org/
* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu
+
+Documentation and Bugs
+======================
+
+To learn how to install and update salt-formulas, consult the documentation
+available online at:
+
+ http://salt-formulas.readthedocs.io/
+
+In the unfortunate event that bugs are discovered, they should be reported to
+the appropriate issue tracker. Use Github issue tracker for specific salt
+formula:
+
+ https://github.com/salt-formulas/salt-formula-linux/issues
+
+For feature requests, bug reports or blueprints affecting entire ecosystem,
+use Launchpad salt-formulas project:
+
+ https://launchpad.net/salt-formulas
+
+You can also join salt-formulas-users team and subscribe to mailing list:
+
+ https://launchpad.net/~salt-formulas-users
+
+Developers wishing to work on the salt-formulas projects should always base
+their work on master branch and submit pull request against specific formula.
+
+ https://github.com/salt-formulas/salt-formula-linux
+
+Any questions or feedback is always welcome so feel free to join our IRC
+channel:
+
+ #salt-formulas @ irc.freenode.net
diff --git a/linux/files/grub_hugepages b/linux/files/grub_hugepages
new file mode 100644
index 0000000..509cc11
--- /dev/null
+++ b/linux/files/grub_hugepages
@@ -0,0 +1,2 @@
+{%- from "linux/map.jinja" import system with context %}
+GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT {%- for hugepages_type, hugepages in system.kernel.hugepages.iteritems() %}{%- if hugepages.get('default', False) %} default_hugepagesz={{ hugepages.size }} {%- endif %} hugepagesz={{ hugepages.size }} hugepages={{ hugepages.count }} {%- endfor %}"
diff --git a/linux/network/interface.sls b/linux/network/interface.sls
index 58e58e6..0fda106 100644
--- a/linux/network/interface.sls
+++ b/linux/network/interface.sls
@@ -39,9 +39,9 @@
{%- set int_name = int.get('name', int_name) %}
-{%- if int.ovs_bridge is defined %}
+{%- if int.ovs_bridge is defined and interface_name == int.ovs_bridge %}
-add_int_to_ovs_bridge_{{ interface_name }}:
+add_int_{{ int_name }}_to_ovs_bridge_{{ interface_name }}:
cmd.run:
- unless: ovs-vsctl show | grep {{ int_name }}
- name: ovs-vsctl add-port {{ interface_name }} {{ int_name }}
@@ -119,7 +119,6 @@
- type: {{ interface.type }}
{%- if interface.address is defined %}
{%- if grains.os_family == 'Debian' %}
- - unless: grep -q "iface {{ interface_name }} " /etc/network/interfaces
- proto: {{ interface.get('proto', 'static') }}
{% endif %}
{%- if grains.os_family == 'RedHat' %}
diff --git a/linux/system/grub.sls b/linux/system/grub.sls
new file mode 100644
index 0000000..d36ba47
--- /dev/null
+++ b/linux/system/grub.sls
@@ -0,0 +1,11 @@
+grub_d_directory:
+ file.directory:
+ - name: /etc/default/grub.d
+ - user: root
+ - group: root
+ - mode: 755
+ - makedirs: True
+
+grub_update:
+ cmd.wait:
+ - name: update-grub
diff --git a/linux/system/hugepages.sls b/linux/system/hugepages.sls
new file mode 100644
index 0000000..342d401
--- /dev/null
+++ b/linux/system/hugepages.sls
@@ -0,0 +1,33 @@
+{%- from "linux/map.jinja" import system with context %}
+
+include:
+ - linux.system.grub
+
+{%- if "pse" in grains.cpu_flags or "pdpe1gb" in grains.cpu_flags %}
+
+/etc/default/grub.d/90-hugepages.cfg:
+ file.managed:
+ - source: salt://linux/files/grub_hugepages
+ - template: jinja
+ - require:
+ - file: grub_d_directory
+ - watch_in:
+ - cmd: grub_update
+
+{%- for hugepages_type, hugepages in system.kernel.hugepages.iteritems() %}
+
+{%- if hugepages.get('mount', False) or hugepages.get('default', False) %}
+
+hugepages_mount_{{ hugepages_type }}:
+ mount.mounted:
+ - name: {{ hugepages.mount_point }}
+ - device: Hugetlbfs-kvm
+ - fstype: hugetlbfs
+ - mkmnt: true
+ - opts: mode=775,pagesize={{ hugepages.size }}
+
+{%- endif %}
+
+{%- endfor %}
+
+{%- endif %}
diff --git a/linux/system/init.sls b/linux/system/init.sls
index fabc37e..fb1b34d 100644
--- a/linux/system/init.sls
+++ b/linux/system/init.sls
@@ -11,6 +11,12 @@
{%- endif %}
{%- if system.kernel is defined %}
- linux.system.kernel
+{%- if system.kernel.hugepages is defined %}
+- linux.system.hugepages
+{%- endif %}
+{%- if system.kernel.sriov is defined %}
+- linux.system.sriov
+{%- endif %}
{%- endif %}
{%- if system.cpu is defined %}
- linux.system.cpu
@@ -65,4 +71,4 @@
{%- endif %}
{%- if system.config is defined %}
- linux.system.config
-{%- endif %}
+{%- endif %}
\ No newline at end of file
diff --git a/linux/system/sriov.sls b/linux/system/sriov.sls
new file mode 100644
index 0000000..4421c67
--- /dev/null
+++ b/linux/system/sriov.sls
@@ -0,0 +1,27 @@
+{%- from "linux/map.jinja" import system with context %}
+
+include:
+ - linux.system.grub
+
+/etc/default/grub.d/90-sriov.cfg:
+ file.managed:
+ - contents: 'GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT intel_iommu=on iommu=pt"'
+ - require:
+ - file: grub_d_directory
+ - watch_in:
+ - cmd: grub_update
+
+/etc/modprobe.d/sriov.conf:
+ file.managed:
+ - contents: |
+ blacklist ixgbevf
+ blacklist igbvf
+ blacklist i40evf
+
+{%- if system.kernel.get('unsafe_interrupts', false) %}
+
+/etc/modprobe.d/iommu_unsafe_interrupts.conf:
+ file.managed:
+ - contents: options vfio_iommu_type1 allow_unsafe_interrupts=1
+
+{%- endif %}
diff --git a/tests/pillar/system.sls b/tests/pillar/system.sls
index 9831d9f..152766d 100644
--- a/tests/pillar/system.sls
+++ b/tests/pillar/system.sls
@@ -19,6 +19,13 @@
term: xterm
prompt:
default: "test01.local$"
+ kernel:
+ hugepages:
+ large:
+ default: true
+ size: 1G
+ count: 210
+ mount_point: /mnt/hugepages_1GB
motd:
- warning: |
#!/bin/sh