如果文件存在,则跳过剩余任务

时间:2018-07-12 11:50:33

标签: ansible ansible-2.x ansible-facts

我陷入一个条件部分,我的主要愿望是,如果目标服务器目录中存在文件,请跳过所有其他任务。谢谢

---
- name: Copying file agent files to the ServerB and install agent
  hosts: ServerB

  tasks:
  - name: check directory if its exist don't run other tasks after this task(I want to indicate in this part)

  - name: Copy Zip Folder to ServerB destination directory
    win_copy:
      src: "/home/Sample/environments/File.zip"
      dest: "C:\\Program Files\\environments\\"

  - name: Unzip file in destination path
    win_unzip:
      src: "C:\\Program Files\\environments\\File.zip"
      dest: "C:\\Program Files\\environments\\"
      copy: no
      delete_archive: yes

  - name: run script for started service in destination server
    win_command: CScript.exe "C:\\Program Files\\environments\\File\\InstallService.vbs"

  - name: Ensure Service is started
    win_service:
      name: File Agent
      state: started
      enabled: yes

0 个答案:

没有答案