ソースを参照

Fixed lots of template issues

Till Klocke 9 年 前
コミット
5bd2611e24

+ 18 - 14
roles/internal/ffdo.mesh-interfaces/tasks/main.yml

@@ -1,20 +1,9 @@
 ---
 # tasks file for mesh-interfaces
 
-- name: Ensure interface definitions from other files are included
-  lineinfile:
-    dest: /etc/network/interfaces
-    line: "source /etc/network/interfaces.d/*.cfg"
-
-- name: Install interface definitions
-  template:
-    dest: "/etc/network/interfaces.d/{{item.file}}"
-    src: "{{item.template}}"
-  with_items:
-  - file: mesh.cfg
-    template: mesh_interfaces.j2
-  - file: backbone.cfg
-    template: gre-tunnel.j2
+- template: 
+    src: test.j2
+    dest: /etc/test-hosts.info
 
 - name: Install bird.conf
   template: src=bird.conf.j2 dest=/etc/bird.d/mesh.conf
@@ -23,3 +12,18 @@
 - name: Install bird6.conf
   template: src=bird6.conf.j2 dest=/etc/bird6.d/mesh.conf
   notify: Restart bird daemons
+
+- name: Ensure interface definitions from other files are included
+  lineinfile:
+    dest: /etc/network/interfaces
+    line: "source /etc/network/interfaces.d/*.cfg"
+
+- name: Install mesh interface definitions
+  template:
+    dest: "/etc/network/interfaces.d/mesh.cfg"
+    src: "mesh_interfaces.j2"
+
+- name: Install gre tunnel definitions
+  template:
+    dest: "/etc/network/interfaces.d/backbone.cfg"
+    src: "gre-tunnel.j2"

+ 3 - 3
roles/internal/ffdo.mesh-interfaces/templates/bird.conf.j2

@@ -2,9 +2,9 @@
 # This file is managed by ansible. Do not edit by hand!
 #
 
-{% for host in hostvars %}
-{% if hostvars[host]['ansible_fqdn'] != ansible_fqdn %}
-protocol bgp {{hostvars[host]['ansible_hostname']}} from ibgp {
+{% for host in groups['all'] %}
+{% if hostvars[host]["inventory_hostname"] != inventory_hostname %}
+protocol bgp {{hostvars[host]['inventory_hostname_short']}} from ibgp {
         source address {{mesh_ipv4|ipaddr('address')}};
         neighbor {{hostvars[host]['mesh_ipv4']}} as {{supernode_as}};
         default bgp_med 4;

+ 4 - 4
roles/internal/ffdo.mesh-interfaces/templates/bird6.conf.j2

@@ -2,10 +2,10 @@
 # This file is managed by ansible. Do not edit by hand!
 #
 
-{% for host in hostvars %}
-{% if hostvars[host]['ansible_fqdn'] != ansible_fqdn %}
-protocol bgp {{hostvars[host]['ansible_hostname']}} from ibgp {
-        neighbor {{host.mesh_ipv6}} as {{supernode_as}};
+{% for host in groups['all'] %}
+{% if hostvars[host]['inventory_hostname'] != inventory_hostname %}
+protocol bgp {{hostvars[host]['inventory_hostname_short']}} from ibgp {
+        neighbor {{hostvars[host].mesh_ipv6}} as {{supernode_as}};
         default bgp_med 4;
 }
 {% endif %}

+ 6 - 4
roles/internal/ffdo.mesh-interfaces/templates/gre-tunnel.j2

@@ -1,11 +1,13 @@
-{% for host in hostvars %}
-{% if hostvars[host]['ansible_fqdn'] != ansible_fqdn %}
-auto {{hostvars[host]['ansible_fqdn']}}
-iface {{hostvars[host]['ansible_fqdn']}} inet manual
+{% for host in groups['all'] %}
+{% if hostvars[host] is defined %}
+{% if hostvars[host]['inventory_hostname'] != inventory_hostname %}
+auto {{hostvars[host]['inventory_hostname_short']}}
+iface {{hostvars[host]['inventory_hostname_short']}} inet manual
     pre-up ip link add $IFACE type gretap local {{ansible_default_ipv4.address}} remote {{hostvars[host]['ansible_default_ipv4']['address']}} dev {{ansible_default_ipv4.alias}}
     pre-up ip link set up dev $IFACE
     up batctl if add $IFACE
     post-down ip link set down dev $IFACE
     post-down ip link del dev $IFACE
 {% endif %}
+{% endif %}
 {% endfor %}

+ 3 - 0
roles/internal/ffdo.mesh-interfaces/templates/test.j2

@@ -0,0 +1,3 @@
+{% for host in groups['all'] %}
+Host: {{host}}
+{% endfor %}