websoft9/apps/application.yml

67 lines
2.0 KiB
YAML
Raw Normal View History

2022-06-27 09:18:46 +08:00
- name: Deploy Application
2022-05-10 17:35:30 +08:00
hosts: all
become: yes
become_method: sudo
vars_files:
- vars/main.yml
2022-07-05 10:38:57 +08:00
- roles/{{appname}}/vars/main.yml
- roles/{{appname}}/defaults/main.yml
2022-05-11 17:39:42 +08:00
pre_tasks:
2022-07-05 16:54:57 +08:00
- name: Excute base roles for apps
2022-05-13 08:59:20 +08:00
block:
2022-06-30 17:45:00 +08:00
- name: Include base roles
include_role:
name: "{{item}}"
with_items:
2022-07-01 09:10:45 +08:00
- role_common
- role_cloud
2022-07-01 09:14:05 +08:00
2022-07-05 16:54:57 +08:00
- name: Git Clone app docker repository
2022-07-01 09:08:07 +08:00
block:
- name: Create app directory
shell: mkdir -p {{installpath}}
- name: Delete {{appname}} dir for sec_installation
shell: rm -rf {{installpath}}/{{appname}}
- name: Clone {{appname}} in Websoft9
git:
repo: "https://github.com/Websoft9/docker-{{appname}}.git"
2022-07-01 09:14:05 +08:00
dest: "{{installpath}}/{{appname}}"
2022-07-05 16:54:57 +08:00
- name: Excute Preparation if have pre.yml
2022-05-17 14:58:09 +08:00
block:
2022-06-27 09:18:46 +08:00
- name: Check if pre.yml exists
2022-06-30 11:02:53 +08:00
uri:
2022-07-01 09:14:05 +08:00
url: "https://github.com/Websoft9/StackHub/blob/main/apps/roles/{{appname}}/tasks/pre.yml"
2022-06-30 11:33:00 +08:00
return_content: yes
2022-05-17 14:58:09 +08:00
register: pre_exists
2022-06-30 11:34:45 +08:00
failed_when: false
2022-06-30 10:45:29 +08:00
2022-06-27 09:18:46 +08:00
- name: Excute pre.yml
2022-07-05 08:43:54 +08:00
include_tasks: roles/{{appname}}/tasks/pre.yml
2022-06-30 11:23:19 +08:00
when: pre_exists.status is defined and pre_exists.status == 200
2022-07-05 10:51:36 +08:00
2022-07-05 16:49:22 +08:00
- name: Install {{appname}}
include_tasks: tasks/install.yml
2022-07-07 16:11:14 +08:00
vars:
2022-07-08 11:19:18 +08:00
app: "{{item}}"
with_items: "{{applist}}"
2022-07-07 16:27:42 +08:00
- name: Check Docker Container Service
shell: docker ps --format \{\{'json .'\}\}| jq -s map\(\{containername:'.Names',state:'.State'\}\)
register: check_container_service
notify: check_container_service
2022-07-05 16:54:57 +08:00
handlers:
- name: check_container_service
debug:
var: check_container_service.stdout
2022-07-05 16:55:17 +08:00
2022-05-10 17:35:30 +08:00
roles:
2022-05-11 09:51:13 +08:00
- { role: role_nginx, tags: "role_nginx" }
2022-07-05 10:42:12 +08:00
- { role: "{{appname}}", tags: "{{appname}}" }
2022-05-11 09:51:13 +08:00
- { role: role_init, tags: "role_init" }
- { role: role_preend, tags: "preend" }
- { role: role_end, tags: "role_end" }