Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
ansible
Manage
Activity
Members
Labels
Plan
Issues
13
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
funkwhale
ansible
Commits
4f5a8b95
Commit
4f5a8b95
authored
5 years ago
by
Jean
Committed by
Eliot Berriot
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add possibility to handle remote managed postgresql setup
parent
41e3bd9e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
defaults/main.yml
+14
-1
14 additions, 1 deletion
defaults/main.yml
tasks/db.yml
+35
-22
35 additions, 22 deletions
tasks/db.yml
tasks/main.yml
+10
-0
10 additions, 0 deletions
tasks/main.yml
templates/env.j2
+1
-1
1 addition, 1 deletion
templates/env.j2
with
60 additions
and
24 deletions
defaults/main.yml
+
14
−
1
View file @
4f5a8b95
...
@@ -8,10 +8,23 @@ funkwhale_config_path: /srv/funkwhale/config
...
@@ -8,10 +8,23 @@ funkwhale_config_path: /srv/funkwhale/config
funkwhale_external_storage_enabled
:
false
funkwhale_external_storage_enabled
:
false
funkwhale_disable_django_admin
:
false
funkwhale_disable_django_admin
:
false
funkwhale_username
:
funkwhale
funkwhale_username
:
funkwhale
funkwhale_database_managed
:
true
funkwhale_frontend_managed
:
true
funkwhale_frontend_managed
:
true
funkwhale_database_managed
:
true
funkwhale_database_local
:
true
funkwhale_database_name
:
funkwhale
funkwhale_database_name
:
funkwhale
funkwhale_database_user
:
funkwhale
funkwhale_database_user
:
funkwhale
# the DB host as per your ansible inventory
funkwhale_database_host_ansible
:
localhost
# the DB FQDN or IP for funkwhale connector configuration (ex: pg01.local)
funkwhale_database_host_app
:
localhost
funkwhale_database_port
:
5432
# ↓ Only needed if 'funkwhale_database_managed' == false
# ↓ This is also assuming DB and user have already been set up, outside of the playbook.
# ↓ Considering the playbook handles both local and remote PostGreSQL server types, this should typically not be required.
#funkwhale_database_url: postgresql://{{ funkwhale_database_user }}[:{{ funkwhale_database_password }}]@[{{ funkwhale_database_host_app }}]:{{ funkwhale_database_port | default(5432) }}/{{ funkwhale_database_name }}
funkwhale_nginx_managed
:
true
funkwhale_nginx_managed
:
true
funkwhale_nginx_max_body_size
:
100M
funkwhale_nginx_max_body_size
:
100M
funkwhale_redis_managed
:
true
funkwhale_redis_managed
:
true
...
...
This diff is collapsed.
Click to expand it.
tasks/db.yml
+
35
−
22
View file @
4f5a8b95
---
---
-
name
:
"
Install
postgresql"
-
name
:
"
Install
postgresql"
become
:
true
become
:
true
when
:
funkwhale_database_managed
when
:
funkwhale_database_managed
and funkwhale_database_local
package
:
package
:
name
:
name
:
-
postgresql
-
postgresql
-
python3-psycopg2
-
python3-psycopg2
-
name
:
"
Start
Postgresql"
-
name
:
"
Start
Postgresql"
when
:
funkwhale_database_managed
when
:
funkwhale_database_managed
and funkwhale_database_local
service
:
service
:
name
:
postgresql
name
:
postgresql
state
:
started
state
:
started
-
name
:
"
Create
{{
funkwhale_database_
name
}}
database"
-
name
:
"
Create
{{
funkwhale_database_
user
}}
database
user
on
{{
funkwhale_database_host_ansible
}}
(local
/
passwordless)
"
become
:
true
become
:
true
become_user
:
postgres
become_user
:
postgres
when
:
funkwhale_database_managed
when
:
funkwhale_database_managed
and funkwhale_database_host_ansible == 'localhost'
postgresql_
db
:
postgresql_
user
:
name
:
"
{{
funkwhale_database_
name
}}"
name
:
"
{{
funkwhale_database_
user
}}"
encoding
:
UTF-8
login_user
:
postgres
template
:
template0
delegate_to
:
"
{{
funkwhale_database_host_ansible
}}"
-
name
:
"
Create
{{
funkwhale_database_user
}}
database
user"
-
name
:
"
Create
{{
funkwhale_database_user
}}
database
user
on
{{
funkwhale_database_host_ansible
}}
(remote
/
with
password)
"
become
:
true
become
:
true
become_user
:
postgres
become_user
:
postgres
when
:
funkwhale_database_managed
when
:
funkwhale_database_managed
and funkwhale_database_host_ansible != 'localhost'
postgresql_user
:
postgresql_user
:
db
:
"
{{
funkwhale_database_name
}}"
name
:
"
{{
funkwhale_database_user
}}"
name
:
"
{{
funkwhale_database_user
}}"
password
:
"
{{
funkwhale_database_password
}}"
login_user
:
postgres
delegate_to
:
"
{{
funkwhale_database_host_ansible
}}"
-
name
:
"
Grant
privileges
on
database
{{
funkwhale_database_name
}}
to
{{
funkwhale_database_user
}}
user"
-
name
:
"
Create
{{
funkwhale_database_name
}}
database
on
{{
funkwhale_database_host_ansible
}}"
when
:
funkwhale_database_managed
become
:
true
become
:
true
become_user
:
postgres
become_user
:
postgres
command
:
psql -c "GRANT ALL PRIVILEGES ON DATABASE {{ funkwhale_database_name }} TO {{ funkwhale_database_user }}"
-
name
:
"
Create
db
extensions"
when
:
funkwhale_database_managed
when
:
funkwhale_database_managed
become
:
true
postgresql_db
:
name
:
"
{{
funkwhale_database_name
}}"
login_user
:
postgres
owner
:
"
{{
funkwhale_database_user
}}"
encoding
:
UTF-8
template
:
template0
delegate_to
:
"
{{
funkwhale_database_host_ansible
}}"
-
name
:
set up pgsql extensions
become
:
yes
become_user
:
postgres
become_user
:
postgres
command
:
psql {{ funkwhale_database_name }} -c "CREATE EXTENSION IF NOT EXISTS {{ item }}"
when
:
funkwhale_database_managed
with_items
:
postgresql_ext
:
-
unaccent
db
:
"
{{
funkwhale_database_name
}}"
-
citext
name
:
"
{{
myext
}}"
login_user
:
postgres
loop
:
[
'
unaccent'
,
'
citext'
]
loop_control
:
loop_var
:
myext
delegate_to
:
"
{{
funkwhale_database_host_ansible
}}"
...
This diff is collapsed.
Click to expand it.
tasks/main.yml
+
10
−
0
View file @
4f5a8b95
---
---
-
name
:
set a password for postgresql DB (remote psql server only)
tags
:
[
db
]
set_fact
:
# Look up for the key 'vault_funkwhale_database_password' (for you to create, ideally in a vault).
# If no key is found,it will search inside ./pgsql_funkwhale.credentials.txt.
# If ./pgsql_funkwhale.credentials.txt does not exist, it generates a random password and write it there.
funkwhale_database_password
:
"
{{
vault_funkwhale_database_password
|
default(lookup('password',
'./%s.credentials.txt
chars=ascii_letters,digits
length=20'
%
'pgsql_funkwhale'))
}}"
# If 'funkwhale_database_local:' == true, funkwhale will connect via unix socket (no password needed).
when
:
not funkwhale_database_local
-
name
:
"
Set
frontend
path"
-
name
:
"
Set
frontend
path"
when
:
funkwhale_frontend_managed
when
:
funkwhale_frontend_managed
tags
:
[
funkwhale
,
nginx
]
tags
:
[
funkwhale
,
nginx
]
...
...
This diff is collapsed.
Click to expand it.
templates/env.j2
+
1
−
1
View file @
4f5a8b95
...
@@ -10,7 +10,7 @@ FUNKWHALE_WEB_WORKERS={{ funkwhale_web_workers }}
...
@@ -10,7 +10,7 @@ FUNKWHALE_WEB_WORKERS={{ funkwhale_web_workers }}
REVERSE_PROXY_TYPE=nginx
REVERSE_PROXY_TYPE=nginx
{% if funkwhale_database_managed %}
{% if funkwhale_database_managed %}
DATABASE_URL=postgresql://{{ funkwhale_database_user }}
@:5432
/{{ funkwhale_database_name }}
DATABASE_URL=postgresql://{{ funkwhale_database_user }}
{%- if funkwhale_database_password is defined -%}:{{ funkwhale_database_password }}{%- endif -%}@{%- if funkwhale_database_host_app != 'localhost' -%}{{ funkwhale_database_host_app }}{%- endif -%}:{{ funkwhale_database_port }}
/{{ funkwhale_database_name }}
{% else %}
{% else %}
DATABASE_URL={{ funkwhale_database_url }}
DATABASE_URL={{ funkwhale_database_url }}
{% endif %}
{% endif %}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment