test: use personal docker registry

This commit is contained in:
Adrien Waksberg 2024-05-08 10:43:30 +02:00
parent a96b7547e8
commit d69bac6e1e
4 changed files with 105 additions and 62 deletions

View file

@ -0,0 +1,52 @@
From bf0c03dc14b9ba6d63950dfcd4a61ab430619b82 Mon Sep 17 00:00:00 2001
From: Adrien Waksberg <adrien.waksberg@mylegitech.com>
Date: Tue, 23 Apr 2024 10:51:45 +0200
Subject: [PATCH] feat: remove apt_key use
---
CHANGELOG.md | 1 +
tasks/repo.yml | 15 +++++++++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 272f011..b17cb66 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
- break: new system for user and privileges
- break: default postgresql version is 15
+- feat: remove apt_key use
### Added
diff --git a/tasks/repo.yml b/tasks/repo.yml
index 21c94ee..8fc021a 100644
--- a/tasks/repo.yml
+++ b/tasks/repo.yml
@@ -1,11 +1,18 @@
---
-- name: Add official repository key
- ansible.builtin.apt_key:
+- name: Add repository key
+ ansible.builtin.get_url:
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
+ dest: /etc/apt/keyrings/postgresql.asc
+ owner: root
+ group: root
+ mode: "0644"
+ checksum: sha256:0144068502a1eddd2a0280ede10ef607d1ec592ce819940991203941564e8e76
tags: postgresql
-- name: Add official repostiroy
+- name: Add repository
ansible.builtin.apt_repository:
+ repo: >-
+ deb [signed-by=/etc/apt/keyrings/postgresql.asc]
+ http://apt.postgresql.org/pub/repos/apt {{ ansible_distribution_release }}-pgdg main
filename: postgresql
- repo: "deb http://apt.postgresql.org/pub/repos/apt {{ ansible_distribution_release }}-pgdg main"
tags: postgresql
--
2.39.2

View file

@ -10,6 +10,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
- break: new system for user and privileges - break: new system for user and privileges
- break: default postgresql version is 15 - break: default postgresql version is 15
- feat: remove apt_key use - feat: remove apt_key use
- test: use personal docker registry
### Added ### Added
@ -26,6 +27,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
### Removed ### Removed
- test: remove support debian 10 - test: remove support debian 10
- test: remove support debian 11
## v1.0.0 - 2021-09-10 ## v1.0.0 - 2021-09-10

102
README.md
View file

