def modify_tags(gce, module, node, tags, state='present'):
 zone = node.extra['zone'].name
 existing_tags = node.extra['tags']
 tags = [x.lower() for x in tags]
 tags_changed = []
 if (state == 'absent'):
  tags_changed = _intersect_items(existing_tags, tags)
  if (not tags_changed):
   return (False, None)
  node_tags = _get_changed_items(existing_tags, tags)
 else:
  tags_changed = _get_changed_items(tags, existing_tags)
  if (not tags_changed):
   return (False, None)
  node_tags = _union_items(existing_tags, tags)
 try:
  gce.ex_set_node_tags(node, node_tags)
  return (True, tags_changed)
 except (GoogleBaseError, InvalidRequestError) as e:
  module.fail_json(msg=str(e), changed=False)

def modify_tags ( gce , module , node , tags , state = 'present' ) : zone = node . extra [ 'zone' ] . name existing_tags = node . extra [ 'tags' ] tags = [ x . lower ( ) for x in tags ] tags_changed = [ ] if ( state == 'absent' ) : tags_changed = _intersect_items ( existing_tags , tags ) if ( not tags_changed ) : return ( False , None ) node_tags = _get_changed_items ( existing_tags , tags ) else : tags_changed = _get_changed_items ( tags , existing_tags ) if ( not tags_changed ) : return ( False , None ) node_tags = _union_items ( existing_tags , tags ) try : gce . ex_set_node_tags ( node , node_tags ) return ( True , tags_changed ) except ( GoogleBaseError , InvalidRequestError ) as e : module . fail_json ( msg = str ( e ) , changed = False )
modify tags on an instance .