diff --git a/tasks/database-lmdb.yml b/tasks/database-lmdb.yml index b57f847..9948fda 100644 --- a/tasks/database-lmdb.yml +++ b/tasks/database-lmdb.yml @@ -7,4 +7,4 @@ group: "{{ pdns_group }}" state: directory mode: 0750 - with_items: "{{ pdns_lmdb_databases_locations }}" + loop: "{{ pdns_lmdb_databases_locations }}" diff --git a/tasks/database-mysql.yml b/tasks/database-mysql.yml index 732b473..dd76b3f 100644 --- a/tasks/database-mysql.yml +++ b/tasks/database-mysql.yml @@ -15,7 +15,7 @@ state: present when: "item.key.split(':')[0] == 'gmysql'" no_log: true - with_dict: "{{ pdns_backends | combine(pdns_mysql_databases_credentials, recursive=True) }}" + loop: "{{ pdns_backends | combine(pdns_mysql_databases_credentials, recursive=True | dict2items) }}" - name: Grant PowerDNS access to the MySQL databases community.mysql.mysql_user: @@ -29,10 +29,7 @@ priv: "{{ item[0]['dbname'] }}.*:ALL" append_privs: true state: present - with_subelements: - - "{{ pdns_backends | combine(pdns_mysql_databases_credentials, recursive=True) }}" - - priv_host - - skip_missing: true + loop: "{{ (pdns_backends | combine(pdns_mysql_databases_credentials, recursive=True)) | dict2items | subelements('priv_host', skip_missing=true) }}" - name: Check if the MySQL databases are empty ansible.builtin.command: > @@ -40,7 +37,7 @@ --host="{{ item['value']['host'] }}" --port "{{ item['value']['port'] | default('3306') }}" --batch --skip-column-names --execute="SELECT COUNT(DISTINCT table_name) FROM information_schema.columns WHERE table_schema = '{{ item['value']['dbname'] }}'" when: item.key.split(':')[0] == 'gmysql' - with_dict: "{{ pdns_backends }}" + loop: "{{ pdns_backends | dict2items }}" register: _pdns_check_mysql_db no_log: true changed_when: false @@ -75,4 +72,4 @@ target: "{{ pdns_mysql_schema_file_to_use }}" no_log: true when: "item['item']['key'].split(':')[0] == 'gmysql' and item['stdout'] == '0'" - with_items: "{{ _pdns_check_mysql_db['results'] }}" + loop: "{{ _pdns_check_mysql_db['results'] }}" diff --git a/tasks/database-sqlite3.yml b/tasks/database-sqlite3.yml index 5b55ebb..9aa7359 100644 --- a/tasks/database-sqlite3.yml +++ b/tasks/database-sqlite3.yml @@ -19,7 +19,7 @@ group: "{{ pdns_group }}" state: directory mode: 0750 - with_items: "{{ pdns_sqlite_databases_locations }}" + loop: "{{ pdns_sqlite_databases_locations }}" - name: Determine location of the SQL file ansible.builtin.shell: @@ -44,7 +44,7 @@ ansible.builtin.shell: "sqlite3 {{ item }} < {{ pdns_sqlite_schema_file_to_use }}" args: creates: "{{ item }}" - with_items: "{{ pdns_sqlite_databases_locations }}" + loop: "{{ pdns_sqlite_databases_locations }}" - name: Check the PowerDNS SQLite databases permissions ansible.builtin.file: @@ -53,4 +53,4 @@ group: "{{ pdns_group }}" mode: 0640 state: file - with_items: "{{ pdns_sqlite_databases_locations }}" + loop: "{{ pdns_sqlite_databases_locations }}" diff --git a/tasks/install.yml b/tasks/install.yml index 937c97e..17f2f6b 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -31,4 +31,4 @@ state: present no_log: true when: pdns_backends_packages[item.key.split(':')[0]] is defined - with_dict: "{{ pdns_backends }}" + loop: "{{ pdns_backends | dict2items }}"