Skip to content

Commit

Permalink
tandoor: migrate away from settings.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
saltydk committed Nov 6, 2024
1 parent 6691584 commit 24cdaed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 0 additions & 2 deletions defaults/settings.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ sarotate:
rc_user:
rc_pass:
apprise:
tandoor:
secret_key:
tqm:
download_client: "qbt"
transmissionvpn:
Expand Down
2 changes: 1 addition & 1 deletion roles/tandoor/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ tandoor_docker_ports: "{{ tandoor_docker_ports_defaults
# Envs
tandoor_docker_envs_default:
TZ: "{{ tz }}"
SECRET_KEY: "{{ tandoor.secret_key }}"
SECRET_KEY: "{{ tandoor_saltbox_facts.facts.secret_key }}"
DB_ENGINE: "django.db.backends.postgresql"
POSTGRES_HOST: "postgres"
POSTGRES_PORT: "5432"
Expand Down
19 changes: 15 additions & 4 deletions roles/tandoor/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@
# GNU General Public License v3.0 #
#########################################################################
---
- name: Fail if secret_key has not been set
ansible.builtin.fail:
msg: "You need to edit 'tandoor.secret_key' in the settings.yml"
when: (tandoor.secret_key | default(None) | ternary('true', 'false') == 'false') and not continuous_integration
- name: "Save Tandoor Saltbox facts"
saltbox_facts:
role: "tandoor"
instance: "tandoor"
keys:
secret_key: "{{ tandoor.secret_key
if tandoor is defined and tandoor.secret_key is defined and tandoor.secret_key | length > 0
else lookup('ansible.builtin.password', '/dev/null', chars=['ascii_letters', 'digits'], length=50) }}"
owner: "{{ user.name }}"
group: "{{ user.name }}"
register: tandoor_saltbox_facts

- name: Remove legacy setting
ansible.builtin.shell: "yyq -i 'del(.tandoor)' {{ playbook_dir }}/settings.yml"
when: tandoor is defined

- name: PostgreSQL Role
ansible.builtin.include_role:
Expand Down

0 comments on commit 24cdaed

Please sign in to comment.