Sim*_*eth 4 ansible ansible-2.x
2.2 版
我想获得以下变量的切片,我该怎么做?
hostvars[inventory_hostname]['ansible_hostname']|list
基本上我有一个主机名,hostname001我希望检索最后两个字符。
How do I split it and slice it?
试试ansible_hostname[-3:]。
为什么你使用hostvars[inventory_hostname]['ansible_hostname']而不是简单的ansible_hostname?
对于字符串和列表,您可以使用 Python 切片技术。
| 归档时间: |
|
| 查看次数: |
4436 次 |
| 最近记录: |