updates to fix buts around reboot and interface generation as well as adding more customizations
diff --git a/roles/compute-node/files/rename_ifaces.sh b/roles/compute-node/files/rename_ifaces.sh
index be08ba5..131ea10 100755
--- a/roles/compute-node/files/rename_ifaces.sh
+++ b/roles/compute-node/files/rename_ifaces.sh
@@ -81,6 +81,7 @@
done
}
+# 40G_LIST ETH_LIST FAB_IFACE EXT_IFACE MGT_IFACE
function generate_interfaces {
OUT=$IFACES_FILE
rm -rf $OUT
@@ -93,14 +94,13 @@
echo "" >> $OUT
IDX=0
- FIRST=1
for i in $(cat $1); do
- if [ $FIRST -eq 1 ]; then
+ if [ "eth$IDX" == "$3" ]; then
echo "auto eth$IDX" >> $OUT
echo "iface eth$IDX inet static" >> $OUT
- echo " address $IP" >> $OUT
- echo " network $NETWORK" >> $OUT
- echo " netmask $NETMASK" >> $OUT
+ echo " address $FAB_IP" >> $OUT
+ echo " network $FAB_NETWORK" >> $OUT
+ echo " netmask $FAB_NETMASK" >> $OUT
FIRST=0
else
echo "iface eth$IDX inet manual" >> $OUT
@@ -109,12 +109,27 @@
IDX=$(expr $IDX + 1)
done
- FIRST=1
for i in $(cat $2); do
- if [ $FIRST -eq 1 ]; then
+ if [ "eth$IDX" == "$4" ]; then
+ if [ "$EXT_IP" == "dhcp" ]; then
+ echo "auto eth$IDX" >> $OUT
+ echo "iface eth$IDX inet dhcp" >> $OUT
+ elif [ "$EXT_IP" == "manual" ]; then
+ echo "iface eth$IDX inet manual" >> $OUT
+ else
+ echo "auto eth$IDX" >> $OUT
+ echo "iface eth$IDX inet static" >> $OUT
+ echo " address $EXT_IP" >> $OUT
+ echo " network $EXT_NETWORK" >> $OUT
+ echo " netmask $EXT_NETMASK" >> $OUT
+ echo " broadcast $EXT_BROADCAST" >> $OUT
+ echo " gateway $EXT_GW" >> $OUT
+ echo " dns-nameservers 8.8.8.8 8.8.4.4" >> $OUT
+ echo " dns-search cord.lab" >> $OUT
+ fi
+ elif [ "eth$IDX" == "$5" ]; then
echo "auto eth$IDX" >> $OUT
echo "iface eth$IDX inet dhcp" >> $OUT
- FIRST=0
else
echo "iface eth$IDX inet manual" >> $OUT
fi
@@ -123,11 +138,24 @@
done
}
-ADDR=$1
-IP=$(echo $ADDR | cut -d/ -f1)
-MASKBITS=$(echo $ADDR | cut -d/ -f2)
-NETWORK=$(network $IP $MASKBITS)
-NETMASK=$(netmask $MASKBITS)
+FAB_IFACE=$1
+FAB_ADDR=$2
+FAB_IP=$(echo $FAB_ADDR | cut -d/ -f1)
+FAB_MASKBITS=$(echo $FAB_ADDR | cut -d/ -f2)
+FAB_NETWORK=$(network $FAB_IP $FAB_MASKBITS)
+FAB_NETMASK=$(netmask $FAB_MASKBITS)
+
+EXT_IFACE=$3
+EXT_ADDR=$4
+if [ "$EXT_ADDR" != "dhcp" ]; then
+ EXT_IP=$(echo $EXT_ADDR | cut -d/ -f1)
+ EXT_MASKBITS=$(echo $EXT_ADDR | cut -d/ -f2)
+ EXT_NETWORK=$(network $EXT_IP $EXT_MASKBITS)
+ EXT_NETMASK=$(netmask $EXT_MASKBITS)
+ EXT_BROADCAST=$(broadcast $EXT_IP $EXT_MASKBITS)
+ EXT_GW=$(first $EXT_ADDR)
+fi
+MGT_IFACE=$5
LIST_ETH=$(mktemp -u)
LIST_40G=$(mktemp -u)
@@ -149,26 +177,27 @@
esac
done
-RESULT="false"
+CHANGED="false"
-generate_interfaces $LIST_40G $LIST_ETH
+generate_interfaces $LIST_40G $LIST_ETH $FAB_IFACE $EXT_IFACE $MGT_IFACE
+
diff /etc/network/interfaces $IFACES_FILE 2>&1 > /dev/null
if [ $? -ne 0 ]; then
- RESULT="true"
+ CHANGED="true"
cp /etc/network/interfaces /etc/network/interfaces.1
cp $IFACES_FILE /etc/network/interfaces
fi
-generate_persistent_names $LIST_40G $LIST_ETH
+generate_persistent_names $LIST_40G $LIST_ETH $FAB_IFACE $EXT_IFACE
if [ -r /etc/udev/rules.d/70-persistent-net.rules ]; then
diff /etc/udev/rules.d/70-persistent-net.rules $NAMES_FILE 2>&1 > /dev/null
if [ $? -ne 0 ]; then
- RESULT="true"
+ CHANGED="true"
cp /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules.1
cp $NAMES_FILE /etc/udev/rules.d/70-persistent-net.rules
fi
else
- RESULT="true"
+ CHANGED="true"
cp $NAMES_FILE /etc/udev/rules.d/70-persistent-net.rules
fi
@@ -177,4 +206,4 @@
rm -rf $LIST_ETH
rm -rf $LIST_40G
-echo -n $RESULT
+echo -n $CHANGED
diff --git a/roles/compute-node/tasks/main.yml b/roles/compute-node/tasks/main.yml
index b5160a6..4eeac12 100644
--- a/roles/compute-node/tasks/main.yml
+++ b/roles/compute-node/tasks/main.yml
@@ -1,4 +1,12 @@
---
+- name: Verify Manditory Variables
+ fail: msg="Variable '{{ item }}' is not defined"
+ when: item not in hostvars[inventory_hostname]
+ with_items:
+ - fabric_ip
+ tags:
+ - interface_config
+
- name: Applications
become: yes
apt: name={{ item }} state=latest force=yes
@@ -70,16 +78,16 @@
- name: Consistent Interface Naming
become: yes
- script: files/rename_ifaces.sh {{ fabric_ip }}
+ script: files/rename_ifaces.sh {{ compute_node.interfaces.fabric }} {{ compute_node.addresses.fabric }} {{ compute_node.interfaces.external }} {{ compute_node.addresses.external }} {{ compute_node.interfaces.management }}
register: ifaces_changed
- changed_when: ifaces_changed.stdout != "false"
+ changed_when: ifaces_changed.stdout.find("true") != -1
tags:
- interface_config
- name: Reboot Required
become: yes
command: /sbin/reboot
- async: 1
+ async: 0
poll: 0
ignore_errors: true
when: ifaces_changed.stdout != "false"
@@ -87,6 +95,7 @@
- interface_config
- name: Wait For Restart
- local_action: wait_for host={{ ansible_host }} state=started port=22 delay=30 search_regex=OpenSSH timeout=600
+ local_action: wait_for port=22 host={{ inventory_hostname }} search_regex=OpenSSH delay=30 timeout=600 connect_timeout=15
+ when: ifaces_changed.stdout != "false"
tags:
- interface_config
diff --git a/roles/compute-node/vars/main.yml b/roles/compute-node/vars/main.yml
index 6d1a0cd..d240443 100644
--- a/roles/compute-node/vars/main.yml
+++ b/roles/compute-node/vars/main.yml
@@ -1 +1,11 @@
pub_ssh_key: "{{ lookup('file', 'files/id_rsa.pub') }}"
+
+compute_node:
+ interfaces:
+ fabric: "{{ fabric_iface | default('eth0') }}"
+ management: "{{ management_iface | default('eth2') }}"
+ external: "{{ external_iface | default('eth3') }}"
+ addresses:
+ fabric: "{{ fabric_ip | mandatory }}"
+ management: "{{ management_ip | default('dhcp') }}"
+ external: "{{ external_ip | default('manual') }}"
diff --git a/roles/maas/tasks/main.yml b/roles/maas/tasks/main.yml
index 63ed046..782c48a 100644
--- a/roles/maas/tasks/main.yml
+++ b/roles/maas/tasks/main.yml
@@ -155,12 +155,24 @@
owner=root
group=root
mode=0644
+ validate_certs=no
with_items:
- - { url : "https://www.dropbox.com/s/eqxs4kx84omtkha/onie-installer-x86_64-accton_as6712_32x-r0?dl=1", dest : "onie-installer-x86_64-accton_as6712_32x-r0" }
- - { url : "https://www.dropbox.com/s/eqxs4kx84omtkha/onie-installer-x86_64-accton_as6712_32x-r0?dl=1", dest : "onie-installer-x86_64-accton_as5712_54x-r0" }
+ - { url : "{{ accton_as6712_32x }}", dest : "onie-installer-x86_64-accton_as6712_32x-r0" }
+ - { url : "{{ accton_as5712_54x }}", dest : "onie-installer-x86_64-accton_as5712_54x-r0" }
tags:
- switch_support
+- name: Restart MAAS Services
+ service:
+ name={{ item }}
+ state=restarted
+ with_items:
+ - maas-proxy
+ - maas-regiond
+ - maas-clusterd
+ - maas-dhcpd
+ - bind9
+
- name: Wait for MAAS to Intialize (start)
pause:
seconds=30
@@ -170,8 +182,8 @@
action: get_url url=http://{{ mgmt_ip_address.stdout }}/MAAS/api/1.0/maas/ dest=/tmp
register: api_test
until: api_test.status_code is defined and api_test.status_code == 403
- retries: 6
- delay: 10
+ retries: 5
+ delay: 60
failed_when: api_test.status_code is not defined or api_test.status_code != 403
- name: Configure MAAS
diff --git a/roles/maas/vars/main.yml b/roles/maas/vars/main.yml
index 23b2835..b7f5a64 100644
--- a/roles/maas/vars/main.yml
+++ b/roles/maas/vars/main.yml
@@ -1,3 +1,6 @@
+accton_as5712_54x: 'http://178.33.61.6/putstorage/DownloadFileHash/AA90EC2D3A5A4A5QQWE3332069EWQS/onie-installer-x86_64-accton_as6712_32x-r0'
+accton_as6712_32x: 'http://178.33.61.6/putstorage/DownloadFileHash/AA90EC2D3A5A4A5QQWE3332069EWQS/onie-installer-x86_64-accton_as6712_32x-r0'
+
maas:
admin_email: "{{ admin_email | default('admin@cord.lab') }}"
user: "{{ maas_user | default('cord') }}"
@@ -15,8 +18,9 @@
# connected to the internet
# 'management' specifies the interface on which the head node will
# service DHCP and PXE boot requests
- external: "{{ external_iface | default('eth3') }}"
+ fabric: "{{ fabric_iface | default('eth0') }}"
management: "{{ management_iface | default('eth2') }}"
+ external: "{{ external_iface | default('eth3') }}"
networks:
# CHANGE: