Esempio n. 1
0
    def run_cmd(self):
        '''
        Prepare and run the ansible playbook command for
        the operation type specified in the constructor
        '''
        self._rundir  = self._cluster.get_vmi()._rundir
        emboxtype = self._cluster.config()['em']['boxtype']
        if not vagboxes.em_support(emboxtype):
            # Don't even try to install if the boxtype does not support an EM
            print 'supported is %s' % vagboxes.list_all(flags=vagboxes.FLAG_EM)
            Log.error("boxtype %s does not support the EM!" % emboxtype)
            return 1
        
        self._pkgtype = vagboxes.get_default_pkgtype(emboxtype)
        vmgr = emvmgr.EMVersionManager()
        (emversion, self._pkgfile) = vmgr.retrieve(self._cluster.config()['em']['version'], self._pkgtype)
        self._pkgname = os.path.split( self._pkgfile )[1]
        
        (ansible_yml,cmdargs) = self._prepare_playbook_install()

        extra_playdir = self._cluster.get_extra_playbook_dir()
        p = PlaybookMgr( os.path.basename(self._rundir), extra_playdir )

        # create ansible inventory file with list of hosts
        emrole = self._cluster.config()['em']['role']
        iplist = [ self._cluster.machine(emrole)['ip'] ]
        ipdict = { 'all' : iplist }
        p.write_inventory( 'emdefault', ipdict )

        # create ansible.cfg file
        self._idbuser = self._cluster.config()['idbuser']
        f = open( common.props['vmi.vagrantvmi.sshkey'] )
        keytext = ''.join(f.readlines())
        p.config_ssh( self._idbuser, keytext )

        # execute playbook thru PlaybookMgr
        Log.info("Running %s EM pkg install playbook; --extra-vars=%s" % (ansible_yml,cmdargs))
        rc, results, out, err = p.run_playbook(ansible_yml, 'emdefault', playbook_args=cmdargs)
        return rc
Esempio n. 2
0
                 print 'ERROR - unable to add /opt/autooam NFS export'
             else:
                 print 'Your /opt/autooam NFS export is now configured.'
         else:
             print 'Your /opt/autooam NFS export is already configured.'
 
     print ''
     print 'Next we will check to see if you need to install any vagrant boxes'
     
     rc = os.system('which vagrant') >> 8
     if rc != 0:
         print 'ERROR - it looks like vagrant is not setup on this machine.  Contact your admin'
     else:
         these_boxes = list_boxes()
         need_to_update = []
         for b in vagboxes.list_all():
             if not b in these_boxes:
                 need_to_update.append(b)
             
         if len(need_to_update):
             print "You are missing one or more vagrant boxes, would you like to install(this may take awhile...)? (y) ",
             ans = sys.stdin.readline().strip().lower()
             if ans != 'n':
                 for b in vagboxes.list_all():
                     try:
                         these_boxes.index(b)
                         print 'Skipping %s, already installed.' % (b)
                     except:
                         print 'Will install box %s.' % (b)
                         boxrepo = '/net/srvengcm1/Calpont/exports/vagrant_boxes'
                         if not os.path.exists(boxrepo):