Commits

intronic  committed 56ead42

some mods to get this running on NeCTAR RC

  • Participants
  • Parent commits d894af3

Comments (0)

Files changed (1)

File mi_fabfile.py

 Usage:
     fab -f mi_fabfile.py -i full_path_to_private_key_file -H servername <configure_MI[:do_rebundle] | rebundle>
 """
+
+# __requires__ = 'Fabric==1.2.0'
+# import sys
+# from pkg_resources import load_entry_point
+
+# #if __name__ == '__main__':
+# #    sys.exit(
+# #        load_entry_point('Fabric==1.2.0', 'console_scripts', 'fab')()
+# #    )
+
+
 import os, os.path, time, contextlib, tempfile
 import datetime as dt
 from contextlib import contextmanager
     env.galaxy_files = '/mnt/galaxy'
     env.shell = "/bin/bash -l -c"
     env.sources_file = "/etc/apt/sources.list"
-    env.std_sources = ["deb http://watson.nci.nih.gov/cran_mirror/bin/linux/ubuntu lucid/"]
+    env.std_sources = ["deb http://watson.nci.nih.gov/cran_mirror/bin/linux/ubuntu maverick/"]
 
 
 # == Templates
     """
     _check_fabric_version()
     time_start = dt.datetime.utcnow()
+    print "#########################"
     print "Configuring host '%s'. Start time: %s" % (env.hosts[0], time_start)
+    print "#########################"
     _amazon_ec2_environment()
+    print "#########################"
+    print "Configuring system '%s'. Start time: %s" % (env.hosts[0], dt.datetime.utcnow())
+    print "#########################"
     _update_system()
+    print "#########################"
+    print "Configuring packages '%s'. Start time: %s" % (env.hosts[0], dt.datetime.utcnow())
+    print "#########################"
     _required_packages() 
+    print "#########################"
+    print "Configuring users '%s'. Start time: %s" % (env.hosts[0], dt.datetime.utcnow())
+    print "#########################"
     _setup_users()
+    print "#########################"
+    print "Configuring programs '%s'. Start time: %s" % (env.hosts[0], dt.datetime.utcnow())
+    print "#########################"
     _required_programs()
+    print "#########################"
+    print "Configuring libraries '%s'. Start time: %s" % (env.hosts[0], dt.datetime.utcnow())
+    print "#########################"
     _required_libraries()
+    print "#########################"
+    print "Configuring environment '%s'. Start time: %s" % (env.hosts[0], dt.datetime.utcnow())
+    print "#########################"
     _configure_environment() 
     time_end = dt.datetime.utcnow()
+    print "#########################"
     print "Duration of machine configuration: %s" % str(time_end-time_start)
+    print "#########################"
     if do_rebundle == 'do_rebundle':
         do_rebundle = True
         reboot_if_needed = True
 def _install_boto():
     install_dir = env.install_dir + "/boto"
     with contextlib.nested(cd(env.install_dir), settings(hide('stdout'))):
-        sudo("git clone http://github.com/boto/boto.git")
-        with cd(install_dir):
-            sudo("python setup.py install")
-            version = run('python -c"import boto; print boto.__version__"')
-            print(green("----- boto %s installed -----" % version))
+        # MJP - this step fails with an error:
+#[115.146.92.41] sudo: git clone http://github.com/boto/boto.git
+#Fatal error: sudo() encountered an error (return code 128) while executing 'git clone http://github.com/boto/boto.git'
+        # Also, OpenStack doesnt work with boto v2.0 (http://www.rc.nectar.org.au/, see comment "I'm using boto 2.0 and I can't stop instances")
+        # so as a work around I load the standard 1.9 python-boto package
+        # which also has an attribute Version instead of __version__
+        sudo("sudo apt-get install python-boto")
+        # with cd(install_dir):
+        #     sudo("python setup.py install")
+        #     version = run('python -c"import boto; print boto.__version__"')
+        #     print(green("----- boto %s installed -----" % version))
+        version = run('python -c"import boto; print boto.Version"')
+        print(green("----- boto %s installed -----" % version))
 
 # == environment
 
     _put_as_user(landscape_sysinfo_template_file, remote_file, user='root', mode=755)
     os.remove(landscape_sysinfo_template_file)
     
-    sudo('if [ -f /etc/update-motd.d/51_update_motd ]; then rm -f /etc/update-motd.d/51_update_motd; fi')
+    # MJP: skip this, it gives an error (even though the same thing on the command line is fine)
+# [115.146.92.41] out: 
+# Fatal error: sudo() encountered an error (return code 1) while executing 'if [ -f /etc/update-motd.d/51_update_motd ]; then rm -f /etc/update-motd.d/51_update_motd; fi'
+# Aborting.
+
+    #sudo('if [ -f /etc/update-motd.d/51_update_motd ]; then rm -f /etc/update-motd.d/51_update_motd; fi')
     
     append('/etc/bash.bashrc', ['alias lt=\"ls -ltr\"', 'alias mroe=more'], use_sudo=True)
 
         print >> f, xvfb_default_template
     remote_file = '/etc/default/xvfb'
     _put_as_user(xvfb_default_file, remote_file, user='root')
-    sudo("ln -s /etc/init.d/xvfb /etc/rc0.d/K01xvfb")
-    sudo("ln -s /etc/init.d/xvfb /etc/rc1.d/K01xvfb")
-    sudo("ln -s /etc/init.d/xvfb /etc/rc2.d/S99xvfb")
-    sudo("ln -s /etc/init.d/xvfb /etc/rc3.d/S99xvfb")
-    sudo("ln -s /etc/init.d/xvfb /etc/rc4.d/S99xvfb")
-    sudo("ln -s /etc/init.d/xvfb /etc/rc5.d/S99xvfb")
-    sudo("ln -s /etc/init.d/xvfb /etc/rc6.d/K01xvfb")
+    sudo("ln -sf /etc/init.d/xvfb /etc/rc0.d/K01xvfb")
+    sudo("ln -sf /etc/init.d/xvfb /etc/rc1.d/K01xvfb")
+    sudo("ln -sf /etc/init.d/xvfb /etc/rc2.d/S99xvfb")
+    sudo("ln -sf /etc/init.d/xvfb /etc/rc3.d/S99xvfb")
+    sudo("ln -sf /etc/init.d/xvfb /etc/rc4.d/S99xvfb")
+    sudo("ln -sf /etc/init.d/xvfb /etc/rc5.d/S99xvfb")
+    sudo("ln -sf /etc/init.d/xvfb /etc/rc6.d/K01xvfb")
     sudo("mkdir /var/lib/xvfb; chown root:root /var/lib/xvfb; chmod 0755 /var/lib/xvfb")
     print(green("----- configured xvfb -----"))