publish on github
This commit is contained in:
commit
4ead2f82c9
29
.travis.yml
Normal file
29
.travis.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
language: python
|
||||||
|
python: "2.7"
|
||||||
|
|
||||||
|
# Use the new container infrastructure
|
||||||
|
sudo: false
|
||||||
|
|
||||||
|
# Install ansible
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- python-pip
|
||||||
|
|
||||||
|
install:
|
||||||
|
# Install ansible
|
||||||
|
- pip install ansible
|
||||||
|
|
||||||
|
# Check ansible version
|
||||||
|
- ansible --version
|
||||||
|
|
||||||
|
# Create ansible.cfg with correct roles_path
|
||||||
|
- printf '[defaults]\nroles_path=../' >ansible.cfg
|
||||||
|
|
||||||
|
script:
|
||||||
|
# Basic role syntax check
|
||||||
|
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||||
33
.yamllint
Normal file
33
.yamllint
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
# Based on ansible-lint config
|
||||||
|
extends: default
|
||||||
|
|
||||||
|
rules:
|
||||||
|
braces:
|
||||||
|
max-spaces-inside: 1
|
||||||
|
level: error
|
||||||
|
brackets:
|
||||||
|
max-spaces-inside: 1
|
||||||
|
level: error
|
||||||
|
colons:
|
||||||
|
max-spaces-after: -1
|
||||||
|
level: error
|
||||||
|
commas:
|
||||||
|
max-spaces-after: -1
|
||||||
|
level: error
|
||||||
|
comments: disable
|
||||||
|
comments-indentation: disable
|
||||||
|
document-start: disable
|
||||||
|
empty-lines:
|
||||||
|
max: 3
|
||||||
|
level: error
|
||||||
|
hyphens:
|
||||||
|
level: error
|
||||||
|
indentation: disable
|
||||||
|
key-duplicates: enable
|
||||||
|
line-length: disable
|
||||||
|
new-line-at-end-of-file: disable
|
||||||
|
new-lines:
|
||||||
|
type: unix
|
||||||
|
trailing-spaces: disable
|
||||||
|
truthy: disable
|
||||||
38
README.md
Normal file
38
README.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
Ansible Postgresql
|
||||||
|
=========
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
no requirements
|
||||||
|
|
||||||
|
Example Playbook
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
||||||
|
```yaml
|
||||||
|
- hosts: servers
|
||||||
|
roles:
|
||||||
|
- role: ansible-postgres
|
||||||
|
postgres_version: 13
|
||||||
|
pg_hba_user_options:
|
||||||
|
- contype: host
|
||||||
|
users: all
|
||||||
|
source: 127.0.0.1/32
|
||||||
|
databases: all
|
||||||
|
method: md5
|
||||||
|
```
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
MIT
|
||||||
|
|
||||||
|
## Devel
|
||||||
|
for devel use
|
||||||
|
https://github.com/ansible-community/molecule-libvirt
|
||||||
|
|
||||||
|
requirements for testings
|
||||||
|
KVM host
|
||||||
|
```
|
||||||
|
libvirt-python
|
||||||
|
```
|
||||||
26
defaults/main.yml
Normal file
26
defaults/main.yml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
# defaults file for postgres
|
||||||
|
postgres_repo: 'https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm'
|
||||||
|
postgres_version: 13
|
||||||
|
|
||||||
|
pg_hba_user_options:
|
||||||
|
- contype: host
|
||||||
|
users: all
|
||||||
|
source: 127.0.0.1/32
|
||||||
|
databases: all
|
||||||
|
method: md5
|
||||||
|
- contype: host
|
||||||
|
users: all
|
||||||
|
source: 192.168.100.10/24
|
||||||
|
databases: all
|
||||||
|
method: md5
|
||||||
|
- contype: host
|
||||||
|
users: all
|
||||||
|
source: 192.168.200.1/24
|
||||||
|
databases: all
|
||||||
|
method: md5
|
||||||
|
- contype: host
|
||||||
|
users: all
|
||||||
|
source: 192.169.100.1/24
|
||||||
|
databases: all
|
||||||
|
method: md5
|
||||||
17
handlers/main.yml
Normal file
17
handlers/main.yml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
# handlers file for postgres
|
||||||
|
- name: start postgreql
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
state: started
|
||||||
|
name: "postgresql-{{postgres_version}}"
|
||||||
|
enabled: yes
|
||||||
|
|
||||||
|
- name: restart postgreql
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
state: restarted
|
||||||
|
name: "postgresql-{{postgres_version}}"
|
||||||
|
|
||||||
|
- name: reloaded postgreql
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
state: reloaded
|
||||||
|
name: "postgresql-{{postgres_version}}"
|
||||||
31
meta/main.yml
Normal file
31
meta/main.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
galaxy_info:
|
||||||
|
role_name: role-postgres
|
||||||
|
author: Attilio Greco
|
||||||
|
description: install postgres in REHL family
|
||||||
|
company: your company (optional)
|
||||||
|
|
||||||
|
# If the issue tracker for your role is not on github, uncomment the
|
||||||
|
# next line and provide a value
|
||||||
|
# issue_tracker_url: http://example.com/issue/tracker
|
||||||
|
|
||||||
|
license: MIT
|
||||||
|
|
||||||
|
min_ansible_version: 4
|
||||||
|
|
||||||
|
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||||
|
# min_ansible_container_version:
|
||||||
|
|
||||||
|
#
|
||||||
|
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||||
|
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||||
|
# To view available platforms and versions (or releases), visit:
|
||||||
|
# https://galaxy.ansible.com/api/v1/platforms/
|
||||||
|
#
|
||||||
|
platforms:
|
||||||
|
- name: Rocky linux
|
||||||
|
versions:
|
||||||
|
- 8.4
|
||||||
|
|
||||||
|
galaxy_tags: [database, postgres]
|
||||||
|
|
||||||
|
dependencies: []
|
||||||
11
molecule/default/INSTALL.rst
Normal file
11
molecule/default/INSTALL.rst
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
*********************************
|
||||||
|
LibVirt driver installation guide
|
||||||
|
*********************************
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
============
|
||||||
|
|
||||||
|
* Configure libvirt
|
||||||
|
|
||||||
|
Install
|
||||||
|
=======
|
||||||
8
molecule/default/converge.yml
Normal file
8
molecule/default/converge.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: "Include postgres"
|
||||||
|
include_role:
|
||||||
|
name: "postgres"
|
||||||
13
molecule/default/molecule.yml
Normal file
13
molecule/default/molecule.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: libvirt
|
||||||
|
platforms:
|
||||||
|
- name: instance-1
|
||||||
|
image_url: "http://remoteshare.4sigma.top/Rocky8.4-try-srinked.qcow2"
|
||||||
|
disk_size: "10G"
|
||||||
|
memory_size: "1" # in GB
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
verifier:
|
||||||
|
name: ansible
|
||||||
6
molecule/default/playbook.yml
Normal file
6
molecule/default/playbook.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
become: yes
|
||||||
|
roles:
|
||||||
|
- role: postgres
|
||||||
18
molecule/default/prepare.yml
Normal file
18
molecule/default/prepare.yml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
- name: prepare
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: prepare | install python3-pip
|
||||||
|
dnf:
|
||||||
|
name:
|
||||||
|
- python3-pip
|
||||||
|
- python3-devel
|
||||||
|
- gcc
|
||||||
|
|
||||||
|
- name: prepare | create ansible requirements
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /home/molecule/ansible
|
||||||
|
state: directory
|
||||||
|
owner: molecule
|
||||||
|
group: molecule
|
||||||
|
mode: '0644'
|
||||||
12
molecule/default/verify.yml
Normal file
12
molecule/default/verify.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
# This is an example playbook to execute Ansible tests.
|
||||||
|
|
||||||
|
- name: Verify
|
||||||
|
hosts: all
|
||||||
|
vars:
|
||||||
|
ansible_python_interpreter:
|
||||||
|
tasks:
|
||||||
|
- name: Verify | check postgres is running
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: postgresql-13.service
|
||||||
|
state: started
|
||||||
12
tasks/configure_postgres.yml
Normal file
12
tasks/configure_postgres.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
- name: Grant users joe and simon access to databases sales and logistics from ipv6 localhost ::1/128 using peer authentication
|
||||||
|
community.postgresql.postgresql_pg_hba:
|
||||||
|
dest: /var/lib/pgsql/{{postgres_version}}/data/pg_hba.conf
|
||||||
|
contype: "{{ item.contype }}"
|
||||||
|
users: "{{ item.users }}"
|
||||||
|
source: "{{ item.source }}"
|
||||||
|
databases: "{{ item.databases }}"
|
||||||
|
method: "{{ item.method }}"
|
||||||
|
create: true
|
||||||
|
loop: "{{pg_hba_user_options}}"
|
||||||
|
notify:
|
||||||
|
- reloaded postgreql
|
||||||
12
tasks/init_postgres.yml
Normal file
12
tasks/init_postgres.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
- name: postgres | init_postgres | init database
|
||||||
|
ansible.builtin.command: /usr/pgsql-{{postgres_version}}/bin/postgresql-{{postgres_version}}-setup initdb
|
||||||
|
register: postgresql_database_init
|
||||||
|
args:
|
||||||
|
creates: /var/lib/pgsql/13/initdb.log
|
||||||
|
notify:
|
||||||
|
- start postgreql
|
||||||
|
|
||||||
|
- name: postgres | init_postgres | show posgres init
|
||||||
|
debug:
|
||||||
|
var: postgresql_database_init
|
||||||
19
tasks/install.yml
Normal file
19
tasks/install.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
- name: postgres | install | install postgres repo
|
||||||
|
dnf:
|
||||||
|
name: 'https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm'
|
||||||
|
state: present
|
||||||
|
disable_gpg_check: yes
|
||||||
|
|
||||||
|
- name: postgres | install | disable postgresql module
|
||||||
|
ansible.builtin.command: dnf -qy module disable postgresql
|
||||||
|
register: postgresql_disable_repo
|
||||||
|
args:
|
||||||
|
creates: /etc/dnf/modules.d/postgresql.module
|
||||||
|
|
||||||
|
- name: postgres | install | install postgresql
|
||||||
|
dnf:
|
||||||
|
name:
|
||||||
|
- postgresql{{postgres_version}}
|
||||||
|
- postgresql{{postgres_version}}-server
|
||||||
|
state: present
|
||||||
4
tasks/main.yml
Normal file
4
tasks/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
- import_tasks: tasks/install.yml
|
||||||
|
- import_tasks: tasks/init_postgres.yml
|
||||||
|
- import_tasks: configure_postgres.yml
|
||||||
8
templates/pg_hba.conf.j2
Normal file
8
templates/pg_hba.conf.j2
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# TYPE DATABASE USER ADDRESS METHOD
|
||||||
|
{% for option_line in pg_hba_user_options -%}
|
||||||
|
{{ " " + option_line.type }} {{ option_line.database }} {{ option_line.user }} {{ option_line.address }} {{ option_line.method }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% for option_line in pg_hba_default_options -%}
|
||||||
|
{{ " " + option_line.type }} {{ option_line.database }} {{ option_line.user }} {{ option_line.address }} {{ option_line.method }}
|
||||||
|
{% endfor %}
|
||||||
2
tests/inventory
Normal file
2
tests/inventory
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
||||||
5
tests/test.yml
Normal file
5
tests/test.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- postgres
|
||||||
2
vars/main.yml
Normal file
2
vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for postgres
|
||||||
Loading…
Reference in New Issue
Block a user