Skip to content

Commit

Permalink
Deprecation check and test fixup
Browse files Browse the repository at this point in the history
Add a deprecation message if enable_logging is used instead of enable_query_log.
Abort if both enable_logging/enable_query_log is enabled with use_extensive_logging
as these are mutually exclusive now.

Fixup tests to _not_ look for the querylog line.
  • Loading branch information
ixs committed May 3, 2019
1 parent 5685a5e commit 7e2652a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
12 changes: 12 additions & 0 deletions bind/config.sls
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ bind_config:
- watch_in:
- service: bind
{%- if salt['pillar.get']('bind:config:enable_logging') is not none %}
bind_local_config_deprecated_logging:
test.show_notification:
- text: Pillar data contains enable_logging. This parameter is deprecated and has been renamed enable_query_log.
{%- endif %}
{%- if (salt['pillar.get']('bind:config:enable_logging') or salt['pillar.get']('bind:config:enable_query_log')) and salt['pillar.get']('bind:config:use_extensive_logging') %}
bind_local_config_logging_extensive_fail:
test.fail_without_changes:
- name: Pillar data uses enable_logging/enable_query_log and use_extensive_logging. These are mutually exclusive.
{%- endif %}
bind_local_config:
file.managed:
- name: {{ map.local_config }}
Expand Down
3 changes: 2 additions & 1 deletion bind/files/named.conf.local.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ view {{ view }} {

{%- if salt['pillar.get']('bind:config:use_extensive_logging', False) %}
include "{{ map.logging_config }}";
{% elif salt['pillar.get']('bind:config:enable_logging', False) %}
{#- bind:config:enable_logging is deprecated. TODO: Remove the or part of the condition below after a while. #}
{% elif salt['pillar.get']('bind:config:enable_query_log', False) or salt['pillar.get']('bind:config:enable_logging', False) %}
logging {
channel "querylog" {
file "{{ map.log_dir }}/query.log";
Expand Down
2 changes: 1 addition & 1 deletion pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bind:
user: root # File & Directory user
group: named # File & Directory group
mode: 640 # File & Directory mode
enable_logging: true # Enable basic query logging in $log_dir/query.log
enable_query_log: true # Enable basic query logging in $log_dir/query.log
use_extensive_logging: # Alternatively, enable much more extensive config for logging.
channel: # Partial example. For proposed settings please refer to
default_log: # https://kb.isc.org/article/AA-01526/0/BIND-Logging-some-basic-recommendations.html
Expand Down
2 changes: 1 addition & 1 deletion test/integration/default/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
# Match 100.51.198 reverse zone from pillar
its('content') { should match /^zone\ "100\.51\.198\.in-addr\.arpa"\ {\n\ \ type\ master;\n\ \ file\ "#{zones_directory}\/100\.51\.198\.in-addr\.arpa";\n\ \ \n\ \ notify\ no;\n\};/ }
# Match logging
its('content') { should match /^logging\ \{\n\ \ channel\ "querylog"\ {\n\ \ \ \ file\ "#{log_directory}\/query\.log";\n\ \ \ \ print-time\ yes;\n\ \ \};\n\ \ category\ queries\ \{\ querylog;\ \};\n\};/ }
its('content') { should not match /^logging\ \{\n\ \ channel\ "querylog"\ {\n\ \ \ \ file\ "#{log_directory}\/query\.log";\n\ \ \ \ print-time\ yes;\n\ \ \};\n\ \ category\ queries\ \{\ querylog;\ \};\n\};/ }
# Match acl1
its('content') { should match /acl\ client1\ \{\n\ \ 127\.0\.0\.0\/8;\n\ \ 10\.20\.0\.0\/16;\n\};/ }
# Match acl2
Expand Down

0 comments on commit 7e2652a

Please sign in to comment.