1
1
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_gitea.git synced 2024-08-16 11:39:50 +02:00

gitea secrets aren't necessarily strings

fixes errors like 	fatal: [gitea]: FAILED! => {"msg": "The conditional check 'gitea_secret_key | length == 0' failed. The error was: Unexpected templating type error occurred on ({% if gitea_secret_key | length == 0 %} True {% else %} False {% endif %}): object of type 'AnsibleVaultEncryptedUnicode' has no len()
when using an encrypted string in vault for secrets
This commit is contained in:
Jens Timmerman 2021-09-24 11:50:31 +02:00 committed by GitHub
parent 9326cd01f1
commit ad24ff74f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,35 +4,35 @@
ansible.builtin.shell: 'umask 077; /usr/local/bin/gitea generate secret SECRET_KEY > /etc/gitea/gitea_secret_key' ansible.builtin.shell: 'umask 077; /usr/local/bin/gitea generate secret SECRET_KEY > /etc/gitea/gitea_secret_key'
args: args:
creates: '/etc/gitea/gitea_secret_key' creates: '/etc/gitea/gitea_secret_key'
when: gitea_secret_key | length == 0 when: gitea_secret_key | string | length == 0
- name: read gitea SECRET_KEY from file - name: read gitea SECRET_KEY from file
become: true become: true
ansible.builtin.slurp: ansible.builtin.slurp:
src: '/etc/gitea/gitea_secret_key' src: '/etc/gitea/gitea_secret_key'
register: remote_secret_key register: remote_secret_key
when: gitea_secret_key | length == 0 when: gitea_secret_key | string | length == 0
- name: set fact gitea_secret_key - name: set fact gitea_secret_key
ansible.builtin.set_fact: ansible.builtin.set_fact:
gitea_secret_key: "{{ remote_secret_key['content'] | b64decode }}" gitea_secret_key: "{{ remote_secret_key['content'] | b64decode }}"
when: gitea_secret_key | length == 0 when: gitea_secret_key | string | length == 0
- name: generate gitea INTERNAL_TOKEN if not provided - name: generate gitea INTERNAL_TOKEN if not provided
become: true become: true
ansible.builtin.shell: 'umask 077; /usr/local/bin/gitea generate secret INTERNAL_TOKEN > /etc/gitea/gitea_internal_token' ansible.builtin.shell: 'umask 077; /usr/local/bin/gitea generate secret INTERNAL_TOKEN > /etc/gitea/gitea_internal_token'
args: args:
creates: '/etc/gitea/gitea_internal_token' creates: '/etc/gitea/gitea_internal_token'
when: gitea_internal_token | length == 0 when: gitea_internal_token | string | length == 0
- name: read gitea INTERNAL_TOKEN from file - name: read gitea INTERNAL_TOKEN from file
become: true become: true
ansible.builtin.slurp: ansible.builtin.slurp:
src: '/etc/gitea/gitea_internal_token' src: '/etc/gitea/gitea_internal_token'
register: remote_internal_token register: remote_internal_token
when: gitea_internal_token | length == 0 when: gitea_internal_token | string | length == 0
- name: set fact gitea_internal_token - name: set fact gitea_internal_token
ansible.builtin.set_fact: ansible.builtin.set_fact:
gitea_internal_token: "{{ remote_internal_token['content'] | b64decode }}" gitea_internal_token: "{{ remote_internal_token['content'] | b64decode }}"
when: gitea_internal_token | length == 0 when: gitea_internal_token | string | length == 0