剧本:
在Windows机器上安装Docker复制开始必要的文件 使用Docker Compose的应用程序
defaults:
---
- name: Deploy Redis on Windows
hosts: redis_hosts
vars_files:
- ./vars.yml
tasks:
- name: Ensure Docker is installed
win_chocolatey:
name: docker-desktop
state: present
- name: Create application directory
win_file:
path: "{{ app_files_dest }}"
state: directory
- name: Copy application files
win_copy:
src: "{{ app_files_src }}/"
dest: "{{ app_files_dest }}"
- name: Start the application with Docker Compose
win_command: docker compose -f redis.yml up -d
args:
chdir: "{{ app_files_dest }}"
app_files_src:“ {{file_path}}/cache”
app_files_dest:'c:p