def activate_packages(module, port_path, packages):
 activate_c = 0
 for package in packages:
  if (not query_package(module, port_path, package)):
   module.fail_json(msg=('failed to activate %s, package(s) not present' % package))
  if query_package(module, port_path, package, state='active'):
   continue
  (rc, out, err) = module.run_command(('%s activate %s' % (port_path, package)))
  if (not query_package(module, port_path, package, state='active')):
   module.fail_json(msg=('failed to activate %s: %s' % (package, out)))
  activate_c += 1
 if (activate_c > 0):
  module.exit_json(changed=True, msg=('activated %s package(s)' % activate_c))
 module.exit_json(changed=False, msg='package(s) already active')

def activate_packages ( module , port_path , packages ) : activate_c = 0 for package in packages : if ( not query_package ( module , port_path , package ) ) : module . fail_json ( msg = ( 'failed to activate %s, package(s) not present' % package ) ) if query_package ( module , port_path , package , state = 'active' ) : continue ( rc , out , err ) = module . run_command ( ( '%s activate %s' % ( port_path , package ) ) ) if ( not query_package ( module , port_path , package , state = 'active' ) ) : module . fail_json ( msg = ( 'failed to activate %s: %s' % ( package , out ) ) ) activate_c += 1 if ( activate_c > 0 ) : module . exit_json ( changed = True , msg = ( 'activated %s package(s)' % activate_c ) ) module . exit_json ( changed = False , msg = 'package(s) already active' )
activate a package if its inactive .