diff --git a/ansible/pre-deploy.yml b/ansible/pre-deploy.yml index eb7e847..9ddd6e4 100644 --- a/ansible/pre-deploy.yml +++ b/ansible/pre-deploy.yml @@ -1,5 +1,42 @@ --- - hosts: all tasks: - - name: Echo test - shell: echo 'pre-deploy!' + - name: Setup host Gitea group + group: + name: gitea + system: true + state: present + + - name: Setup host Gitea user + user: + name: gitea + comment: gitea user + create_home: true + home: /var/lib/gitea + group: gitea + system: true + state: present + generate_ssh_key: true + ssh_key_bits: 2048 + ssh_key_file: .ssh/id_rsa + + - name: Get uid/guid of the gitea user + getent: + database: passwd + key: gitea + split: ":" + + - name: Store gitea git user uid/guid + set_fact: + gitea_user_uid: "{{ getent_passwd['gitea'][1] }}" + gitea_user_guid: "{{ getent_passwd['gitea'][2] }}" + + - name: Configure the dokku app environment + dokku_config: + app: gitea + restart: false + config: + USER_GID: "{{ gitea_user_guid }}" + USER_UID: "{{ gitea_user_uid }}" + become: true + become_user: dokku