/roles/test/tasks/main.yml
---
- name: deploy
debug: msg="This is an install method."
tags:
- deploy
- name: uninstall
debug: msg="test uninstall section."
tags:
- uninstall
/site.yml
---
- hosts: localhost
gather_facts: no
tasks:
- name: loading role
include_role:
name: test
tags: deploy
运行
ansible-playbook site.yml
结果是:
PLAY [localhost] ***************************************************************************************************************
TASK [test : deploy] ***********************************************************************************************************
ok: [localhost] => {
"msg": "This is a install method."
}
TASK [test : uninstall] ********************************************************************************************************
ok: [localhost] => {
"msg": "test uninstall section."
}
PLAY RECAP *********************************************************************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0
我觉得写的没错的话,应该是仅仅运行deploy那个任务的,为啥所有的任务都运行了?
你这个只是对task进行打标签的操作,不行.