@ -1,30 +1,30 @@
# Ansible role: Postgresql # Ansible role: Postgresql
[![Version](https://img.shields.io/badge/latest_version-1.0.0-green.svg)](https://git.yaegashi.fr/nishiki/ansible-role-postgresql/releases) [![Version](https://img.shields.io/badge/latest_version-1.0.0-green.svg)](https://code.waks.be/nishiki/ansible-role-postgresql/releases)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://git.yaegashi.fr/nishiki/ansible-role-postgresql/src/branch/master/LICENSE) [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://code.waks.be/nishiki/ansible-role-postgresql/src/branch/main/LICENSE)
Install and configure Postgresql Install and configure Postgresql
## Requirements ## Requirements
* Ansible >= 2.10 - Ansible >= 2.10
* Debian - Debian
* Bullseye - Bullseye
* Bookworm - Bookworm
## Role variables ## Role variables
| Name | Type | Required |Default | Comment | | Name | Type | Required | Default | Comment |
|------------------------------------|-------|----------|--------|-----------------------------------------------------| | ---------------------------------- | ----- | -------- | ------- | --------------------------------------------------- |
| postgresql_version | str | no | 15 | the major version to use | | postgresql_version | str | no | 15 | the major version to use |
| postgresql_use_official_repository | bool | no | false | set true if you want official postgresql repository | | postgresql_use_official_repository | bool | no | false | set true if you want official postgresql repository |
| postgresql_primary | bool | no | false | set true to create user and database on this server | | postgresql_primary | bool | no | false | set true to create user and database on this server |
| postgresql_config | dict | no | | add option config file | | postgresql_config | dict | no | | add option config file |
| postgresql_databases | array | no | | the database to manage | | postgresql_databases | array | no | | the database to manage |
| postgresql_users | dict | no | | the users to manage | | postgresql_users | dict | no | | the users to manage |
| postgresql_privileges | array | no | | set the privileges for roles | | postgresql_privileges | array | no | | set the privileges for roles |
| postgresql_hba | array | no | | the hba authorizations | | postgresql_hba | array | no | | the hba authorizations |
| postgresql_role_memberships | dict | no | | add membership in a role group | | postgresql_role_memberships | dict | no | | add membership in a role group |
### postgresql_config ### postgresql_config
@ -41,18 +41,16 @@ Example:
### postgresql_databases ### postgresql_databases
| Name | Type | Required | Default | Comment |
| Name | Type | Required | Default | Comment | | ---------- | ---- | -------- | --------- | --------------------------------- |
|------------|------|----------|-----------|-----------------------------------------------------| | name | str | yes | | the database name |
| name | str | yes | | the database name | | owner | str | yes | | the owner's database name |
| owner | str | yes | | the owner's database name | | encoding | str | no | UTF-8 | encoding to use |
| encoding | str | no | UTF-8 | encoding to use | | lc_collate | str | no | C.UTF-8 | lc_collate to use |
| lc_collate | str | no | C.UTF-8 | lc_collate to use | | lc_ctype | str | no | C.UTF-8 | lc_ctype to use |
| lc_ctype | str | no | C.UTF-8 | lc_ctype to use | | template | str | no | template0 | template to use |
| template | str | no | template0 | template to use |
| state | str | no | present | if absent the database is deleted | | state | str | no | present | if absent the database is deleted |
Example: Example:
``` ```
@ -65,7 +63,7 @@ Example:
### postgresql_users ### postgresql_users
| Name | Type | Required | Default | Comment | | Name | Type | Required | Default | Comment |
|------------|-------|----------|---------|---------------------------------------------------------------| | ---------- | ----- | -------- | ------- | ------------------------------------------------------------- |
| key | str | yes | | the user name | | key | str | yes | | the user name |
| password | str | yes | | the password to logon | | password | str | yes | | the password to logon |
| attributes | array | no | | list with the user's attributes (REPLICATION, SUPERUSER, ...) | | attributes | array | no | | list with the user's attributes (REPLICATION, SUPERUSER, ...) |
@ -83,14 +81,14 @@ Example:
### postgresql_privileges ### postgresql_privileges
| Name | Type | Required | Default | Comment | | Name | Type | Required | Default | Comment |
|------------|-------|----------|-------------------|---------------------------------------------------------------| | ---------- | ----- | -------- | ----------------- | ----------------------------------------------------------- |
| roles | str | yes | | the roles with this privileges | | roles | str | yes | | the roles with this privileges |
| database | str | yes | | the database where to apply the privileges | | database | str | yes | | the database where to apply the privileges |
| type | str | no | table | the type of privileges (table, function, schema, ...) | | type | str | no | table | the type of privileges (table, function, schema, ...) |
| objets | array | yes | ["ALL_IN_SCHEMA"] | list with the objets (ex: table name) | | objets | array | yes | ["ALL_IN_SCHEMA"] | list with the objets (ex: table name) |
| privileges | array | yes | | list with the privileges (SELECT, UPDATE, INSERT, ALL, ...) | | privileges | array | yes | | list with the privileges (SELECT, UPDATE, INSERT, ALL, ...) |
| state | str | no | present | if absent the privileges is deleted | | state | str | no | present | if absent the privileges is deleted |
Example: Example:
@ -108,13 +106,13 @@ Example:
### postgresql_hba ### postgresql_hba
| Name | Type | Required | Default | Comment | | Name | Type | Required | Default | Comment |
|-----------|-------|----------|---------|-------------------------------------------------------| | --------- | ----- | -------- | ------- | ------------------------------------------- |
| type | str | yes | | connection type (host, hostssl, local) | | type | str | yes | | connection type (host, hostssl, local) |
| databases | array | yes | | array with the database names or all string | | databases | array | yes | | array with the database names or all string |
| users | array | yes | | array with the user names or all string | | users | array | yes | | array with the user names or all string |
| subnet | str | no | | allow subnet, not require if type is local | | subnet | str | no | | allow subnet, not require if type is local |
| method | str | yes | | auth method (trust, md5, ...) | | method | str | yes | | auth method (trust, md5, ...) |
Example: Example:
@ -129,11 +127,11 @@ Example:
### postgresql_role_memberships ### postgresql_role_memberships
| Name | Type | Required | Default | Comment | | Name | Type | Required | Default | Comment |
|-----------|-------|----------|---------|------------------------------------------| | ------ | ----- | -------- | ------- | ---------------------------------------- |
| key | str | yes | | the role name | | key | str | yes | | the role name |
| groups | array | yes | | the groups (roles) where to add the role | | groups | array | yes | | the groups (roles) where to add the role |
| state | str | no | present | if absent the memberships are deleted | | state | str | no | present | if absent the memberships are deleted |
Example: Example:
@ -178,10 +176,10 @@ Example:
### Test with molecule and docker ### Test with molecule and docker
* install [docker](https://docs.docker.com/engine/installation/) - install [docker](https://docs.docker.com/engine/installation/)
* install `python3` and `python3-pip` - install `python3` and `python3-pip`
* install molecule and dependencies `pip3 install molecule molecule-docker docker ansible-lint testinfra yamllint` - install molecule and dependencies `pip3 install molecule molecule-docker docker ansible-lint testinfra yamllint`
* run `molecule test` - run `molecule test`
## License ## License

View file

@ -3,16 +3,7 @@ driver:
name: docker name: docker
platforms: platforms:
- name: debian12 - name: debian12
image: nishiki/debian12:molecule image: code.waks.be/nishiki/molecule:debian12
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
command: /bin/systemd
capabilities:
- SYS_ADMIN
- name: debian11
image: nishiki/debian11:molecule
privileged: true privileged: true
volumes: volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw - /sys/fs/cgroup:/sys/fs/cgroup:rw