cloudera.services.ml_project_file module – Manage a file within a Cloudera Machine Learning (CML) project

Note

This module is part of the cloudera.services collection (version 1.0.0).

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 git+https://github.com/cloudera-labs/cloudera.services.git.

To use it in a playbook, specify: cloudera.services.ml_project_file.

New in cloudera.services 1.0.0

Synopsis

  • Upload or delete a file within a Cloudera Machine Learning (CML) project.

  • Paths are relative to the project root (/home/cdsw).

  • The module supports check_mode.

Parameters

Parameter

Comments

api_key

aliases: token

string / required

The CML API key (bearer token) used to authenticate to the Workspace API.

If not set, the value of the CML_API_KEY environment variable is used.

client_cert

path

The path to a client certificate for authenticating to the API endpoint.

client_key

path

The path to a client key for authenticating to the API endpoint.

content

string

The literal contents to upload to the file.

Mutually exclusive with src.

Required when creating a file unless src is set.

debug

aliases: debug_endpoints

boolean

A flag to enable debug logging of the module’s execution.

Choices:

  • false ← (default)

  • true

force

boolean

Whether to re-upload the file even when it already exists.

Choices:

  • false ← (default)

  • true

force_basic_auth

boolean

A flag to force basic authentication for API requests.

Choices:

  • false ← (default)

  • true

http_agent

aliases: user_agent

string

The User-Agent string to send with API requests.

Default: "cloudera-services-module"

page_size

aliases: default_page_size

integer

The number of items to return per page in a paginated API response.

Default: 100

path

aliases: dest, file

string / required

The destination path of the file within the project, relative to the project root.

project_id

string

The unique identifier of the enclosing project.

Mutually exclusive with project_name.

project_name

string

The name of the enclosing project.

Mutually exclusive with project_id.

src

path

The path to a local file whose contents are uploaded.

Mutually exclusive with content.

Required when creating a file unless content is set.

state

string

The declarative state of the file.

Choices:

  • "present" ← (default)

  • "absent"

timeout

aliases: timeout_seconds

integer

The timeout in seconds for any API requests.

Default: 60

url

aliases: endpoint, endpoint_url, workspace_url

string / required

The base URL of the CML Workspace API endpoint, including the port if necessary.

If not set, the value of the CML_ENDPOINT environment variable is used.

url_password

string

The password for authenticating to the API endpoint.

url_username

string

The username for authenticating to the API endpoint.

use_gssapi

boolean

A flag to enable or disable GSSAPI authentication for API requests.

Choices:

  • false ← (default)

  • true

use_proxy

boolean

A flag to enable or disable the use of a proxy for API requests.

Choices:

  • false

  • true ← (default)

validate_certs

boolean

A flag to enable or disable SSL certificate validation for API requests.

Choices:

  • false

  • true ← (default)

Examples

- name: Upload a file from literal content
  cloudera.services.ml_project_file:
    url: "https://ml-workspace.example.com"
    api_key: "{{ cml_api_key }}"
    project_name: my-project
    path: app.py
    content: |
      print("hello")
    state: present

- name: Upload a local file to a nested path
  cloudera.services.ml_project_file:
    project_id: "{{ project_id }}"
    path: src/run.py
    src: ./files/run.py

- name: Force re-upload of an existing file
  cloudera.services.ml_project_file:
    project_id: "{{ project_id }}"
    path: app.py
    content: "print('updated')"
    force: true

- name: Delete a file
  cloudera.services.ml_project_file:
    project_id: "{{ project_id }}"
    path: app.py
    state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

file

dictionary

The project file details.

Returned: always

file_size

string

The size of the file in bytes.

Returned: when available

is_dir

boolean

Whether the path is a directory.

Returned: when available

path

string

The path of the file, relative to the project root.

Returned: always

sdk_out

string

Returns the captured REST API log.

Returned: when supported

sdk_out_lines

list / elements=string

Returns a list of each line of the captured REST API log.

Returned: when supported

Authors

  • Webster Mudge (@wmudge)