Browse Source

Example used to setup gitea at git.bertieb.org

Only db password in vars/main.yml needs to be changed, works as-is
master
bertieb 2 months ago
commit
343af3228d
4 changed files with 64 additions and 0 deletions
  1. +4
    -0
      createdb/handlers/main.yml
  2. +47
    -0
      createdb/tasks/main.yml
  3. +9
    -0
      setup.yml
  4. +4
    -0
      vars/main.yml

+ 4
- 0
createdb/handlers/main.yml View File

@@ -0,0 +1,4 @@
---

- name: restart postgresql
service: name=postgresql state=restarted

+ 47
- 0
createdb/tasks/main.yml View File

@@ -0,0 +1,47 @@
---
- name: Ensure bash, OpenSSl, and libssl are the latest versions
apt:
pkg:
- bash
- openssl
- libssl-dev
- libssl-doc
state: latest
tags: packages

- name: Install PostgreSQL
apt:
pkg:
- postgresql
- postgresql-contrib
- libpq-dev
- python3-psycopg2
state: present
tags: packages

- name: Ensure the PostgreSQL service is running
service: name=postgresql state=started enabled=yes

- name: Ensure database is created
become: yes
become_user: postgres
postgresql_db: name={{ db_name }}
encoding='UTF-8'
template='template0'
state=present
- name: Ensure user has access to the database
become: yes
become_user: postgres
postgresql_user: db={{ db_name }}
name={{ db_user }}
password={{ db_password }}
priv=ALL
state=present

- name: Ensure user does not have unnecessary privileges
become: yes
become_user: postgres
postgresql_user: name={{ db_user }}
role_attr_flags=NOSUPERUSER,NOCREATEDB
state=present

+ 9
- 0
setup.yml View File

@@ -0,0 +1,9 @@
---
- name: Create a PostgreSQL DB server
hosts: all
remote_user: postgres
vars_files:
- vars/main.yml

roles:
- createdb

+ 4
- 0
vars/main.yml View File

@@ -0,0 +1,4 @@
---
db_user: postgres
db_name: gitea
db_password: CHANGEME

Loading…
Cancel
Save