当前位置:网站首页>Include of ansible module_ Tasks: why is the imported task not executed after adding tags?
Include of ansible module_ Tasks: why is the imported task not executed after adding tags?
2022-04-23 06:58:00 【Sebastien23】
ansible Module include_tasks: Why is it added tags The imported task was not executed ?
In this paper ansible The version is 2.9.
Scene reproduction
Here is Role Tasks to be tested in :
# role01.yml
# ... Ahead tasks
- name: included task for test
include_tasks: test01.yml
tags:
- test01
# ... hinder tasks
In the execution of the whole Role when ,test01.yml Will be imported normally playbook And implement :
$ ansible-playbook -i hosts.ini all role01.yml
But when we want to pass tags When testing this task alone ,
$ ansible-playbook -i hosts.ini all role01.yml --tags "test01"
Something strange happened :include_tasks The task itself was carried out successfully , But imported test01.yml But not implemented !
Cause analysis
In the face of include_tasks Task use tags when , Only to include_tasks The task itself takes effect , And Can't Take effect on the tasks contained in it .
So if we want to work on the tasks included , How do you do that ?
terms of settlement
Can pass include_tasks Modular apply Parameters , Tag the included tasks .
Change the above task to the following form
# role01.yml
# ... Ahead tasks
- name: included task for test
include_tasks:
file: test01.yml
apply:
tags: test01
tags: always
# ... hinder tasks
And then call it :
$ ansible-playbook -i hosts.ini all role01.yml --tags "test01"
Be careful , above tags: always
Don't omit , otherwise include_tasks Itself will not be executed .always Label only for include_tasks Effective in itself . When calling other tags when ,include_tasks It will be always perform , But the tasks contained in it will not be performed .
版权声明
本文为[Sebastien23]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230557416481.html
边栏推荐
- JS性能优化
- LeetCode刷题|13罗马数字转整数
- Curry realization of function continuous call calculation and accumulation
- MySQL【ACID+隔离级别+ redo log + undo log】
- DDOS攻击/防御介绍
- 多线程
- Baidu map coordinates, Google coordinates and Tencent coordinates are mutually transformed
- offset和client獲取dom元素比特置信息
- openvswitch vlan网络实践
- Scientists say Australian plan to cull up to 10,000 wild horses doesn’t go far enough
猜你喜欢
随机推荐
柯里化实现函数连续调用计算累加和
Multi cycle verification of El form
SQL学习|基础查询与排列
Offset et client pour obtenir des informations sur l'emplacement des éléments Dom
leetcode之爬楼梯方法数
[Lombok quick start]
openvswitch 编译安装
tensorflow下载
JQ序列化后PHP后台解析
virtio 与vhost_net介绍
Installing redis using a small leather panel in the window environment
2021年国产数据库12强介绍
JS实现网页轮播图
LeetCode刷题|897递增顺序搜索树
rdma网络介绍
Decentralized Collaborative Learning Framework for Next POI Recommendation
Thinkphp5 -- object (think \ response \ JSON) to array
DNA reveals surprise ancestry of mysterious Chinese mummies
【代码解析(7)】Communication-Efficient Learning of Deep Networks from Decentralized Data
JS performance optimization