nephosolutions.postgresql
NephoSolutions - Ansible 角色 PostgreSQL
Ansible 角色,用于安装和配置 PostgreSQL、扩展、数据库和用户。
从 ANXS/postgresql fork。
安装
此角色已在 Ansible 2.4.0 及更高版本下测试。
安装方法:
ansible-galaxy install ANXS.postgresql
示例剧本
以下是如何使用该角色的示例:
- hosts: postgresql-server
become: yes
roles:
- { role: anxs.postgresql }
依赖项
兼容性矩阵
发行版 / PostgreSQL | <= 9.3 | 9.4 | 9.5 | 9.6 | 10 | 11 | 12 |
---|---|---|---|---|---|---|---|
Ubuntu 14.04 | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :grey_question: |
Ubuntu 16.04 | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :grey_question: |
Debian 8.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :grey_question: |
Debian 9.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :grey_question: |
CentOS 6.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :grey_question: |
CentOS 7.x | :no_entry: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :grey_question: |
CentOS 8.x | :no_entry: | :grey_question: | :grey_question: | :grey_question: | :grey_question: | :grey_question: | :grey_question: |
Fedora 最新版 | :no_entry: | :x: | :x: | :x: | :x: | :x: | :x: |
- :white_check_mark: - 已测试,工作正常
- :warning: - 不适合生产环境
- :grey_question: - 将来可能有效(如果可以,请提供帮助)
- :interrobang: - 可能有效,未测试
- :no_entry: - PostgreSQL 已达到生命周期结束(EOL)
变量
# 基本设置
postgresql_version: 11
postgresql_encoding: "UTF-8"
postgresql_locale: "en_US.UTF-8"
postgresql_ctype: "en_US.UTF-8"
postgresql_admin_user: "postgres"
postgresql_default_auth_method: "peer"
postgresql_service_enabled: false # 服务是否应启用,默认值为 true
postgresql_cluster_name: "main"
postgresql_cluster_reset: false
# 要创建的数据库列表(可选)
# 注意:想要灵活使用扩展,请使用 postgresql_database_extensions 设置。
postgresql_databases:
- name: foobar
owner: baz # 可选;指定数据库的所有者
hstore: yes # 在该数据库上安装 hstore 扩展的标志(是/否)
uuid_ossp: yes # 在该数据库上安装 uuid-ossp 扩展的标志(是/否)
citext: yes # 在该数据库上安装 citext 扩展的标志(是/否)
encoding: "UTF-8" # 为每个数据库覆盖全局 {{ postgresql_encoding }} 变量
lc_collate: "en_GB.UTF-8" # 为每个数据库覆盖全局 {{ postgresql_locale }} 变量
lc_ctype: "en_GB.UTF-8" # 为每个数据库覆盖全局 {{ postgresql_ctype }} 变量
# 要创建的数据库扩展列表(可选)
postgresql_database_extensions:
- db: foobar
extensions:
- hstore
- citext
# 要创建的用户列表(可选)
postgresql_users:
- name: baz
pass: pass
encrypted: yes # 如果密码应该被加密,postgresql >= 10 只接受加密密码
# 要创建的架构列表(可选)
postgresql_database_schemas:
- database: foobar # 数据库名称
schema: acme # 架构名称
state: present
- database: foobar # 数据库名称
schema: acme_baz # 架构名称
owner: baz # 所有者名称
state: present
# 要应用的用户权限列表(可选)
postgresql_user_privileges:
- name: baz # 用户名称
db: foobar # 数据库
priv: "所有" # 权限字符串格式:示例:INSERT,UPDATE/table:SELECT/anothertable:所有
role_attr_flags: "CREATEDB" # 角色属性标志
还有很多其他的设置,可以在 defaults/main.yml 中找到。
测试
该项目随附一个 Vagrantfile,这是一种快速简单的方式来测试角色的更改,可以使用 vagrant up
启动它。
请参见 vagrant 文档 以了解如何使用 Vagrant。
一旦你的虚拟机启动,你可以使用 vagrant provision
或 ansible-playbook tests/playbook.yml -i vagrant-inventory
对其进行重新配置。
如果想要测试剧本,可以查看 tests/playbook.yml,并在 tests/vars.yml 中修改变量。
如果你要贡献,请首先在 Vagrant 环境中测试你的更改(使用目标发行版),如果可能,请确保你的更改包含在 .travis.yml 中的测试覆盖范围内。
许可证
根据 MIT 许可证授权。有关详细信息,请参阅 LICENSE 文件。
感谢
创建者:
维护者:
主要贡献者:
反馈、错误报告、请求...
欢迎 提出!
关于项目
"Install and configure PostgreSQL, dependencies, extensions, databases and users." "Forked from https://github.com/ANXS/postgresql"
安装
ansible-galaxy install nephosolutions.postgresql
许可证
mit
下载
1.4k
拥有者
ICT Consultancy & Services – DevOps & Cloud Architects