New in version 2.4.
The below requirements are needed on the host that executes this module.
Parameter  | 
        Choices/Defaults  | 
                    Comments  | 
    
|---|---|---|
| 
                 
                        labels
                                                                             
                 | 
                            
                 | 
                                                            
                 A list of labels (key/value pairs) to add or remove for the resource. 
                                                                                             | 
        
| 
                 
                        resource_location
                                                                             
                 | 
                            
                 | 
                                                            
                 The location of resource (global, us-central1-f, etc.) 
                                                                                             | 
        
| 
                 
                        resource_name
                                                                             
                 | 
                            
                 | 
                                                            
                 The name of resource. 
                                                                                             | 
        
| 
                 
                        resource_type
                                                                             
                 | 
                            
                 | 
                                                            
                 The type of resource (instances, disks, snapshots, images) 
                                                                                             | 
        
| 
                 
                        resource_url
                                                                             
                 | 
                            
                 | 
                                                            
                 The 'self_link' for the resource (instance, disk, snapshot, etc) 
                                                                                             | 
        
Note
- name: Add labels on an existing instance (using resource_url)
  gce_labels:
    service_account_email: "{{ service_account_email }}"
    credentials_file: "{{ credentials_file }}"
    project_id: "{{ project_id }}"
    labels:
      webserver-frontend: homepage
      environment: test
      experiment-name: kennedy
    resource_url: https://www.googleapis.com/compute/beta/projects/myproject/zones/us-central1-f/instances/example-instance
    state: present
- name: Add labels on an image (using resource params)
  gce_labels:
    service_account_email: "{{ service_account_email }}"
    credentials_file: "{{ credentials_file }}"
    project_id: "{{ project_id }}"
    labels:
      webserver-frontend: homepage
      environment: test
      experiment-name: kennedy
    resource_type: images
    resource_location: global
    resource_name: my-custom-image
    state: present
- name: Remove specified labels from the GCE instance
  gce_labels:
    service_account_email: "{{ service_account_email }}"
    credentials_file: "{{ credentials_file }}"
    project_id: "{{ project_id }}"
    labels:
      environment: prod
      experiment-name: kennedy
    resource_url: https://www.googleapis.com/compute/beta/projects/myproject/zones/us-central1-f/instances/example-instance
    state: absent
Common return values are documented here, the following are the fields unique to this module:
Key  | 
        Returned  | 
        Description  | 
    
|---|---|---|
| 
                 
                        labels
                         
                dict 
                     | 
            Always.  | 
            
                 List of labels that exist on the resource. 
                                            Sample: 
                                                    [{'environment': 'test', 'webserver-frontend': 'homepage', 'environment-name': 'kennedy'}] 
                                         | 
        
| 
                 
                        resource_location
                         
                str 
                     | 
            Always.  | 
            
                 The location of the GCE resource. 
                                            Sample: 
                                                    us-central1-f 
                                         | 
        
| 
                 
                        resource_name
                         
                str 
                     | 
            Always.  | 
            
                 The name of the GCE resource. 
                                            Sample: 
                                                    my-happy-little-instance 
                                         | 
        
| 
                 
                        resource_type
                         
                str 
                     | 
            Always.  | 
            
                 The type of the GCE resource. 
                                            Sample: 
                                                    instances 
                                         | 
        
| 
                 
                        resource_url
                         
                str 
                     | 
            Always.  | 
            
                 The 'self_link' of the GCE resource. 
                                            Sample: 
                                                    https://www.googleapis.com/compute/beta/projects/myproject/zones/us-central1-f/instances/example-instance 
                                         | 
        
| 
                 
                        state
                         
                str 
                     | 
            Always.  | 
            
                 state of the labels 
                                            Sample: 
                                                    present 
                                         | 
        
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
Hint
If you notice any issues in this documentation you can edit this document to improve it.