Files
demolampswarm/roles/demolamp/tasks/main2.yml
Gary Kwok 0530779609 V1
2024-02-23 18:13:31 +08:00

50 lines
1.1 KiB
YAML

---
- 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"