def package_installed(name, ignore_check=False, prevent_pending=False, image=None, restart=False):
 ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
 old = __salt__['dism.installed_packages']()
 package_info = __salt__['dism.package_info'](name)
 if (package_info['Package Identity'] in old):
  ret['comment'] = 'The package {0} is already installed: {1}'.format(name, package_info['Package Identity'])
  return ret
 if __opts__['test']:
  ret['changes']['package'] = '{0} will be installed'.format(name)
  ret['result'] = None
  return ret
 status = __salt__['dism.add_package'](name, ignore_check, prevent_pending, image, restart)
 if (status['retcode'] not in [0, 1641, 3010]):
  ret['comment'] = 'Failed to install {0}: {1}'.format(name, status['stdout'])
  ret['result'] = False
 new = __salt__['dism.installed_packages']()
 changes = salt.utils.compare_lists(old, new)
 if changes:
  ret['comment'] = 'Installed {0}'.format(name)
  ret['changes'] = status
  ret['changes']['package'] = changes
 return ret

def package_installed ( name , ignore_check = False , prevent_pending = False , image = None , restart = False ) : ret = { 'name' : name , 'result' : True , 'comment' : '' , 'changes' : { } } old = __salt__ [ 'dism.installed_packages' ] ( ) package_info = __salt__ [ 'dism.package_info' ] ( name ) if ( package_info [ 'Package Identity' ] in old ) : ret [ 'comment' ] = 'The package {0} is already installed: {1}' . format ( name , package_info [ 'Package Identity' ] ) return ret if __opts__ [ 'test' ] : ret [ 'changes' ] [ 'package' ] = '{0} will be installed' . format ( name ) ret [ 'result' ] = None return ret status = __salt__ [ 'dism.add_package' ] ( name , ignore_check , prevent_pending , image , restart ) if ( status [ 'retcode' ] not in [ 0 , 1641 , 3010 ] ) : ret [ 'comment' ] = 'Failed to install {0}: {1}' . format ( name , status [ 'stdout' ] ) ret [ 'result' ] = False new = __salt__ [ 'dism.installed_packages' ] ( ) changes = salt . utils . compare_lists ( old , new ) if changes : ret [ 'comment' ] = 'Installed {0}' . format ( name ) ret [ 'changes' ] = status ret [ 'changes' ] [ 'package' ] = changes return ret
install a package .