Add remove_ntp_dhcp option
* Those option are WA for
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=600661
WA needed for extremly rare situatuon, when network dhcp provide wrong
ntp.
* Those option make sence to use only with dropping 'ntp-servers' request
from dhclient.conf - unless, you totally remove dhcp client from system
* Misc: update run_tests.sh to latest
Change-Id: I8818eed3541f1d7bfc073cc05d8df48d124b812e
diff --git a/README.rst b/README.rst
index 800e869..e5a96e8 100644
--- a/README.rst
+++ b/README.rst
@@ -86,6 +86,15 @@
server: ntp.nic.cz
key_id: 2
+Cleanup ntp configurations left by DHCP:
+
+.. code-block:: yaml
+
+ ntp:
+ client:
+ enabled: true
+ remove_dhcp_conf: true # default false
+
Peering (simple):
.. code-block:: yaml
diff --git a/ntp/client.sls b/ntp/client.sls
index cf5fc59..ae18820 100644
--- a/ntp/client.sls
+++ b/ntp/client.sls
@@ -68,4 +68,14 @@
- watch:
- file: /etc/ntp.conf
+{%- if client.get('remove_dhcp_conf', False) %}
+ntp_remove_dhcp_conf:
+ file.absent:
+ - name: /var/lib/ntp/ntp.conf.dhcp
+ - watch_in:
+ - service: ntp_service
+ - require_in:
+ - file: /etc/ntp.conf
+{%- endif %}
+
{%- endif %}
diff --git a/ntp/schemas/client.yaml b/ntp/schemas/client.yaml
index cabda1f..cf43ae2 100644
--- a/ntp/schemas/client.yaml
+++ b/ntp/schemas/client.yaml
@@ -21,6 +21,11 @@
description: |
Enables mode7 for the NTP server.
type: boolean
+ remove_dhcp_conf:
+ description: |
+ Forcibly remove "/var/lib/ntp/ntp.conf.dhcp" file.
+ WA for issue https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=600661
+ type: boolean
strata:
description: |
List of NTP stratums to keep the time in sync.
diff --git a/ntp/schemas/server.yaml b/ntp/schemas/server.yaml
index 1c8fdbc..0ae5b8e 100644
--- a/ntp/schemas/server.yaml
+++ b/ntp/schemas/server.yaml
@@ -29,6 +29,11 @@
type: number
minimum: 0
maximum: 8
+ remove_dhcp_conf:
+ description: |
+ Forcibly remove "/var/lib/ntp/ntp.conf.dhcp" file.
+ WA for issue https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=600661
+ type: boolean
restrict:
description: |
List of subnets that servers gives time to.
diff --git a/ntp/server.sls b/ntp/server.sls
index 6c3a8bc..b884481 100644
--- a/ntp/server.sls
+++ b/ntp/server.sls
@@ -68,4 +68,16 @@
- watch:
- file: /etc/ntp.conf
+{%- if server.get('remove_dhcp_conf', False) %}
+ntp_remove_dhcp_conf:
+ file.absent:
+ - name: /var/lib/ntp/ntp.conf.dhcp
+ - watch_in:
+ - service: ntp_service
+ - require_in:
+ - file: /etc/ntp.conf
{%- endif %}
+
+{%- endif %}
+
+
diff --git a/tests/pillar/client_auth.sls b/tests/pillar/client_auth.sls
index ebe515e..6c5ca3f 100644
--- a/tests/pillar/client_auth.sls
+++ b/tests/pillar/client_auth.sls
@@ -1,6 +1,7 @@
ntp:
client:
enabled: true
+ remove_dhcp_conf: true
auth:
enabled: true
secrets:
@@ -22,4 +23,4 @@
key_id: 1
secondary:
server: ntp.nic.cz
- key_id: 2
\ No newline at end of file
+ key_id: 2
diff --git a/tests/pillar/server_auth.sls b/tests/pillar/server_auth.sls
index 9c351c9..8891a40 100644
--- a/tests/pillar/server_auth.sls
+++ b/tests/pillar/server_auth.sls
@@ -15,6 +15,7 @@
trustedkey: false
mode7: true
orphan: 5
+ remove_dhcp_conf: true
peers:
- host: 192.168.31.1
- host: 192.168.31.2
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 7093161..a348912 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -28,6 +28,8 @@
SALT_OPTS="${SALT_OPTS} --retcode-passthrough --local -c ${SALT_CONFIG_DIR} --log-file=/dev/null"
+IGNORE_MODELVALIDATE_MASK=${IGNORE_MODELVALIDATE_MASK:-"novalidate"}
+
if [ "x${SALT_VERSION}" != "x" ]; then
PIP_SALT_VERSION="==${SALT_VERSION}"
fi
@@ -154,7 +156,11 @@
}
prepare() {
- [ -d ${BUILDDIR} ] && mkdir -p ${BUILDDIR}
+ if [[ -f ${BUILDDIR}/.prepare_done ]]; then
+ log_info "${BUILDDIR}/.prepare_done exist, not rebuilding BUILDDIR"
+ return
+ fi
+ [[ -d ${BUILDDIR} ]] && mkdir -p ${BUILDDIR}
[[ ! -f "${VENV_DIR}/bin/activate" ]] && setup_virtualenv
setup_mock_bin
@@ -162,6 +168,7 @@
setup_salt
install_dependencies
link_modules
+ touch ${BUILDDIR}/.prepare_done
}
lint_releasenotes() {
@@ -215,7 +222,7 @@
salt_run saltutil.clear_cache; salt_run saltutil.refresh_pillar; salt_run saltutil.sync_all;
for role in ${SCHEMARDIR}/*.yaml; do
role_name=$(basename "${role%*.yaml}")
- for pillar in pillar/${role_name}*.sls; do
+ for pillar in $(ls pillar/${role_name}*.sls | grep -v ${IGNORE_MODELVALIDATE_MASK} ); do
pillar_name=$(basename "${pillar%*.sls}")
local _message="FORMULA:${FORMULA_NAME} ROLE:${role_name} against PILLAR:${pillar_name}"
log_info "model_validate ${_message}"