add filter plugins, have juju add machines with full dns names
diff --git a/filter_plugins/format_string.py b/filter_plugins/format_string.py
new file mode 100644
index 0000000..8210d89
--- /dev/null
+++ b/filter_plugins/format_string.py
@@ -0,0 +1,16 @@
+from jinja2.utils import soft_unicode
+
+def format_string(string, pattern):
+    """
+    formats the string with the value passed to it
+    basicaly the reverse order of standard "format()"
+    """
+    return soft_unicode(pattern) % (string)
+
+class FilterModule(object):
+
+    def filters(self):
+        return {
+            'format_string': format_string,
+        }
+
diff --git a/filter_plugins/genmac.py b/filter_plugins/genmac.py
new file mode 100644
index 0000000..5bdee2a
--- /dev/null
+++ b/filter_plugins/genmac.py
@@ -0,0 +1,29 @@
+import hashlib
+import netaddr
+
+def genmac(value, prefix='', length=12):
+    '''
+    deterministically generates a "random" MAC with a configurable prefix
+    '''
+
+    # from: http://serverfault.com/questions/40712/what-range-of-mac-addresses-can-i-safely-use-for-my-virtual-machines
+    if prefix == ''
+        mac_prefix = "0ac04d" # random "cord"-esque
+
+    # deterministically generate a value
+    h = hashlib.new('sha1')
+    h.update(value)
+
+    # build/trim MAC
+    mac_string = (mac_prefix + h.hexdigest())[0:length]
+
+    return netaddr.EUI(mac_string)
+
+class FilterModule(object):
+    ''' MAC generation filter '''
+    filter_map = {
+        'genmac': genmac,
+    }
+
+    def filters(self):
+         return self.filter_map
diff --git a/roles/juju-setup/tasks/main.yml b/roles/juju-setup/tasks/main.yml
index 365aed9..bc85ae2 100644
--- a/roles/juju-setup/tasks/main.yml
+++ b/roles/juju-setup/tasks/main.yml
@@ -73,13 +73,18 @@
 - name: Obtain Juju Facts for creating machines
   juju_facts:
 
+- name: Pause to let Juju settle before adding machines
+  pause:
+    prompt="Waiting for Juju..."
+    seconds=20
+
 # For setwise operations on desired vs Juju state:
 # list of active juju_machines names: juju_machines.keys()
 # list of active juju_services names: juju_services.keys()
 
 - name: Add machines to Juju
   command: "juju add-machine ssh:{{ item }}"
-  with_items: "{{ head_vm_list | map(attribute='service') | list | reject('undefined') | difference( juju_machines.keys() ) }}"
+  with_items: "{{ head_vm_list | map(attribute='service') | list | reject('undefined') | map('format_string', '%s.'~site_suffix ) | difference( juju_machines.keys() ) }}"
 
 # run this again, so machines will be in the juju_machines list
 - name: Obtain Juju Facts after machine creation
@@ -97,8 +102,6 @@
   command: "juju deploy {{ charm_versions[item] | default(item) }} --config={{ juju_config_path }}"
   with_items: "{{ standalone_service_list | difference( juju_services.keys() ) }}"
 
-# FIXME: ignoring errors when creating relationships.
-# Previous method wasn't idempotent either
 - name: Create relations between services
   command: "juju add-relation '{{ item.0.name }}' '{{ item.1 }}'"
   register: juju_relation
@@ -112,7 +115,7 @@
   juju_facts:
 
 # 900s = 15m. Usually takes 10-12m on cloudlab for relations to come up
-# Only checks for first port in list.
+# Only checks for first port in list
 - name: Wait for juju services on VM's have open ports
   wait_for:
     host={{ item.name }}
@@ -121,7 +124,7 @@
   with_items: "{{ head_vm_list | selectattr('forwarded_ports', 'defined') | list }}"
 
 # secondary wait, as waiting on ports isn't enough. Probably only need one of these...
-# 10m max wait
+# 40*15s = 600s = 10m max wait
 - name: Wait for juju services to start
   action: command juju status --format=summary
   register: juju_summary
@@ -149,3 +152,4 @@
 
 - name: update-ca-certificates on xos vm
   command: ansible xos-1 -b -u ubuntu -m command -a "update-ca-certificates"
+