小编mos*_*osh的帖子

根据匹配的属性构建列表(ansible)

尝试构建与属性匹配的服务器列表(在本例中为ec2_tag),以便为特定任务调度特定服务器.

我正在尝试selectattr与之匹配:

servers: "{{ hostvars[inventory_hostname]|selectattr('ec2_tag_Role', 'match', 'cassandra_db_seed_node') | map(attribute='inventory_hostname') |list}}"
Run Code Online (Sandbox Code Playgroud)

虽然我从Ansible得到了类似错误:

fatal: [X.X.X.X]: FAILED! => {"failed": true, "msg": "Unexpected templating type error occurred on ({{ hostvars[inventory_hostname]|selectattr('ec2_tag_Role', 'match', 'cassandra_db_seed_node') | map(attribute='inventory_hostname') |list}}): expected string or buffer"}
Run Code Online (Sandbox Code Playgroud)

我在这里错过了什么?

linux ansible

4
推荐指数
1
解决办法
830
查看次数

标签 统计

ansible ×1

linux ×1