はまったのでメモです。
事象
- includeにtagをつけてもtagが見つからないと言われる
- 要するに無視されている模様
$ ansible-playbook site.yml -i stage --tags hoge
ERROR: tag(s) not found in playbook: hoge. possible values:
環境
- ansible 1.8.4
$ ansible --version
ansible 1.8.4
tree
$ tree ./
./
├── fuga.yml
├── hoge.yml
├── roles
│ ├── absent_file
│ │ └── tasks
│ │ └── main.yml
│ └── ensure_file
│ ├── files
│ │ └── hoge.txt
│ └── tasks
│ └── main.yml
├── stage
└── site.yml
site.yml
- include: hoge.yml
tags:
- hoge
- include: fuga.yml
tags:
- fuga
hoge.yml
- hosts: all
roles:
- ensure_file
fuga.yml
- hosts: all
roles:
- absent_file
roles/absent_file/tasks.yml
- file: path=/root/hoge.txt mode=0644 state=absent
roles/ensure_file/tasks.yml
- copy: dest=/root/hoge.txt src=hoge.txt mode=0644
原因
既知のIssue
https://github.com/ansible/ansible/issues/9862
https://github.com/ansible/ansible/issues/11309
本来はそもそもトップレベルのPlayBookにタグれなかったとのこと。
2.0もしくはそれ以上でサポートされた(る)模様。
diffを見ると、そもそもincludeモジュールにtagを読み込む機能がなかったので足して直してますね。
https://github.com/ansible/ansible/commit/7c1d569a26b2b7a41d6b4bc9f442fbd7f8b8a188