diff --git a/defaults/main.yml b/defaults/main.yml index 6e328fb..5fbacda 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -14,4 +14,6 @@ gitea_admin_username: testadmin gitea_admin_password: testadmin gitea_admin_email: admin@example.com -gitea_database_password: "{{ ansible_local.gitea.database_password }}" +gitea_db_name: gitea +gitea_db_user: gitea +gitea_db_pass: "{{ ansible_local.gitea.database_password }}" diff --git a/tasks/database.yaml b/tasks/database.yaml new file mode 100644 index 0000000..52dc195 --- /dev/null +++ b/tasks/database.yaml @@ -0,0 +1,16 @@ +--- + +- block: + + - name: postgresql user + postgresql_user: + name: "{{gitea_db_user}}" + password: "{{gitea_db_pass}}" + + - name: postgresql database + postgresql_db: + name: "{{gitea_db_name}}" + owner: "{{gitea_db_user}}" + + become: true + become_user: postgres diff --git a/tasks/main.yml b/tasks/main.yml index 7fac942..bf413fc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -4,6 +4,7 @@ - import_tasks: setup.yaml - import_tasks: download.yaml +- import_tasks: database.yaml - import_tasks: deploy.yml - name: flush handlers diff --git a/tasks/setup.yaml b/tasks/setup.yaml index 64033c2..e116f5b 100644 --- a/tasks/setup.yaml +++ b/tasks/setup.yaml @@ -7,3 +7,6 @@ - git - golang - gnupg + - postgresql + - python-psycopg2 + - autopostgresqlbackup diff --git a/vars/main.yml b/vars/main.yml index 3504231..fa2d3c4 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,5 +1,5 @@ _gitea_local_facts: - database_password: "{% if not ansible_local.gitea.database_password is defined %}{{ lookup('password', '/dev/null length=15 chars=ascii_letters') }}{% else %}{{ ansible_local.gitea.database_password }}{% endif %}" + database_password: "{% if not ansible_local.gitea.database_password is defined %}{{ lookup('password', '/dev/null length=16 chars=ascii_letters') }}{% else %}{{ ansible_local.gitea.database_password }}{% endif %}" _gitea_nginx_vhosts: - name: gitea @@ -45,11 +45,24 @@ _gitea_config: - section: database option: DB_TYPE - value: sqlite3 + value: postgres - section: database - option: PATH - value: "/var/lib/gitea/data/gitea.db" + option: HOST + value: localhost + #value: "/run/postgresql/" + + - section: database + option: NAME + value: "{{gitea_db_name}}" + + - section: database + option: USER + value: "{{gitea_db_user}}" + + - section: database + option: PASSWD + value: "{{gitea_db_pass}}" - section: log option: ROOT_PATH