ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
1 将任务转移到其他主机上执行 `delegate_to` ``` --- - name: delegate tasks to other server hosts: s.hi.com tasks: - name: delegate tasks to other server copy: src=/tmp/a.txt dest=/tmp/b.txt delegate_to: b1.hi.com - name: common tasks copy: src=/tmp/a.txt dest=/tmp/b.txt ``` 2 并行执行play的主机数量,最大失败主机比例 ``` --- - name: one by one hosts: s.hi.com serial: 1 # 当失败比例达到25%让整个play失败 max_fail_percentage: 25 ``` 4 只执行一次 场景:hosst指向的是多台主机,但只有一台运行数据库迁移 `run_once` ``` --- - name: run once test hosts: b1.hi.com s.hi.com tasks: - name: run once test shell: date >> /tmp/time.txt run_once: true ``` 5 生成ssl ~~~ - name: create virtualenv hosts: web vars: proj_name: mezz conf_path: /root/ssl domain: www.mezz.com tasks: - name: create ssl certificates command: openssl req -new -x509 -nodes -out {{ proj_name }}.crt -keyout {{ proj_name }}.key -subj '/CN={{ domain }}' -days 3650 chdir={{ conf_path }} creates={{ conf_path }}/{{ proj_name }}.crt ~~~