more work on simulate-fabric role
diff --git a/cord-single-playbook.yml b/cord-single-playbook.yml
index 0e28450..f92f073 100644
--- a/cord-single-playbook.yml
+++ b/cord-single-playbook.yml
@@ -17,12 +17,12 @@
roles:
- common-prep
- cloudlab-prep
- - apt-cacher-ng
-- name: DNS Server Setup
+- name: Cache and DNS Server Setup
hosts: head
become: yes
roles:
+ - apt-cacher-ng
- dns-nsd
- dns-unbound
diff --git a/roles/simulate-fabric/defaults/main.yml b/roles/simulate-fabric/defaults/main.yml
index 968f6d9..b038889 100644
--- a/roles/simulate-fabric/defaults/main.yml
+++ b/roles/simulate-fabric/defaults/main.yml
@@ -3,12 +3,35 @@
simfabric_bridges:
- name: databr
- ipaddr: "10.168.0.1/24"
- nat: True
+ addresses:
+ - "10.168.0.1/24"
+ - "10.168.1.1/24"
interfaces:
- veth0
+simfabric_links:
+ - name: veth
+ mac: "02:42:0a:a8:00:01"
+
simfabric_interfaces:
- veth0
- veth1
+simfabric_iptables:
+ - table: nat
+ chain: POSTROUTING
+ source: "10.168.0.0/16"
+ dest: "! 10.168.0.0/16"
+ jump: MASQUERADE
+
+simfabric_sysctl:
+ - name: net.ipv4.ip_forward
+ value: 1
+ - name: net.ipv4.conf.all.send_redirects
+ value: 0
+ - name: net.ipv4.conf.default.send_redirects
+ value: 0
+ - name: net.ipv4.conf.eth0.send_redirects
+ value: 0
+ - name: net.ipv4.conf.databr.send_redirects
+ value: 0
diff --git a/roles/simulate-fabric/files/simulate-fabric-playbook.yml b/roles/simulate-fabric/files/simulate-fabric-playbook.yml
index 9ff2345..6a99712 100644
--- a/roles/simulate-fabric/files/simulate-fabric-playbook.yml
+++ b/roles/simulate-fabric/files/simulate-fabric-playbook.yml
@@ -21,3 +21,45 @@
command: brctl addbr "{{ item.name }}"
with_items: "{{ simfabric_bridges }}"
+ - name: Set IP addresses to bridges
+ when: "ansible_{{ item.0.name }} is not defined"
+ command: "ip addr add {{ item.1 }} dev {{ item.0.name }}"
+ with_subelements:
+ - "{{ simfabric_bridges }}"
+ - addresses
+
+ - name: Start bridges
+ when: "ansible_{{ item.name }}.active is false"
+ command: "ip link set dev {{ item }} up"
+ with_items: "{{ simfabric_bridges }}"
+
+ - name: Create ip links
+ when: "ansible_{{ item.name }}0 is not defined"
+ command: "ip link add address {{ item.mac }} type {{ item.name }}"
+ with_items: "{{ simfabric_links }}"
+
+ - name: Start interfaces
+ when: "ansible_{{ item.name }}.active is false"
+ command: "ip link set dev {{ item }} up"
+ with_items: "{{ simfabric_interfaces }}"
+
+ - name: Add interfaces to bridges
+ when: "ansible_{{ item.0.name }}.interfaces is empty"
+ command: "brctl addif {{ item.0.name }} {{ item.1 }}"
+ with_subelements:
+ - "{{ simfabric_bridges }}"
+ - interfaces
+
+ - name: Configure iptables
+ iptables: "table={{ item.table }} chain={{ item.chain }} source={{ item.source }} dest={{ item.dest }} jump={{ item.jump }}"
+ with_items: "{{ simfabric_iptables }}"
+
+ - name: Set kernel sysctl values
+ sysctl:
+ name="{{ item.name }}"
+ value="{{ item.value }}"
+ sysctl_set=yes
+ state=present
+ reload=yes
+ with_items: "{{ simfabric_sysctl }}"
+
diff --git a/roles/simulate-fabric/templates/simulate-fabric-vars.yml.j2 b/roles/simulate-fabric/templates/simulate-fabric-vars.yml.j2
index b129297..599443f 100644
--- a/roles/simulate-fabric/templates/simulate-fabric-vars.yml.j2
+++ b/roles/simulate-fabric/templates/simulate-fabric-vars.yml.j2
@@ -3,6 +3,15 @@
simfabric_bridges:
{{ simfabric_bridges | to_nice_yaml }}
+simfabric_links:
+{{ simfabric_links | to_nice_yaml }}
+
simfabric_interfaces:
{{ simfabric_interfaces | to_nice_yaml }}
+simfabric_iptables:
+{{ simfabric_iptables | to_nice_yaml }}
+
+simfabric_sysctl:
+{{ simfabric_sysctl | to_nice_yaml }}
+