--- - 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 }}" - name: Updating primary zone db file file: src: "file/ns/zone/db.{{ 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