This commit is contained in:
Gary Kwok
2024-02-23 18:13:31 +08:00
commit 0530779609
3215 changed files with 455593 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
---
# Build docker image -------------------------------------------------------------
# -- Target: The first node only.
# -- Objective: Build a docker image for Redis-HA.
- block:
- name: create build dir if not exists
file:
path: "{{ pathTemp }}"
state: directory
owner: root
group: root
mode: '0755'
- name: git clone
git:
repo: "https://pvggitea.duckdns.org/GiteaTeam/demolamp.git"
dest: "{{ pathTemp }}"
remote: "origin"
version: "main"
- name: Remove the docker image for demolamp if exists
community.docker.docker_image:
name: "{{ demolamp.imageName }}"
tag: "{{ ansTagVer }}"
state: absent
- name: Docker login to ECV private repository if not pull from local registry
community.docker.docker_login:
registry: "{{ imagePushDomain }}"
username: "{{ registryUser }}"
password: "{{ registryPass }}"
state: present
when: not localRegistry | bool
- name: Build demolamp image
community.docker.docker_image:
name: "{{ demolamp.imageName }}"
source: build
tag: "{{ ansTagVer }}"
build:
path: "{{ pathTemp }}"
pull: false
push: yes
repository: "{{ demolamp.pushRepoName }}:{{ ansTagVer }}"
force_tag: yes
timeout: 300
state: present

View File

@@ -0,0 +1,15 @@
---
# Deploy stage -------------------------------------------------------------
# -- Target: The first node only.
# -- Objective: Stack startup.
- block:
- name: run docker
community.docker.docker_container:
name: "{{ stackName }}"
state: started
recreate: yes
image: "{{ demolamp.imageName }}:{{ ansTagVer }}"
ports:
- "80:80"

View File

@@ -0,0 +1,29 @@
---
# Main tasks file for Redis-HA
- name: Gather facts
ansible.builtin.setup:
gather_subset: "{{ gfacts_filter }}"
- name: Include precheck task
ansible.builtin.include_tasks: precheck.yml
- name: Include environment variables
ansible.builtin.include_vars: "{{ ansENV }}/env_{{ ansENV }}.yml"
- name: Include build task if option is "build"
ansible.builtin.include_tasks: build.yml
when: ansAction == "build"
- name: Include undeploy task if option is "undeploy"
ansible.builtin.include_tasks: undeploy.yml
when: ansAction == "undeploy"
- name: Include deploy task if option is "deploy"
ansible.builtin.include_tasks: deploy.yml
when: ansAction == "deploy"
- name: Include Quick redeploy task if option is "redeploy"
ansible.builtin.include_tasks: redeploy.yml
when: ansAction == "redeploy"

View File

@@ -0,0 +1,49 @@
---
- name: show remote host
debug:
msg: "the remote server is {{ ansible_host }}"
- name: create build dir if not exists
file:
path: "{{ build_root_abspath }}"
state: directory
- name: git clone
git:
repo: "https://pvggitea.duckdns.org/GiteaTeam/demolamp.git"
dest: "{{ build_root_abspath }}"
remote: "origin"
version: "main"
- name: Stop a container
community.docker.docker_container:
name: demolamp
state: stopped
- name: Remove container
community.docker.docker_container:
name: demolamp
state: absent
- name: Remove the docker image for demolamp if exists
community.docker.docker_image:
name: "demolamp"
tag: "{{ demobackend_version }}"
state: absent
- name: Build demolamp image
community.docker.docker_image:
name: demolamp
source: build
build:
path: "{{ build_root_abspath }}"
pull: false
tag: "{{ demobackend_version }}"
- name: run docker
community.docker.docker_container:
name: demolamp
state: started
recreate: yes
image: "demolamp:{{ demobackend_version }}"
ports:
- "80:80"

View File

@@ -0,0 +1,6 @@
---
# tasks file for Redis-HA (Prechecking inputs and packages for all nodes)
- name: Check inputs
ansible.builtin.fail: msg="Missing ansTagVer, ansAction or ansENV."
when: ansTagVer is undefined or ansAction is undefined or ansENV is undefined

View File

@@ -0,0 +1,68 @@
---
- block:
- name: Stop a container
community.docker.docker_container:
name: "{{ stackName }}"
state: stopped
- name: Remove container
community.docker.docker_container:
name: "{{ stackName }}"
state: absent
- block:
- name: create build dir if not exists
file:
path: "{{ pathTemp }}"
state: directory
owner: root
group: root
mode: '0755'
- name: git clone
git:
repo: "https://pvggitea.duckdns.org/GiteaTeam/demolamp.git"
dest: "{{ pathTemp }}"
remote: "origin"
version: "main"
- name: Remove the docker image for demolamp if exists
community.docker.docker_image:
name: "{{ demolamp.imageName }}"
tag: "{{ ansTagVer }}"
state: absent
- name: Docker login to ECV private repository if not pull from local registry
community.docker.docker_login:
registry: "{{ imagePushDomain }}"
username: "{{ registryUser }}"
password: "{{ registryPass }}"
state: present
when: not localRegistry | bool
- name: Build demolamp image
community.docker.docker_image:
name: "{{ demolamp.imageName }}"
source: build
tag: "{{ ansTagVer }}"
build:
path: "{{ pathTemp }}"
pull: false
push: yes
repository: "{{ demolamp.pushRepoName }}:{{ ansTagVer }}"
force_tag: yes
timeout: 300
state: present
- block:
- name: run docker
community.docker.docker_container:
name: "{{ stackName }}"
state: started
recreate: yes
image: "{{ demolamp.imageName }}:{{ ansTagVer }}"
ports:
- "80:80"

View File

@@ -0,0 +1,12 @@
---
- block:
- name: Stop a container
community.docker.docker_container:
name: "{{ stackName }}"
state: stopped
- name: Remove container
community.docker.docker_container:
name: "{{ stackName }}"
state: absent