Questions tagged «jinja»

6
Ansible:如果满足特定条件,则在vars文件中有条件地定义变量
根据在group_vars中定义的变量的值(真/假),我尝试在vars文件中定义一些变量。它们的值取决于var组的值。 我当前的var文件如下所示: {% if my_group_var %} test: var1: value var2: value ... varn: value {% else %} test: var1: other_value var2: other_value ... varn: other_value {% endif %} 对于我的每个角色,我都使用在此文件中定义的变量。 我的测试剧本如下所示: - name: blabla hosts: blabla vars_files: - <path>/test_vars.yml roles: blabla 运行剧本后收到的错误是: {% if my_group_var %} ^ here exception type: <class …

1
在Jinja2模板中循环Ansible变量数组
当Ansible收集有关主机的事实时,例如获取主机的所有坐骑: "ansible_mounts": [ { "block_available": 7800291, "block_size": 4096, "block_total": 8225358, "block_used": 425067, "device": "/dev/mapper/foobar", "fstype": "xfs", "inode_available": 16403366, "inode_total": 16458752, "inode_used": 55386, "mount": "/", "options": "rw,seclabel,relatime,attr2,inode64,noquota", "size_available": 31949991936, "size_total": 33691066368, "uuid": "2ebc82cb-5bc2-4db9-9914-33d65ba350b8" }, { "block_available": 44648, "block_size": 4096, "block_total": 127145, "block_used": 82497, "device": "/dev/sda1", "fstype": "xfs", "inode_available": 255595, "inode_total": 256000, …
12 ansible  json  jinja 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.