ansible 命令只执行一次

RUN ONCE

通过run_once: true来指定该task只能在某一台机器上执行一次. 可以和delegate_to 结合使用

- command: /opt/application/upgrade_db.py
  run_once: true
  delegate_to: web01.example.org

指定在"web01.example.org"上执行这

如果没有delegate_to, 那么这个task会在第一台机器上执行

如部署时,导入数据库

猜你喜欢

转载自blog.csdn.net/JackLiu16/article/details/82023518