community.general.rax_files_objects module – Upload, download, and delete objects in Rackspace Cloud Files
Note
This module is part of the community.general collection (version 8.6.8).
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 community.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.rax_files_objects
.
DEPRECATED
- Removed in:
version 9.0.0
- Why:
This module relies on the deprecated package pyrax.
- Alternative:
Use the Openstack modules instead.
Synopsis
Upload, download, and delete objects in Rackspace Cloud Files.
Aliases: cloud.rackspace.rax_files_objects
Requirements
The below requirements are needed on the host that executes this module.
pyrax
Parameters
Parameter |
Comments |
---|---|
Rackspace API key, overrides |
|
The URI of the authentication service. If not specified will be set to https://identity.api.rackspacecloud.com/v2.0/. |
|
Optionally clear existing metadata when applying metadata to existing objects. Selecting this option is only appropriate when setting Choices:
|
|
The container to use for file object operations. |
|
The destination of a |
|
Environment as configured in |
|
Used to set an expiration in seconds on an uploaded file or folder. |
|
Authentication mechanism to use, such as rackspace or keystone. Default: |
|
Items to set as metadata values on an uploaded file or folder. Default: |
|
The method of operation to be performed: Choices:
|
|
Region to create an instance in. |
|
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 Choices:
|
|
The tenant ID used for authentication. |
|
The tenant name used for authentication. |
|
Type of object to do work on Metadata object or a file object Choices:
|
|
Rackspace username, overrides |
|
Whether or not to require SSL validation of API endpoints. Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: none |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Notes
Note
The following environment variables can be used,
RAX_USERNAME
,RAX_API_KEY
,RAX_CREDS_FILE
,RAX_CREDENTIALS
,RAX_REGION
.RAX_CREDENTIALS
andRAX_CREDS_FILE
point to a credentials file appropriate for pyrax. See https://github.com/rackspace/pyrax/blob/master/docs/getting_started.md#authenticating.RAX_USERNAME
andRAX_API_KEY
obviate the use of a credentials file.RAX_REGION
defines a Rackspace Public Cloud region (DFW, ORD, LON, …).The following environment variables can be used,
RAX_USERNAME
,RAX_API_KEY
,RAX_CREDS_FILE
,RAX_CREDENTIALS
,RAX_REGION
.RAX_CREDENTIALS
andRAX_CREDS_FILE
points to a credentials file appropriate for pyrax. See https://github.com/rackspace/pyrax/blob/master/docs/getting_started.md#authenticating.RAX_USERNAME
andRAX_API_KEY
obviate the use of a credentials file.RAX_REGION
defines a Rackspace Public Cloud region (DFW, ORD, LON, …).
Examples
- 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: [email protected]
- 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
Status
This module will be removed in version 9.0.0. [deprecated]
For more information see DEPRECATED.