community / community.general / 6.6.8 / module / rax_files_objects Upload, download, and delete objects in Rackspace Cloud Files Authors: Paul Durivage (@angstwad)community.general.rax_files_objects (6.6.8) — module
Install with ansible-galaxy collection install community.general:==6.6.8
collections: - name: community.general version: 6.6.8
Upload, download, and delete objects in Rackspace Cloud Files.
This module relies on the C(pyrax) package which is deprecated in favour of using Openstack API.
Unless maintainers step up to work on the module, it will be marked as deprecated in community.general 7.0.0 and removed in version 9.0.0.
- name: "Test Cloud Files Objects" hosts: local gather_facts: false tasks: - name: "Get objects from test container" community.general.rax_files_objects: container: testcont dest: ~/Downloads/testcont - name: "Get single object from test container" community.general.rax_files_objects: container: testcont src: file1 dest: ~/Downloads/testcont - name: "Get several objects from test container" community.general.rax_files_objects: container: testcont src: file1,file2,file3 dest: ~/Downloads/testcont - name: "Delete one object in test container" community.general.rax_files_objects: container: testcont method: delete dest: file1 - name: "Delete several objects in test container" community.general.rax_files_objects: container: testcont method: delete dest: file2,file3,file4 - name: "Delete all objects in test container" community.general.rax_files_objects: container: testcont method: delete - name: "Upload all files to test container" community.general.rax_files_objects: container: testcont method: put src: ~/Downloads/onehundred - name: "Upload one file to test container" community.general.rax_files_objects: container: testcont method: put src: ~/Downloads/testcont/file1 - name: "Upload one file to test container with metadata" community.general.rax_files_objects: container: testcont src: ~/Downloads/testcont/file2 method: put meta: testkey: testdata who_uploaded_this: someuser@example.com - name: "Upload one file to test container with TTL of 60 seconds" community.general.rax_files_objects: container: testcont method: put src: ~/Downloads/testcont/file3 expires: 60 - name: "Attempt to get remote object that does not exist" community.general.rax_files_objects: container: testcont method: get src: FileThatDoesNotExist.jpg dest: ~/Downloads/testcont ignore_errors: true - name: "Attempt to delete remote object that does not exist" community.general.rax_files_objects: container: testcont method: delete dest: FileThatDoesNotExist.jpg ignore_errors: true
- name: "Test Cloud Files Objects Metadata" hosts: local gather_facts: false tasks: - name: "Get metadata on one object" community.general.rax_files_objects: container: testcont type: meta dest: file2 - name: "Get metadata on several objects" community.general.rax_files_objects: container: testcont type: meta src: file2,file1 - name: "Set metadata on an object" community.general.rax_files_objects: container: testcont type: meta dest: file17 method: put meta: key1: value1 key2: value2 clear_meta: true - name: "Verify metadata is set" community.general.rax_files_objects: container: testcont type: meta src: file17 - name: "Delete metadata" community.general.rax_files_objects: container: testcont type: meta dest: file17 method: delete meta: key1: '' key2: '' - name: "Get metadata on all objects" community.general.rax_files_objects: container: testcont type: meta
env: description: - Environment as configured in I(~/.pyrax.cfg), see U(https://github.com/rackspace/pyrax/blob/master/docs/getting_started.md#pyrax-configuration). type: str src: description: - Source from which to upload files. Used to specify a remote object as a source for an operation, i.e. a file name, C(file1), or a comma-separated list of remote objects, C(file1,file2,file17). Parameters I(src) and I(dest) are mutually exclusive on remote-only object operations type: str dest: description: - The destination of a C(get) operation; i.e. a local directory, C(/home/user/myfolder). Used to specify the destination of an operation on a remote object; i.e. a file name, C(file1), or a comma-separated list of remote objects, C(file1,file2,file17). type: str meta: default: {} description: - Items to set as metadata values on an uploaded file or folder. type: dict type: choices: - file - meta default: file description: - Type of object to do work on - Metadata object or a file object type: str method: choices: - get - put - delete default: get description: - 'The method of operation to be performed: C(put) to upload files, C(get) to download files or C(delete) to remove remote objects in Cloud Files. ' type: str region: description: - Region to create an instance in. type: str api_key: aliases: - password description: - Rackspace API key, overrides I(credentials). type: str expires: description: - Used to set an expiration in seconds on an uploaded file or folder. type: int username: description: - Rackspace username, overrides I(credentials). type: str container: description: - The container to use for file object operations. required: true type: str structure: default: true description: - Used to specify whether to maintain nested directory structure when downloading objects from Cloud Files. Setting to false downloads the contents of a container to a single, flat directory type: bool tenant_id: description: - The tenant ID used for authentication. type: str clear_meta: default: false description: - Optionally clear existing metadata when applying metadata to existing objects. Selecting this option is only appropriate when setting I(type=meta). type: bool credentials: aliases: - creds_file description: - File to find the Rackspace credentials in. Ignored if I(api_key) and I(username) are provided. type: path tenant_name: description: - The tenant name used for authentication. type: str auth_endpoint: description: - The URI of the authentication service. - If not specified will be set to U(https://identity.api.rackspacecloud.com/v2.0/) type: str identity_type: default: rackspace description: - Authentication mechanism to use, such as rackspace or keystone. type: str validate_certs: aliases: - verify_ssl description: - Whether or not to require SSL validation of API endpoints. type: bool