Skip to content
This repository was archived by the owner on Feb 14, 2020. It is now read-only.

Ansible 2.4 deprecations fix #5

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
service:
name=bind9
state=reloaded
sudo: yes
become: yes

- name: restart bind9
service:
name=bind9
state=restarted
sudo: yes
become: yes

- name: start bind9
service:
name=bind9
state=started
sudo: yes
become: yes

- name: stop bind9
service:
name=bind9
state=stopped
sudo: yes
become: yes
16 changes: 8 additions & 8 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
# tasks file
#

- include: debug.yml
- import_tasks: debug.yml
when: debug | default(false)
tags: debug

- include: validation.yml
- import_tasks: validation.yml
tags: validation

- include: installation.yml
- import_tasks: installation.yml
tags: installation
sudo: yes
become: yes

- include: configuration.yml
- import_tasks: configuration.yml
tags: configuration
sudo: yes
become: yes

- include: apparmor.yml
- import_tasks: apparmor.yml
tags: apparmor
sudo: yes
become: yes
2 changes: 1 addition & 1 deletion tasks/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- name: ensure mandatory variables are set
fail:
msg="{{ item }} is a mandatory variable"
when: "{{ item }} is not defined"
when: "item is not defined"
with_items:
- bind_default_resolvconf
- bind_default_options
Expand Down
4 changes: 2 additions & 2 deletions templates/etc/bind/named.conf.local.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

{% if bind_local_includes is defined %}
{% for content in bind_local_includes %}
include "{{ content }}";
include "{{ content }}";
{% endfor %}
{% endif %}

{% endif %}
{% if bind_zones is defined %}
{% for zone, content in bind_zones.iteritems() | sort %}
zone "{{ zone }}" {
Expand Down
26 changes: 13 additions & 13 deletions templates/etc/bind/named.conf.logging.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

{% if bind_named_conf_logging is defined and bind_named_conf_logging.channels is defined %}
logging {
{% for channel, content in bind_named_conf_logging.channels.iteritems() | sort %}
{% for channel, content in bind_named_conf_logging.channels.iteritems() | reject("equalto", "") | sort %}
channel {{ channel }} {
{% for line in content.split('\n') %}
{% for line in content.split('\n') | reject("equalto", "") | sort %}
{{ line }}
{% endfor %}
{% endfor %}
};
{% endfor %}
{% endfor %}

{% for category, channel in bind_named_conf_logging.categories.iteritems() %}
{# Old Style #}
{% if channel is string %}
category {{ category }} { {{ channel }}; };
{# New Style #}
{% elif channel is sequence %}
category {{ category }} { {{ channel | join('; ')}}; };
{% endif %}
{% endfor %}
{% for category, channel in bind_named_conf_logging.categories.iteritems() | sort %}
{# Old Style #}
{% if channel is string %}
category {{ category }} { {{ channel }}; };
{# New Style #}
{% elif channel is sequence %}
category {{ category }} { {{ channel | join('; ')}}; };
{% endif %}
{% endfor %}
};
{% endif %}
2 changes: 1 addition & 1 deletion templates/etc/bind/named.conf.options.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// {{ ansible_managed }}

options {
{% for line in bind_named_conf_options.split('\n')| sort %}
{% for line in bind_named_conf_options.split('\n') | reject("equalto", "") | sort %}
{{ line }}
{% endfor %}
};
4 changes: 2 additions & 2 deletions templates/var/cache/bind/db.name.zone.j2
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
; {{ ansible_managed }}

{% if 'directives' in item.value %}
{% for directive, value in item.value.directives.iteritems() %}
{% for directive, value in item.value.directives.iteritems() | sort %}
${{ directive }} {{ value }}
{% endfor %}
{% endif %}
{% if 'resource_records' in item.value %}
{% for record in item.value.resource_records %}
{% for record in item.value.resource_records | sort(attribute='type', reverse = True) %}
{% if 'name' in record %}{{ (record.name|string).ljust(25) }}{% endif %} {% if 'ttl' in record %}{{ (record.ttl|string).ljust(5) }}{% endif %} {% if 'class' in record %}{{ (record.class|string).ljust(3) }}{% endif %} {% if 'type' in record %}{{ (record.type|string).ljust(10) }}{% endif %} {% if 'data' in record %}{{ record.data }}{% endif %}

{% endfor %}
Expand Down
4 changes: 2 additions & 2 deletions tests/files/tmp/db.example.com.zone.expected
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ $TTL 3600
example.com. IN SOA sid.example.com. root.example.com. ( 2007120710 1d 2h 4w 1h )
@ IN NS sid.example.com.
@ IN MX 10 sid.example.com.
sid IN A 192.168.0.1
etch IN A 192.168.0.2
pop IN CNAME sid
www IN CNAME sid
mail IN CNAME sid
sid IN A 192.168.0.1
etch IN A 192.168.0.2
9 changes: 3 additions & 6 deletions tests/files/tmp/named.conf.logging.expected
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,22 @@
logging {
channel bind_log {
file "/var/log/named/bind.log" versions 3 size 1m;
severity info;
print-category yes;
print-severity yes;
print-time yes;

severity info;
};
channel security_info {
file "/var/log/named/security_info.log" versions 1 size 100k;
severity info;
print-severity yes;
print-time yes;

severity info;
};
channel update_debug {
file "/var/log/named/update_debug.log" versions 3 size 100k;
severity debug;
print-severity yes;
print-time yes;

severity debug;
};

category default { bind_log; };
Expand Down
1 change: 0 additions & 1 deletion tests/files/tmp/named.conf.options.expected
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Ansible managed file, do not edit directly

options {

auth-nxdomain no;
directory "/var/cache/bind";
dnssec-validation auto;
Expand Down
4 changes: 2 additions & 2 deletions tests/plugins/callback/idempotence.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os

from ansible import constants as C
from ansible.constants import mk_boolean
from ansible.module_utils.parsing.convert_bool import boolean

try:
from ansible.plugins.callback import CallbackBase
Expand All @@ -27,7 +27,7 @@ class CallbackModule(parent):

def __init__(self):
self.playbook = None
self.enabled = mk_boolean(os.getenv(VAR_IDEMPOTENCE, 'no'))
self.enabled = boolean(os.getenv(VAR_IDEMPOTENCE, 'no'))

super(CallbackModule, self).__init__()

Expand Down
4 changes: 2 additions & 2 deletions tests/tasks/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
copy:
src="tmp/named.conf{{ item }}.expected"
dest="/tmp/named.conf{{ item }}.expected"
sudo: yes
become: yes
changed_when: no
with_items:
- ''
Expand Down Expand Up @@ -65,7 +65,7 @@
copy:
src="tmp/db.{{ item }}.zone.expected"
dest="/tmp/db.{{ item }}.zone.expected"
sudo: yes
become: yes
changed_when: no
with_items:
- 'example.com'
Expand Down
6 changes: 3 additions & 3 deletions tests/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# Test tasks to verify role execution.
#

- include: installation.yml
- import_tasks: installation.yml
tags: installation

- include: configuration.yml
- import_tasks: configuration.yml
tags: configuration

- name: test syntax of configuration files
Expand All @@ -22,7 +22,7 @@

- name: test if bind9 process is running
shell: service bind9 status
sudo: yes
become: yes
register: test
changed_when: no
failed_when: test.stdout.find('bind9 is running') == -1