This repository has been archived on 2020-10-27. You can view files and clone it, but cannot push or open issues or pull requests.
git.autonomic.zone/ansible/pre-deploy.yml

122 lines
3.4 KiB
YAML
Raw Normal View History

2020-03-19 00:46:09 +00:00
---
- hosts: all
2020-03-22 11:26:48 +00:00
gather_facts: false
2020-03-19 00:46:09 +00:00
tasks:
2020-03-21 00:48:23 +00:00
- name: Load variables
include_vars:
2020-03-22 10:53:49 +00:00
dir: "{{ dokku_lib_root }}/data/ansible/gitea/vars/"
extensions:
2020-03-22 10:54:58 +00:00
- yml
2020-03-22 10:53:49 +00:00
2020-03-22 11:39:40 +00:00
- name: Configure git.autonomic.zone domain
dokku_domains:
app: gitea
domains:
- git.autonomic.zone
state: present
2020-03-22 10:53:49 +00:00
- name: Create mariadb database
shell: "dokku mariadb:create gitea --password {{ db_passwd }} --root-password {{ root_db_passwd }}"
2020-03-22 10:53:49 +00:00
args:
creates: /var/lib/dokku/services/mariadb/gitea
2020-03-21 00:48:23 +00:00
- name: Setup host Gitea group
group:
name: gitea
system: true
state: present
2020-03-19 23:48:11 +00:00
become: true
- 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
2020-03-19 23:48:11 +00:00
become: true
- name: Get uid/guid of the gitea user
getent:
database: passwd
key: gitea
split: ":"
2020-03-19 23:48:11 +00:00
become: true
2020-03-22 11:14:54 +00:00
- name: Create volume mount configuration directories
2020-03-22 10:53:49 +00:00
file:
path: "{{ item }}"
state: directory
owner: dokku
group: dokku
with_items:
- /var/lib/gitea/gitea/
- /var/lib/gitea/gitea/conf
become: true
- name: Copy over app.ini gitea configuration
vars:
2020-03-22 11:19:19 +00:00
DISABLE_REGISTRATION: "true"
ENABLE_OPENID_SIGNIN: "true"
ENABLE_OPENID_SIGNUP: "false"
2020-03-22 10:53:49 +00:00
INTERNAL_TOKEN: "{{ internal_token }}"
JWT_SECRET: "{{ jwt_secret }}"
2020-03-22 11:19:19 +00:00
REQUIRE_SIGNIN_VIEW: "false"
ALLOW_ONLY_EXTERNAL_REGISTRATION: "true"
RUN_MODE: "prod"
2020-03-22 10:53:49 +00:00
SECRET_KEY: "{{ secret_key }}"
template:
src: app.ini.j2
dest: /var/lib/gitea/gitea/conf/app.ini
owner: dokku
group: dokku
become: true
- name: Specify docker volume mounts
dokku_storage:
app: gitea
mounts:
- /var/lib/gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
- /var/lib/dokku/services/mariadb/gitea:/var/lib/mysql
- 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 }}"
2020-03-22 10:53:49 +00:00
- name: Configure the docker env vars
dokku_config:
app: gitea
restart: false
config:
ADMIN_MAIL: "{{ autonomic_admin_mail }}"
ADMIN_PASS: "{{ autonomic_admin_pass }}"
2020-03-22 11:17:44 +00:00
ADMIN_USER: "{{ autonomic_admin_user }}"
2020-03-22 11:19:19 +00:00
DB_TYPE: "mysql"
2020-03-22 10:53:49 +00:00
DB_HOST: "dokku-mariadb-gitea:3306"
2020-03-22 11:19:19 +00:00
DB_NAME: "gitea"
DB_USER: "mariadb" # https://github.com/dokku/dokku-mariadb/issues/89
2020-03-22 10:53:49 +00:00
DB_PASSWD: "{{ db_passwd }}"
2020-03-22 11:20:17 +00:00
DISABLE_REGISTRATION: "true"
2020-03-22 11:19:19 +00:00
DOMAIN: "git.autonomic.zone"
2020-03-22 11:20:17 +00:00
INSTALL_LOCK: "true"
2020-03-22 11:19:19 +00:00
RUN_MODE: "prod"
2020-03-22 10:53:49 +00:00
USER_GID: "{{ gitea_user_guid }}"
USER_UID: "{{ gitea_user_uid }}"
2020-03-22 11:21:49 +00:00
DOKKU_LETSENCRYPT_EMAIL: "{{ autonomic_admin_mail }}"