google.cloud.gcp_colab_notebook_execution module – Creates a GCP Colab.NotebookExecution resource
Note
This module is part of the google.cloud collection (version 1.13.0).
You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install google.cloud. You need further requirements to be able to use this module, see Requirements for details.
To use it in a playbook, specify: google.cloud.gcp_colab_notebook_execution.
Synopsis
- ‘An instance of a notebook Execution’
Requirements
The below requirements are needed on the host that executes this module.
- python >= 3.8
- requests >= 2.18.4
- google-auth >= 2.25.1
Parameters
Parameter | Comments |
|---|---|
access_token string | The access token used to authenticate. |
auth_kind string / required | The type of credential used. Choices:
|
custom_environment_spec dictionary | Compute configuration to use for an execution job. |
|
machine_spec dictionary |
‘The machine configuration of the runtime.’. |
|
accelerator_count integer |
The number of accelerators used by the runtime. |
|
accelerator_type string |
The type of hardware accelerator used by the runtime. If specified, acceleratorCount must also be specified. |
|
machine_type string |
The Compute Engine machine type selected for the runtime. |
|
network_spec dictionary |
The network configuration for the runtime. |
|
enable_internet_access boolean |
Enable public internet access for the runtime. Choices:
|
|
network string |
The name of the VPC that this runtime is in. |
|
subnetwork string |
The name of the subnetwork that this runtime is in. |
|
persistent_disk_spec dictionary |
The configuration for the data disk of the runtime. |
|
disk_size_gb string |
The disk size of the runtime in GB. If specified, the diskType must also be specified. The minimum size is 10GB and the maximum is 65536GB. |
|
disk_type string |
The type of the persistent disk. |
dataform_repository_source dictionary | The Dataform Repository containing the input notebook. |
|
commit_sha string |
The commit SHA to read repository with. If unset, the file will be read at HEAD. |
|
dataform_repository_resource_name string / required |
The resource name of the Dataform Repository. |
direct_notebook_source dictionary | The content of the input notebook in ipynb format. |
|
content string / required |
The base64-encoded contents of the input notebook file. |
display_name string / required | The display name of the Notebook Execution. |
env_type string | Specifies which Ansible environment you’re running this module within. This should not be set unless you know what you’re doing. This only alters the User Agent string for any API requests. |
execution_timeout string | Max running time of the execution job in seconds (default 86400s / 24 hrs). |
execution_user string | The user email to run the execution as. |
gcs_notebook_source dictionary | The Cloud Storage uri for the input notebook. |
|
generation string |
The version of the Cloud Storage object to read. If unset, the current version of the object is read. See https://cloud.google.com/storage/docs/metadata#generation-number. |
|
uri string / required |
The Cloud Storage uri pointing to the ipynb file. |
gcs_output_uri string / required | The Cloud Storage location to upload the result to. Format:`gs://bucket-name`. |
location string / required | The location for the resource: https://cloud.google.com/colab/docs/locations. |
notebook_execution_job_id string | User specified ID for the Notebook Execution Job. |
notebook_runtime_template_resource_name string | The NotebookRuntimeTemplate to source compute configuration from. |
project string | The Google Cloud Platform project to use. |
scopes list / elements=string | Array of scopes to be used. |
service_account string | The service account to run the execution as. |
service_account_contents jsonarg | The contents of a Service Account JSON file, either in a dictionary or as a JSON string that represents it. |
service_account_email string | An optional service account email address if machineaccount is selected and the user does not wish to use the default email. |
service_account_file path | The path of a Service Account JSON file if serviceaccount is selected as type. |
state string | Whether the resource should exist in GCP. Choices:
|
Notes
Note
- API Reference: https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.notebookExecutionJobs
- Schedule a notebook run Guide: https://cloud.google.com/colab/docs/schedule-notebook-run
- For authentication, you can set auth_kind using the
GCP_AUTH_KINDenv variable. - For authentication, you can set service_account_file using the
GCP_SERVICE_ACCOUNT_FILEenv variable. - For authentication, you can set service_account_contents using the
GCP_SERVICE_ACCOUNT_CONTENTSenv variable. - For authentication, you can set service_account_email using the
GCP_SERVICE_ACCOUNT_EMAILenv variable. - For authentication, you can set access_token using the
GCP_ACCESS_TOKENenv variable. - For authentication, you can set scopes using the
GCP_SCOPESenv variable. - Environment variables values will only be used if the playbook values are not set.
- The
service_account_email,service_account_file,service_account_fileandaccess_tokenoptions are mutually exclusive.
Examples
- name: Create Basic Notebook Execution
vars:
nb_config:
cells:
- cell_type: code
execution_count: null
metadata: {}
outputs: []
source:
- print('Hello, World!')
metadata:
kernelspec:
display_name: Python 3
language: python
name: python3
language_info:
codemirror_mode:
name: ipython
version: 3
file_extension: .py
mimetype: text/x-python
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.8.5
nbformat: 4
nbformat_minor: 4
google.cloud.gcp_colab_notebook_execution:
state: present
display_name: my-notebook-execution
location: us-central1
direct_notebook_source:
content: "{{ nb_config | to_json | b64encode }}"
notebook_runtime_template_resource_name: projects/{{ gcp_project }}/locations/us-central1/notebookRuntimeTemplates/my-runtime-template
gcs_output_uri: gs://my-bucket
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
################################################################################
- name: Create Notebook Execution With Custom Environment
vars:
nb_config:
cells:
- cell_type: code
execution_count: null
metadata: {}
outputs: []
source:
- print('Hello, World!')
metadata:
kernelspec:
display_name: Python 3
language: python
name: python3
language_info:
codemirror_mode:
name: ipython
version: 3
file_extension: .py
mimetype: text/x-python
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.8.5
nbformat: 4
nbformat_minor: 4
google.cloud.gcp_colab_notebook_execution:
state: present
display_name: my-notebook-execution
location: us-central1
direct_notebook_source:
content: "{{ nb_config | to_json | b64encode }}"
notebook_runtime_template_resource_name: projects/{{ gcp_project }}/locations/us-central1/notebookRuntimeTemplates/my-runtime-template
custom_environment_spec:
machine_spec:
machine_type: n1-standard-4
accelerator_type: NVIDIA_TESLA_T4
accelerator_count: 1
persistent_disk_spec:
disk_type: pd-standard
disk_size_gb: 100
network_spec:
enable_internet_access: true
network: "projects/{{ gcp_project }}/global/networks/my-network"
gcs_output_uri: gs://my-bucket
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
################################################################################
- name: Create Notebook Execution With Dataform Repository Source
google.cloud.gcp_colab_notebook_execution:
state: present
display_name: my-notebook-execution
location: us-central1
dataform_repository_source:
commit_sha: deadbeef
dataform_repository_resource_name: projects/{{ gcp_project }}/locations/us-central1/dataform/repositories/my-dataform-repository
notebook_runtime_template_resource_name: projects/{{ gcp_project }}/locations/us-central1/notebookRuntimeTemplates/my-runtime-template
gcs_output_uri: gs://my-bucket
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Description |
|---|---|
changed boolean | Whether the resource was changed. Returned: always |
state string | The current state of the resource. Returned: always |
Collection links
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/projects/ansible/latest/collections/google/cloud/gcp_colab_notebook_execution_module.html