I have a db host, on which some sql files are present. I want to source it into db using an ansible playbook. so I find all files & register in variable, then try to source those using below code.
- name: get schema files
find:
paths: "~/dbs/"
recurse: no
patterns: "*.sql"
register: db_sql_files
- name: import schemas
mysql_db:
name: all
state: import
target: "{{ item['path'] }}"
login_user: "{{ db_user }}"
login_password: "{{ db_pass }}"
with_items: "{{ db_sql_files['files'] }}"
when I run playbook, I get below error.
The task includes an option with an undefined variable. The error was: 'item' is undefined