CORD-229 - updated to implement initial base switch provisioning
Change-Id: I3deca583dc2753e1a2c77629f1ee45f8b66223c8
diff --git a/build.gradle b/build.gradle
index 86c0888..ed2d757 100644
--- a/build.gradle
+++ b/build.gradle
@@ -28,8 +28,6 @@
deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'
dockerPath = project.hasProperty('dockerPath') ? project.getProperty('dockerPath') : '/usr/bin'
-
- vboxUser = project.hasProperty('vboxUser') ? project.getProperty('vboxUser') : 'cord'
}
// Switch Configuration Image
@@ -227,14 +225,10 @@
.p(config.seedServer.fabric_network, "fabric_network")
.p(config.seedServer.fabric_iface, "fabric_iface")
.p(config.seedServer.domain, "domain")
- }
-
- if (config.seedServer.port) {
- extraVars = extraVars.p(config.seedServer.port, "ansible_ssh_port")
- }
-
- if (vboxUser != "") {
- extraVars = extraVars.p(vboxUser, "power_helper_user")
+ .p(config.seedServer.virtualbox_support, "virtualbox_support")
+ .p(config.seedServer.power_helper_user, "power_helper_user")
+ .p(config.seedServer.power_helper_host, "power_helper_host")
+ .p(config.seedServer.port, "ansible_ssh_port")
}
if (config.otherServers) {
@@ -282,16 +276,10 @@
.p(config.seedServer.fabric_network, "fabric_network")
.p(config.seedServer.fabric_iface, "fabric_iface")
.p(config.seedServer.domain, "domain")
+ .p(config.seedServer.virtualbox_support, "virtualbox_support")
.p(config.seedServer.power_helper_user, "power_helper_user")
.p(config.seedServer.power_helper_host, "power_helper_host")
- }
-
- if (config.seedServer.port) {
- extraVars = extraVars.p(config.seedServer.port, "ansible_ssh_port")
- }
-
- if (vboxUser != "") {
- extraVars = extraVars.p(vboxUser, "power_helper_user")
+ .p(config.seedServer.port, "ansible_ssh_port")
}
if (config.otherServers) {
diff --git a/provisioner/handlers.go b/provisioner/handlers.go
index 6a7bb01..32812da 100644
--- a/provisioner/handlers.go
+++ b/provisioner/handlers.go
@@ -76,7 +76,13 @@
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
- err = c.dispatcher.Dispatch(&info, role, c.config.Script)
+
+ // If the request has a script set, override the default configuration
+ script := c.config.Script
+ if info.Script != "" {
+ script = info.Script
+ }
+ err = c.dispatcher.Dispatch(&info, role, script)
if err != nil {
log.Printf("[errpr] unable to dispatch provisioning request for node '%s' : %s", info.Name, err)
http.Error(w, err.Error(), http.StatusInternalServerError)
diff --git a/roles/fabric-switch/tasks/ofdpa.yml b/roles/fabric-switch/tasks/ofdpa.yml
index 2c643e8..21af257 100644
--- a/roles/fabric-switch/tasks/ofdpa.yml
+++ b/roles/fabric-switch/tasks/ofdpa.yml
@@ -5,14 +5,37 @@
validate_certs: false
dest: /mnt/flash2/ofdpa-i.12.1.1_12.1.1%2Baccton1.7-1_amd64.deb
+- name: Verify Service Exists
+ stat:
+ path: /etc/init.d/ofdpa
+ register: ofdpa_stat
+ changed_when: false
+ failed_when: false
+
- name: OpenFlow Agent Stopped
service: name=ofdpa state=stopped
+ when: ofdpa_stat.stat.exists
+
+- name: Verify Distributeion Release File
+ stat:
+ path: /etc/lsb-release
+ register: lsb_stat
+ changed_when: false
+ failed_when: false
+
+- name: Verify Distribute Name
+ shell: grep -i ubuntu /etc/lsb-release | wc -l
+ register: dist
+ changed_when: false
+ failed_when: false
- name: Openflow Agent
apt: deb="/mnt/flash2/ofdpa-i.12.1.1_12.1.1%2Baccton1.7-1_amd64.deb" force=true
+ when: not lsb_stat.stat.exists or dist.stdout == "0"
- name: OpenFlow Agent Started
service: name=ofdpa state=started
+ when: not lsb_stat.stat.exists or dist.stdout == "0"
- name: Mark Persist Openflow Agent
command: persist /etc/accton/ofdpa.conf
diff --git a/roles/head-node/files/compute-node.yml b/roles/head-node/files/compute-node.yml
index 7fb41f0..4a6a50d 100644
--- a/roles/head-node/files/compute-node.yml
+++ b/roles/head-node/files/compute-node.yml
@@ -1,4 +1,4 @@
- hosts: all
remote_user: ubuntu
roles:
- - compute-node
+ - {{ provision.role }}
diff --git a/roles/head-node/files/compute-node.yml.j2 b/roles/head-node/files/compute-node.yml.j2
deleted file mode 100644
index 4a6a50d..0000000
--- a/roles/head-node/files/compute-node.yml.j2
+++ /dev/null
@@ -1,4 +0,0 @@
-- hosts: all
- remote_user: ubuntu
- roles:
- - {{ provision.role }}
diff --git a/roles/head-node/files/do-switch b/roles/head-node/files/do-switch
new file mode 100755
index 0000000..27c6819
--- /dev/null
+++ b/roles/head-node/files/do-switch
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+ID=$1
+HOSTNAME=$2
+IP=$3
+MAC=$4
+ROLE=$5
+
+LOG=/etc/maas/ansible/logs/$ID.log
+
+echo "" >> $LOG
+echo "***** BEGIN *****" >> $LOG
+echo "PROVISION $ID $HOSTNAME $IP $MAC $ROLE" >> $LOG
+
+SKIP_TAGS=
+EXTRA_VARS=--extra-vars=ansible_ssh_pass=onl
+
+echo "ANSIBLE_ROLES_PATH=/etc/maas/ansible/roles ansible-playbook -i $IP, /etc/maas/ansible/switch-node.yml $SKIP_TAGS $EXTRA_VARS" >> $LOG
+ANSIBLE_ROLES_PATH=/etc/maas/ansible/roles ansible-playbook -i $IP, /etc/maas/ansible/switch-node.yml $SKIP_TAGS $EXTRA_VARS >> $LOG
+
diff --git a/roles/head-node/files/switch-node.yml b/roles/head-node/files/switch-node.yml
new file mode 100644
index 0000000..3539060
--- /dev/null
+++ b/roles/head-node/files/switch-node.yml
@@ -0,0 +1,4 @@
+- hosts: all
+ remote_user: root
+ roles:
+ - fabric-switch
diff --git a/roles/head-node/tasks/main.yml b/roles/head-node/tasks/main.yml
index d084a67..6735f20 100644
--- a/roles/head-node/tasks/main.yml
+++ b/roles/head-node/tasks/main.yml
@@ -26,11 +26,14 @@
- name: Ensure Ansible Provisioning Script
become: yes
copy:
- dest=/etc/maas/ansible/do-ansible
- src=files/do-ansible
+ dest=/etc/maas/ansible/{{ item }}
+ src=files/{{ item }}
owner=maas
group=maas
mode=0755
+ with_items:
+ - do-ansible
+ - do-switch
- name: Ensure Provisioning Log Directory
become: yes
@@ -44,8 +47,11 @@
- name: Ensure Compute Node Playbook
become: yes
template:
- src=files/compute-node.yml.j2
- dest=/etc/maas/ansible/compute-node.yml
+ src=files/{{ item }}
+ dest=/etc/maas/ansible/{{ item }}
owner=maas
group=maas
mode=0644
+ with_items:
+ - compute-node.yml
+ - switch-node.yml
diff --git a/roles/maas/templates/automation-compose.yml.j2 b/roles/maas/templates/automation-compose.yml.j2
index 5dc952b..40d7f98 100644
--- a/roles/maas/templates/automation-compose.yml.j2
+++ b/roles/maas/templates/automation-compose.yml.j2
@@ -42,6 +42,7 @@
links:
- provisioner
environment:
+ - "SWITCHQ_SCRIPT=/etc/maas/ansible/do-switch"
- "SWITCHQ_PROVISION_URL=http://provisioner:4243/provision/"
- "SWITCHQ_PROVISION_TTL=0s"
- "SWITCHQ_DEFAULT_ROLE=fabric-switch"