From bcd528f95114668277aafe2fb21eec452882815d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Flor=C3=A9al=20Toumikian?= Date: Fri, 17 May 2024 12:28:23 +0200 Subject: [PATCH] Fixed: Linters error --- .gitignore | 1 + ansible.cfg | 2 +- playbooks/01-primary-ns.yaml | 73 +++++++++++++++-------------- playbooks/tasks/ns/primary-zone.yml | 46 +++++++++--------- 4 files changed, 61 insertions(+), 61 deletions(-) diff --git a/.gitignore b/.gitignore index 5df1376..588d8ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /.vscode/ /inventory/ +/ansible_collections/ diff --git a/ansible.cfg b/ansible.cfg index 8be7511..038ebd7 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,3 +1,3 @@ [defaults] -inventory = inventory/hosts.yml +inventory = inventory collections_path = . \ No newline at end of file diff --git a/playbooks/01-primary-ns.yaml b/playbooks/01-primary-ns.yaml index d51712f..b050a2a 100644 --- a/playbooks/01-primary-ns.yaml +++ b/playbooks/01-primary-ns.yaml @@ -1,44 +1,45 @@ -- hosts: dns-hosts - name: Configuration of ns zones +- name: Configuration of ns zones + hosts: primarydns + vars: + zones: + - zome: + domain_name: trans13nrv.eu.org tasks: - - name: Use variables - include_vars: vars.yml + - name: Use variables + ansible.builtin.include_vars: vars.yml - - - name: Ensure bind is installed - package: - name: bind9 - state: latest + - name: Ensure bind is installed + ansible.builtin.package: + name: bind9 + state: present - - name: Ensure dnssec-tools is installed - package: - name: dnsutils - state: latest + - name: Ensure dnssec-tools is installed + ansible.builtin.package: + name: dnsutils + state: present - - name: Ensure required master zone directory is present - file: - path: "{{ dns.paths.primary_zones }}" - state: directory - owner: "{{ root.user }}" - group: "{{ dns.group }}" + - name: Ensure required master zone directory is present + ansible.builtin.file: + path: "{{ dns.paths.primary_zones }}" + state: directory + owner: "{{ root.user }}" + group: "{{ dns.group }}" + mode: "660" - - name: Ensure required keys zone directory is present - file: - path: "{{ dns.paths.keys }}" - state: directory - owner: "{{ dns.user }}" - group: "{{ dns.group }}" + - name: Ensure required keys zone directory is present + ansible.builtin.file: + path: "{{ dns.paths.keys }}" + state: directory + owner: "{{ dns.user }}" + group: "{{ dns.group }}" + mode: "660" - - name: Prymary Zones - vars: - zones: - - zome: - domain_name: trans13nrv.eu.org - include_tasks: tasks/ns/primary-zone.yml - loop: "{{ zones }}" + - name: Prymary Zones + ansible.builtin.include_tasks: tasks/ns/primary-zone.yml + loop: "{{ zones }}" - - name: Reload bind9 service - service: - name: bind9 - state: reloaded \ No newline at end of file + - name: Reload bind9 service + ansible.builtin.service: + name: bind9 + state: reloaded diff --git a/playbooks/tasks/ns/primary-zone.yml b/playbooks/tasks/ns/primary-zone.yml index 19bb979..5c3b9cc 100644 --- a/playbooks/tasks/ns/primary-zone.yml +++ b/playbooks/tasks/ns/primary-zone.yml @@ -1,27 +1,25 @@ --- - - name: "Setup variable for zone {{ zone.domain_name }}" - register: - domain_name: "{{ zone.domain_name }}" - transfer_hosts: "{{ zone.transfer_hosts }}" - zone_config_file: "{{ dns.paths.etc }}/named.conf.{{ domain_name }}" - zone_db_file: "{{ dns.paths.dns.paths.primary_zones }}/db.{{ zone.domain_zone }}" +- vars: + zone_config_file: "{{ dns.patch.etc }}/named.conf.{{ zone.domain_name }}" + zone_db_file: "{{ dns.patch.primary_zones }}/db.{{ zone.domain_name }}.zone" - - name: Updating primary zone db file - file: - src: "file/ns/zone/db.{{ domain_name }}" - dest: "{{ zone_db_file }}" +- name: Updating primary zone db file + ansible.builtin.file: + src: "file/ns/zone/db.{{ zone.domain_name }}" + dest: "{{ zone_db_file }}" - - name: "Creating zone {{ domain_name }}" - template: - src: templates/ns/zone/named.conf.primary-zone.j2 - dest: "{{ zone_config_file }}" - - - name: "Including zone configuration to global configuration" - blockinfile: - path: "{{ dns.path.etc }}/named.conf.local" - state: present - marker: "// {mark} ANSIBLE MANAGED BLOCK FOR {{ domain_name }} ZONE" # not required. The marker line template. C({mark}) will be replaced with the values C(in marker_begin) (default="BEGIN") and C(marker_end) (default="END"). Using a custom marker without the C({mark}) variable may result in the block being repeatedly inserted on subsequent playbook runs. - block: | - "include \"{{ zone_config_file }}\""; - marker_begin: BEGIN - marker_end: END \ No newline at end of file +- name: "Creating zone {{ domain_name }}" + ansible.builtin.template: + src: templates/ns/zone/named.conf.primary-zone.j2 + dest: "{{ zone_config_file }}" + mode: "644" + +- name: "Including zone configuration to global configuration" + ansible.builtin.blockinfile: + path: "{{ dns.path.etc }}/named.conf.local" + state: present + marker: "// {mark} ANSIBLE MANAGED BLOCK FOR {{ domain_name }} ZONE" + block: | + "include \"{{ zone_config_file }}\""; + marker_begin: BEGIN + marker_end: END