rtshome.pgsql
pgsql
提供四个新的Ansible模块用于Postgresql:
- postgresql_table:确保数据库中存在(或不存在)一个表
- postgresql_row:确保表中存在(或不存在)一行
- postgresql_query:在数据库中执行任意查询并返回结果
- postgresql_command:在数据库中执行任意查询
有关更多文档,请查看项目的维基: https://github.com/rtshome/ansible_pgsql/wiki
要求
需要安装psycopg2,详情请参阅Ansible的PostgreSQL模块:http://docs.ansible.com/ansible/latest/list_of_database_modules.html#postgresql
角色变量
模块没有定义变量
依赖关系
示例剧本
示例剧本实现:
- 在
acme
数据库中创建表config
- 确保
config
表中存在一行 - 对
config
进行SELECT查询并将结果存储在query
变量中 - 执行命令删除
logs
表中的所有记录
- hosts: servers
tasks:
- postgresql_table:
database: acme
name: config
state: present
columns:
- {
name: key,
type: text,
null: False
}
- {
name: value,
type: text,
null: False
}
primary_key:
- key
- postgresql_row:
database: acme
table: config
row:
key: env
value: production
- postgresql_query:
database: acme
query: SELECT * FROM config WHERE env = %(env)s
parameters:
env: production
register: query
- postgresql_command:
database: acme
command: "TRUNCATE logs"
roles:
- rtshome.pgsql
许可证
BSD
作者信息
Denis Gasparin denis@gasparin.net http://www.gasparin.net
关于项目
Add four modules to interact with PostgreSQL DBMS: postgresql_table, postgresql_row, postgresql_query, postgresql_command.
安装
ansible-galaxy install rtshome.pgsql
许可证
bsd-2-clause
下载
76.4k
拥有者