zoukankan      html  css  js  c++  java
  • Ansible Playbook handlers 语句

    handlers 用法如下,表示当 tasks 执行成功之后再执行 handlers,相当于 shell 中的 && 用法,如果 tasks 执行失败是不会执行 handlers 语句的

    [root@localhost ~]$ cat handlers.yml 
    ---
    - name: handlers test
      hosts: 192.168.119.134
      user: root
      tasks:
        - name: copy file
          copy: src=/etc/passwd dest=/tmp/aaa.txt
          notify: test handlers                         # 这里要指定执行哪个handlers,对应下面的name,我们可以定义多个handlers,通过 handlers name 来识别不同的handlers
      handlers:                                         # 表示如果拷贝文件成功,就使用 shell 模块执行 echo "abc" >> /tmp/aaa.txt 命令
        - name: test handlers 
          shell: echo "abc" >> /tmp/aaa.txt   

        

  • 相关阅读:
    情人节玫瑰花
    Yii2美化confirm
    apache ab压力测试
    Yii2的Debug工具
    yii2的扩展程序包
    slim
    composer使用
    打印
    yii的csv导出
    ajax文件下载
  • 原文地址:https://www.cnblogs.com/pzk7788/p/10216666.html
Copyright © 2011-2022 走看看