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

152 lines
4.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
- name: Prepare Python system dependencies
2020-03-29 12:00:37 +00:00
become: true
apt:
name: python3-pip
2020-03-29 12:00:37 +00:00
state: present
- name: Install dns-lexicon[gandi] system wide
become: true
pip:
name: "{{ item }}"
executable: /usr/bin/pip3
2020-03-29 12:39:19 +00:00
state: present
with_items:
- cryptography==2.8
- dns-lexicon==3.3.19
2020-03-29 11:54:45 +00:00
- name: "Create {{ domain }} DNS entry"
gandi_dns:
gandi_rest_token: "{{ gandi_rest_token }}"
domain: "{{ domain }}"
ipv4: "{{ dokku_domain_ipv4 }}"
state: present
2020-03-24 12:47:53 +00:00
- name: "Configure the {{ domain }} domain"
2020-03-22 11:39:40 +00:00
dokku_domains:
app: gitea
domains:
2020-03-24 12:47:53 +00:00
- "{{ domain }}"
2020-03-22 11:39:40 +00:00
state: present
2020-03-22 10:53:49 +00:00
- name: Create mariadb database
2020-03-29 11:55:03 +00:00
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
2020-03-22 15:56:01 +00:00
- name: Link mariadb database to application
dokku_service_link:
2020-03-22 16:00:43 +00:00
app: gitea
name: gitea
2020-03-22 15:56:01 +00:00
service: mariadb
2020-03-29 11:55:11 +00:00
# - name: Authenticate with Minio back-end
# - name: Configure daily backup policy
# - name: Take pre-deploy backup
2020-03-23 15:21:12 +00:00
- name: Setup host git user
user:
2020-03-23 15:21:12 +00:00
name: git
comment: gitea user
create_home: true
2020-03-23 15:21:12 +00:00
home: /home/git
group: git
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
2020-03-23 15:21:12 +00:00
- name: Create application directories
2020-03-23 14:36:55 +00:00
file:
path: "{{ item }}"
state: directory
2020-03-23 15:21:12 +00:00
owner: git
group: git
2020-03-23 14:36:55 +00:00
with_items:
- /app
- /app/gitea
2020-03-23 15:21:12 +00:00
- /var/lib/gitea
2020-03-23 14:36:55 +00:00
become: true
2020-03-23 15:21:12 +00:00
- name: Get uid/guid of the git user
getent:
database: passwd
2020-03-23 15:21:12 +00:00
key: git
split: ":"
2020-03-19 23:48:11 +00:00
become: true
2020-03-22 10:53:49 +00:00
- 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
2020-03-23 14:38:31 +00:00
- /var/lib/gitea/.ssh:/data/git/.ssh
2020-03-22 10:53:49 +00:00
- name: Store gitea git user uid/guid
set_fact:
2020-03-23 15:21:44 +00:00
git_user_uid: "{{ getent_passwd['git'][1] }}"
git_user_guid: "{{ getent_passwd['git'][2] }}"
- name: Configure the dokku app environment
2020-03-22 10:53:49 +00:00
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-23 13:58:21 +00:00
ALLOW_ONLY_EXTERNAL_REGISTRATION: "{{ allow_only_external_registration }}"
2020-03-23 13:30:20 +00:00
APP_NAME: "{{ autonomic_app_name }}"
AUTHOR: "{{ author }}"
2020-03-22 16:09:29 +00:00
DB_HOST: "dokku-mariadb-gitea:3306"
2020-03-22 11:19:19 +00:00
DB_NAME: "gitea"
2020-03-22 10:53:49 +00:00
DB_PASSWD: "{{ db_passwd }}"
2020-03-22 15:57:56 +00:00
DB_TYPE: "mysql"
DB_USER: "mariadb" # https://github.com/dokku/dokku-mariadb/issues/89
2020-03-23 13:30:20 +00:00
DESCRIPTION: "{{ description }}"
2020-03-23 14:01:06 +00:00
DISABLE_REGISTRATION: "{{ disable_registration }}"
2020-03-22 15:57:56 +00:00
DOKKU_LETSENCRYPT_EMAIL: "{{ autonomic_admin_mail }}"
2020-03-23 13:30:20 +00:00
DOMAIN: "{{ domain }}"
ENABLE_OPENID_SIGNIN: "{{ enable_openid_signin }}"
ENABLE_OPENID_SIGNUP: "{{ enable_openid_signup }}"
2020-03-28 15:36:13 +00:00
GITEA_THEME: "{{ gitea_theme }}"
2020-03-25 10:43:22 +00:00
HTTP_PORT: "{{ http_port }}"
2020-03-23 13:30:20 +00:00
INSTALL_LOCK: "{{ install_lock }}"
2020-03-22 16:53:12 +00:00
JWT_SECRET: "{{ jwt_secret }}"
2020-03-27 17:40:10 +00:00
MAILER_ENABLED: "{{ mailer_enabled }}"
2020-03-22 11:19:19 +00:00
RUN_MODE: "prod"
2020-03-22 16:53:12 +00:00
SECRET_KEY: "{{ secret_key}}"
2020-03-27 17:40:10 +00:00
SMTP_FROM: "{{ smtp_from }}"
SMTP_HOST: "{{ smtp_host }}"
2020-03-27 18:35:50 +00:00
SMTP_MAILER_TYPE: "{{ smtp_mailer_type }}"
SMTP_PASSWD: "{{ smtp_passwd }}"
2020-03-27 17:40:10 +00:00
SMTP_TLS_ENABLED: "{{ smtp_tls_enabled }}"
SMTP_USER: "{{ smtp_user }}"
2020-03-23 14:19:29 +00:00
SSH_DOMAIN: "{{ ssh_domain }}"
2020-03-23 15:28:11 +00:00
SSH_LISTEN_PORT: "{{ ssh_listen_port }}"
SSH_PORT: "{{ ssh_port }}"
2020-03-23 13:30:20 +00:00
STARTUP_TIMEOUT: "{{ startup_timeout }}"
2020-03-23 15:21:44 +00:00
USER_GID: "{{ git_user_guid }}"
USER_UID: "{{ git_user_uid }}"
2020-03-23 13:30:20 +00:00
WHITELIST_URIS: "{{ whitelist_uris }}"