def request_cert(name, master, ticket, port='5665'):
 ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''}
 cert = '/etc/icinga2/pki/ca.crt'
 if os.path.isfile(cert):
  ret['comment'] = 'No execution needed. Cert: {0} already exists.'.format(cert)
  return ret
 if __opts__['test']:
  ret['result'] = None
  ret['comment'] = 'Certificate request from icinga2 master would be executed'
  return ret
 cert_request = __salt__['icinga2.request_cert'](name, master, ticket, port)
 if (not cert_request):
  ret['comment'] = 'Certificate request from icinga2 master executed'
  ret['changes']['cert'] = 'Executed. Certificate requested: {0}'.format(cert)
  return ret
 ret['comment'] = 'FAILED. Certificate requested failed with exit code: {0}'.format(cert_request)
 ret['result'] = False
 return ret

def request_cert ( name , master , ticket , port = '5665' ) : ret = { 'name' : name , 'changes' : { } , 'result' : True , 'comment' : '' } cert = '/etc/icinga2/pki/ca.crt' if os . path . isfile ( cert ) : ret [ 'comment' ] = 'No execution needed. Cert: {0} already exists.' . format ( cert ) return ret if __opts__ [ 'test' ] : ret [ 'result' ] = None ret [ 'comment' ] = 'Certificate request from icinga2 master would be executed' return ret cert_request = __salt__ [ 'icinga2.request_cert' ] ( name , master , ticket , port ) if ( not cert_request ) : ret [ 'comment' ] = 'Certificate request from icinga2 master executed' ret [ 'changes' ] [ 'cert' ] = 'Executed. Certificate requested: {0}' . format ( cert ) return ret ret [ 'comment' ] = 'FAILED. Certificate requested failed with exit code: {0}' . format ( cert_request ) ret [ 'result' ] = False return ret
request ca cert from master icinga2 node .