A module for executing a sql query against a database using SqlAlchemy.
connection
-- a sqlalchemy database uriquery
-- the sql query to executerows_are_lists
-- if True, return rows as lists. If False (the default), return rows as dictionaries.
- hosts: localhost
roles:
- sql_query
tasks:
- sql_query:
connection: sqlite:///airports.sqlite
query: >
select name, city from airports
where timezone = -5 and country = 'United States'
register: result
- debug:
var: result
- debug:
msg: "{{ item.name }} is located in {{ item.city }}"
with_items: "{{ result.results }}"
ansible-playbook -i tests/inventory tests/main.yml