Documentation

gc_storage - This module manages objects/buckets in Google Cloud Storage.

New in version 1.4.

Synopsis

  • This module allows users to manage their objects/buckets in Google Cloud Storage. It allows upload and download operations and can set some canned permissions. It also allows retrieval of URLs for objects for use in playbooks, and retrieval of string contents of objects. This module requires setting the default project in GCS prior to playbook usage. See https://developers.google.com/storage/docs/reference/v1/apiversion1 for information about setting the default project.

Options

parameter required default choices comments
bucket
yes
Bucket name.
dest
no
The destination file path when downloading an object/key with a GET operation.
expiration
no
Time limit (in seconds) for the URL generated and returned by GCA when performing a mode=put or mode=get_url operation. This url is only available when public-read is the acl for the object.
force
no True
Forces an overwrite either locally on the filesystem or remotely with the object/key. Used with PUT and GET operations.

aliases: overwrite
gs_access_key
yes
GS access key. If not set then the value of the GS_ACCESS_KEY_ID environment variable is used.
gs_secret_key
yes
GS secret key. If not set then the value of the GS_SECRET_ACCESS_KEY environment variable is used.
headers
(added in 2.0)
no {}
Headers to attach to object.
mode
yes
  • get
  • put
  • get_url
  • get_str
  • delete
  • create
Switches the module behaviour between upload, download, get_url (return download url) , get_str (download object as string), create (bucket) and delete (bucket).
object
no
Keyname of the object inside the bucket. Can be also be used to create "virtual directories" (see examples).
permission
no private
This option let's the user set the canned permissions on the object/bucket that are created. The permissions that can be set are 'private', 'public-read', 'authenticated-read'.
src
no
The source file path when performing a PUT operation.

Examples

- name: Upload some content
  gc_storage:
    bucket: mybucket
    object: key.txt
    src: /usr/local/myfile.txt
    mode: put
    permission: public-read

- name: Upload some headers
  gc_storage:
    bucket: mybucket
    object: key.txt
    src: /usr/local/myfile.txt
    headers: '{"Content-Encoding": "gzip"}'

- name: Download some content
  gc_storage:
    bucket: mybucket
    object: key.txt
    dest: /usr/local/myfile.txt
    mode: get

- name: Download an object as a string to use else where in your playbook
  gc_storage:
    bucket: mybucket
    object: key.txt
    mode: get_str

- name: Create an empty bucket
  gc_storage:
    bucket: mybucket
    mode: create

- name: Create a bucket with key as directory
  gc_storage:
    bucket: mybucket
    object: /my/directory/path
    mode: create

- name: Delete a bucket and all contents
  gc_storage:
    bucket: mybucket
    mode: delete

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Support

This module is community maintained without core committer oversight.

For more information on what this means please read Module Support

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Helping Testing PRs and Developing Modules.