{"id":6808,"date":"2014-11-08T19:05:59","date_gmt":"2014-11-08T11:05:59","guid":{"rendered":"http:\/\/jpuyy.com\/?p=6808"},"modified":"2014-11-08T19:06:56","modified_gmt":"2014-11-08T11:06:56","slug":"ansible-jinja2-templates","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=6808","title":{"rendered":"ansible jinja2\u6a21\u677f\u4f7f\u7528"},"content":{"rendered":"<p>\u5728j2\u4e2d\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u4f7f\u7528 ansible setup \u6a21\u5757\u4e2d\u7684\u53d8\u91cf<\/p>\n<p>\u5982\u4ee5\u4e0b\u662f\u4e00\u4e2abind\u7684\u914d\u7f6e\u6587\u4ef6<\/p>\n<pre>  {% if ansible_bond0.ipv4.address %}\r\n  bind {{ ansible_bond0.ipv4.address }}\r\n  {% elif ansible_eth0.ipv4.address %}\r\n  bind {{ ansible_eth0.ipv4.address }}\r\n  {% else %}\r\n  bind 0.0.0.0\r\n  {% endif %}\r\n<\/pre>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2asnmp\u78c1\u76d8\u5206\u533a\u7684\u8bbe\u5b9a<\/p>\n<pre>{% for i in ansible_mounts %}\r\n{% if i['mount']  != '\/boot' %}\r\ndisk {{ i['mount'] }} 10% \r\n{% endif %}\r\n{% endfor %}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728j2\u4e2d\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u4f7f\u7528 ansible setup \u6a21\u5757\u4e2d\u7684\u53d8\u91cf \u5982\u4ee5\u4e0b\u662f\u4e00\u4e2abind\u7684\u914d\u7f6e\u6587\u4ef6 {% if ansible_bond0.ipv4.address %} bind {{ ansible_bond0.ipv4.address }} {% elif ansible_eth0.ipv4.address %} bind {{ ansible_eth0.ipv4.address }} {% else %} bind 0.0.0.0 {% endif %} \u4ee5\u4e0b\u662f\u4e00\u4e2asnmp\u78c1\u76d8\u5206\u533a\u7684\u8bbe\u5b9a {% for i in ansible_mounts %} {% if i[&#8216;mount&#8217;] != &#8216;\/boot&#8217; %} disk {{ i[&#8216;mount&#8217;] }} 10% {% endif %} {% endfor %}<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165],"tags":[],"class_list":["post-6808","post","type-post","status-publish","format-standard","hentry","category-ops"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/6808","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6808"}],"version-history":[{"count":2,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/6808\/revisions"}],"predecessor-version":[{"id":6822,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/6808\/revisions\/6822"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6808"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6808"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}