death114 发表于 2018-7-30 12:32:54

ansible callbacks-TimeAPI

def compute(self, runner_results, setup=False, poll=False, ignore_errors=False):  
      ''' walk through all results and increment stats '''
  
      for (host, value) in runner_results.get('contacted', {}).iteritems():
  
            if not ignore_errors and (('failed' in value and bool(value['failed'])) or
  
                ('failed_when_result' in value and ] or ['rc' in value and value['rc'] != 0])):
  
                self._increment('failures', host)
  
            elif 'skipped' in value and bool(value['skipped']):
  
                self._increment('skipped', host)
  
            elif 'changed' in value and bool(value['changed']):
  
                if not setup and not poll:
  
                  self._increment('changed', host)
  
                self._increment('ok', host)
  
            else:
  
                if not poll or ('finished' in value and bool(value['finished'])):
  
                  self._increment('ok', host)
  
      for (host, value) in runner_results.get('dark', {}).iteritems():
  
            self._increment('dark', host)
  
      global lazy_out
  
      lazy_out = runner_results
  
      print lazy_out.get('contacted').get(host).get('stdout')
  
    def summarize(self, host):
  
      ''' return information about a particular host '''
  
      return dict(
  
            ok          = self.ok.get(host, 0),
  
            failures    = self.failures.get(host, 0),
  
            unreachable = self.dark.get(host,0),
  
            changed   = self.changed.get(host, 0),
  
            skipped   = self.skipped.get(host, 0),
  
            #haha       = lazy_out.values().values()['stdout'],
  
            haha      = lazy_out.get('contacted').get(host).get('stdout')
  
      )
页: [1]
查看完整版本: ansible callbacks-TimeAPI