Update roles/demolamp/tasks/deploy.yml

This commit is contained in:
2024-03-12 16:51:23 +08:00
parent 9e3d8a661d
commit 8b90659578

View File

@@ -1,15 +1,65 @@
--- ---
- name: Housekeep pervious temporary directory
ansible.builtin.file:
path: "{{ pathTemp }}"
state: absent
- name: Create a temporary directory on remote nodes
ansible.builtin.file:
path: "{{ pathTemp }}"
state: directory
owner: root
group: root
mode: '0755'
# Deploy stage ------------------------------------------------------------- # Deploy stage -------------------------------------------------------------
# -- Target: The first node only. # -- Target: The first node only.
# -- Objective: Stack startup. # -- Objective: Stack startup.
- block: - block:
- name: run docker - name: Create a directory on remote host if not exists for docker-compose file
community.docker.docker_container: ansible.builtin.file:
name: "{{ stackName }}" path: "{{ pathCompose }}"
state: started state: directory
recreate: yes owner: root
image: "{{ demolamp.imageName }}:{{ ansTagVer }}" group: root
ports: mode: '0755'
- "80:80"
- name: Check compose file exists
ansible.builtin.stat:
path: "{{ pathCompose }}/{{ fileCompose }}"
ignore_errors: True
register: chk_composeFile
- name: Deploy the docker compose file
ansible.builtin.template:
src: "{{ role_path }}/files/{{ ansTagVer }}/{{ templateCompose }}"
dest: "{{ pathCompose }}/{{ fileCompose }}"
owner: root
group: root
mode: "0755"
force: yes
backup: yes
when: updateComposeTpl | bool or not chk_composeFile.stat.exists
- name: Docker login to ECV private repository if not pull from local registry
community.docker.docker_login:
registry: "{{ imagePullDomain }}"
username: "{{ registryUser }}"
password: "{{ registryPass }}"
state: present
when: not localRegistry | bool
- name: Prune docker containers
community.docker.docker_prune:
containers: yes
- name: Deploy the Redis-HA service
community.docker.docker_stack:
name: "{{ stackName }}"
compose:
- "{{ pathCompose }}/{{ fileCompose }}"
state: present
with_registry_auth : yes