ansible-playbook tags 使用
yaml文件内容
---
- hosts: websrvs
remote_user: root
tasks:
- name: install httpd package
yum: name=httpd
tags: inshttpd
- name: copy conf file
copy: src=files/httpd.conf dest=/etc/httpd/conf/backup=yes
notify: restart service
- name: start service
service: httpd state=started enabled=yes
tags: rshttpd
handlers:
- name: restart servlce
service: name=httpd state=restarted
# 执行命令
ansible-playbook -t inshttpd,rshttpd httpd.yml
这样就会只执行 inshttpd 和 rshttpd 两个tags的任务
可以多个动作公用一个标签;
本文来自博客园, 作者:Star-Hitian, 转载请注明原文链接:https://www.cnblogs.com/Star-Haitian/articles/15233833.html

浙公网安备 33010602011771号