mirror of
https://github.com/roles-ansible/ansible_collection_pretix.git
synced 2024-10-28 22:01:03 +01:00
start creating database and update pretix users
This commit is contained in:
parent
dd10d1a078
commit
2e6f30c157
10 changed files with 157 additions and 0 deletions
3
roles/postgres/defaults/main.yml
Normal file
3
roles/postgres/defaults/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
# Optional perform simple Versionscheck
|
||||||
|
packages__submodules_versioncheck: false
|
1
roles/postgres/tasks/create_database.yml
Normal file
1
roles/postgres/tasks/create_database.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
---
|
21
roles/postgres/tasks/main.yml
Normal file
21
roles/postgres/tasks/main.yml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
---
|
||||||
|
- name: Run simple versionscheck (optional)
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: 'versioncheck.yml'
|
||||||
|
when: packages__submodules_versioncheck | bool
|
||||||
|
|
||||||
|
- name: Make sure postgres is installed
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: 'packages.yml'
|
||||||
|
when:
|
||||||
|
- ansible_pkg_mgr == "apt"
|
||||||
|
|
||||||
|
- name: Only apt is supported
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: "Only debian based systems using apt are supported"
|
||||||
|
when:
|
||||||
|
- not ansible_pkg_mgr == "apt"
|
||||||
|
|
||||||
|
- name: Create pretix Configuration
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: 'create_database.yml'
|
43
roles/postgres/tasks/packages.yml
Normal file
43
roles/postgres/tasks/packages.yml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
---
|
||||||
|
- name: Update apt repo-cache on debian/ubuntu hosts
|
||||||
|
become: true
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
cache_valid_time: 3600
|
||||||
|
|
||||||
|
- name: Install Required packages
|
||||||
|
become: true
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: 'apt-tansport-https'
|
||||||
|
state: 'present'
|
||||||
|
|
||||||
|
- name: Create directory for PostgreSQL repository key
|
||||||
|
become: true
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: 'directory'
|
||||||
|
mode: '0755'
|
||||||
|
owner: 'root'
|
||||||
|
group: 'root'
|
||||||
|
with_items:
|
||||||
|
- '/usr/share/postgresql-common'
|
||||||
|
- '/usr/share/postgresql-common/pgdg'
|
||||||
|
|
||||||
|
- name: Download the PostgreSQL signing key
|
||||||
|
get_url:
|
||||||
|
url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
|
||||||
|
dest: '/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc'
|
||||||
|
|
||||||
|
#- name: Create the PostgreSQL repository configuration
|
||||||
|
# shell: echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
|
||||||
|
#
|
||||||
|
#- name: Update apt cache
|
||||||
|
# apt:
|
||||||
|
# update_cache: yes
|
||||||
|
#
|
||||||
|
#- name: Install PostgreSQL
|
||||||
|
# apt:
|
||||||
|
# name: postgresql
|
||||||
|
# state: present
|
||||||
|
# update_cache: yes
|
||||||
|
# install_recommends: yes
|
44
roles/postgres/tasks/versioncheck.yml
Normal file
44
roles/postgres/tasks/versioncheck.yml
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
---
|
||||||
|
# Copyright (c) 2021 L3D <l3d@c3woc.de>
|
||||||
|
# this file is released with the MIT license.
|
||||||
|
# License: https://github.com/roles-ansible/ansible_role_template/blob/main/LICENSE
|
||||||
|
- name: Create directory for versionscheck
|
||||||
|
become: true
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: '/etc/.ansible-version'
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
when: packages__submodules_versioncheck | bool
|
||||||
|
|
||||||
|
- name: Check playbook version
|
||||||
|
become: true
|
||||||
|
ansible.builtin.slurp:
|
||||||
|
src: "/etc/.ansible-version/{{ packages__playbook_version_path }}"
|
||||||
|
register: playbook_version
|
||||||
|
when: packages__submodules_versioncheck | bool
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
|
- name: Print remote role version # noqa: H500
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "Remote role version: {{ playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}"
|
||||||
|
when: packages__submodules_versioncheck | bool
|
||||||
|
|
||||||
|
- name: Print locale role version # noqa: H500
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "Local role version: '{{ packages__playbook_version_number | string }}'."
|
||||||
|
when: packages__submodules_versioncheck | bool
|
||||||
|
|
||||||
|
- name: Check if your version is outdated
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: "Your ansible module has the version '{{ packages__playbook_version_number }}' and is outdated. You need to update it!"
|
||||||
|
when:
|
||||||
|
- playbook_version.content|default("Mgo=")|b64decode|int - 1 >= packages__playbook_version_number|int and packages__submodules_versioncheck | bool
|
||||||
|
|
||||||
|
- name: Write new version to remote disk
|
||||||
|
become: true
|
||||||
|
ansible.builtin.copy:
|
||||||
|
content: "{{ packages__playbook_version_number }}"
|
||||||
|
dest: "/etc/.ansible-version/{{ packages__playbook_version_path }}"
|
||||||
|
mode: '0644'
|
||||||
|
when: packages__submodules_versioncheck | bool
|
||||||
|
tags: skip_ansible_lint_template-instead-of-copy
|
5
roles/postgres/vars/main.yml
Normal file
5
roles/postgres/vars/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
postgres__packages: []
|
||||||
|
|
||||||
|
packages__playbook_version_number: 3
|
||||||
|
packages__playbook_version_path: 'l3d.pretix.postgres.version'
|
|
@ -1,6 +1,7 @@
|
||||||
---
|
---
|
||||||
pretix__user: 'pretix'
|
pretix__user: 'pretix'
|
||||||
pretix__group: "{{ pretix__user }}"
|
pretix__group: "{{ pretix__user }}"
|
||||||
|
pretix__home: '/var/lib/pretix'
|
||||||
|
|
||||||
# Optional perform simple Versionscheck
|
# Optional perform simple Versionscheck
|
||||||
packages__submodules_versioncheck: false
|
packages__submodules_versioncheck: false
|
||||||
|
|
3
roles/pretix/tasks/configure.yml
Normal file
3
roles/pretix/tasks/configure.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
- name: Create directory for pretiy config
|
||||||
|
become: true
|
|
@ -11,3 +11,7 @@
|
||||||
- name: Install required packages
|
- name: Install required packages
|
||||||
ansible.builtin.include_tasks:
|
ansible.builtin.include_tasks:
|
||||||
file: 'packages.yml'
|
file: 'packages.yml'
|
||||||
|
|
||||||
|
- name: Create pretix Configuration
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: 'configure.yml'
|
||||||
|
|
32
roles/pretix/templates/pretix.cfg.j2
Normal file
32
roles/pretix/templates/pretix.cfg.j2
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
{{ ansible_managed | ansible.builtin.comment(decoration=';') }}
|
||||||
|
|
||||||
|
[pretix]
|
||||||
|
instance_name=My pretix installation
|
||||||
|
url=https://pretix.mydomain.com
|
||||||
|
currency=EUR
|
||||||
|
datadir=/var/pretix/data
|
||||||
|
trust_x_forwarded_for=on
|
||||||
|
trust_x_forwarded_proto=on
|
||||||
|
|
||||||
|
[database]
|
||||||
|
backend=postgresql
|
||||||
|
name=pretix
|
||||||
|
user=pretix
|
||||||
|
; For PostgreSQL on the same host, we don't need a password because we can use
|
||||||
|
; peer authentication if our PostgreSQL user matches our unix user.
|
||||||
|
password=
|
||||||
|
; For local postgres authentication, you can leave it empty
|
||||||
|
host=
|
||||||
|
|
||||||
|
[mail]
|
||||||
|
; See config file documentation for more options
|
||||||
|
from=tickets@yourdomain.com
|
||||||
|
host=127.0.0.1
|
||||||
|
|
||||||
|
[redis]
|
||||||
|
location=redis://127.0.0.1/0
|
||||||
|
sessions=true
|
||||||
|
|
||||||
|
[celery]
|
||||||
|
backend=redis://127.0.0.1/1
|
||||||
|
broker=redis://127.0.0.1/2
|
Loading…
Reference in a new issue