Ansible With Wasabi

Prev Next

Ansible is a development tool that can be used with Wasabi by following the instructions below.

Requirements

  • Ansible 2.7

  • Additional packages are required – boto, boto3, botocore & python >= 2.6

If package installations are failing to complete, you may need to use the following option to ignore existing instances: sudo pip install --ignore-installed.

Wasabi’s cloud storage functions and operates very similarly to Amazon S3—hence, the user benefits from leveraging all the tools made available for Amazon S3.

With Ansible, the following Wasabi operations can be performed:

  • List (List all objects inside a bucket)

  • Get (download)

  • Put (upload)

  • Delete (delete a bucket or buckets and all its objects)

  • Create (create a new bucket)

  • Delobj (delete object inside a bucket)

  • Create a bucket in a different region

Review the information below for each mode, with sample expected results.

Listing All Objects in a Bucket

Query

MAC$ ansible -i inv_local localhost -m aws_s3 -a "bucket=ansiblebucket s3_url=https://s3.wasabisys.com mode=list region=us-east-1 aws_access_key= aws_secret_key="

Result

localhost | SUCCESS => {
    "changed": false,
    "msg": "LIST operation complete",
    "s3_keys": [
        "WasabiRocks.yml"
    ]
}

Downloading Files From the Bucket

Query

MAC$ ansible -i inv_local localhost -m aws_s3 -a "bucket=ansiblebucket s3_url=https://s3.wasabisys.com mode=get region=us-east-1 aws_access_key= aws_secret_key= object=ansiblebucket/WasabiRocks.yml dest=/Users/MAC/yamlscripts/WasabiRocks.yml"

Result

localhost | CHANGED => {
    "changed": true,
    "msg": "GET operation complete"
}

Uploading Files to a Bucket

Query

MAC$ ansible -i inv_local localhost -m aws_s3 -a "bucket=ansiblebucket s3_url=https://s3.wasabisys.com mode=put region=us-east-1 aws_access_key= aws_secret_key= object=WasabiRocks.yml src=/Users/MAC/yamlScripts/WasabiRocks.yml"

Result

localhost | CHANGED => {
 "changed": true,
 "msg": "PUT operation complete",
 "url": "https://s3.wasabisys.com/ansiblebucket/WasabiRocks.yml?AWSAccessKeyId=&Expires=1542120731&Signature="
}

Deleting Files From a Bucket

Query

MAC$ ansible -i inv_local localhost -m aws_s3 -a "bucket=ansiblebucket s3_url=https://s3.wasabisys.com mode=delete region=us-east-1 aws_access_key= aws_secret_key= "

Result

localhost | CHANGED => {
 "changed": true,
 "msg": "Object deleted from bucket ansiblebucket."
}

Creating a New Bucket

Query

MAC$ ansible -i inv_local localhost -m aws_s3 -a "bucket=bucket-for-ansible s3_url=https://s3.wasabisys.com mode=create region=us-east-1 aws_access_key= aws_secret_key="

Result

localhost | CHANGED => {
 "changed": true,
 "msg": "Bucket bucket-for-ansible and all keys have been deleted."
}

Deleting Specific Objects in a Bucket

Query

MAC$ ansible -i inv_local localhost -m aws_s3 -a "bucket=ansiblebucket s3_url=https://s3.wasabisys.com mode=delete region=us-east-1 aws_access_key= aws_secret_key= object=WasabiRocks.yml"

Result

localhost | CHANGED => {“changed": true, "msg": "Object deleted from bucket ansiblebucket."}

Creating a Bucket in a Different Region (for example, us-west-1)

Query

MAC$ ansible -i inv_local localhost -m aws_s3 -a "bucket=bucket-for-ansible-west s3_url=https://s3.us-west-1.wasabisys.com mode=create region=us-west-1 aws_access_key= aws_secret_key= "

Result

localhost | CHANGED => { "changed": true, "msg": "Bucket created successfully"}

This example discusses using Wasabi’s us-west-1 storage region. To use other Wasabi storage regions, use an appropriate Wasabi service URL.