当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
tp5 报错variable type error: array解决方法
mysql密码过期的方法
【MySQL基础篇】启动选项、系统变量、状态变量
bcc安装和基本工具使用说明
PHP unlimited classification and tree
Jenkins搭建与使用
Imitation scallop essay reading page
JS performance optimization
TP5 uses redis
【OSS文件上传快速入门】
TP6 的 each 遍历用法
Curry realization of function continuous call calculation and accumulation
页面缓存问题解决方法(慎用)
Centos8 builds php8 0.3 operating environment
openvswitch vlan网络实践
fdfs启动
Number of stair climbing methods of leetcode
ubuntu下搭建mysql环境 & 初识SQL
ovs与ovs+dpdk架构分析
【MySQL基础篇】数据导出导入权限与local_infile参数