Ansible With Wasabi
    • 13 Jun 2024
    • 1 Minute to read
    • PDF

    Ansible With Wasabi

    • PDF

    Article summary

    How do I use Ansible with Wasabi?

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

    Pre-requisites:

    • Ansible 2.7

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

    If package installation are failing to complete– you may have to use the following option to ignore existing instances using command- sudo pip install --ignore-installed

    Wasabi’s cloud storage functions and operates very similar to Amazon S3 – hence the user gets the benefit of leveraging all the tools made available for Amazon S3.

    With Ansible, 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 different region

    Please review the information below for each of the modes with sample expected results

    To List all the Objects inside 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"

        ]

    }

    To Download 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"

    }

    Upload 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="

    }

    Delete 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."

    }

    Create 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."

    }

    Delete Specific objects inside 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."

    }

    Create bucket in different region (ex: 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"

    }

    Note that this example discusses the use of Wasabi’s us-west-1 storage region. To use other Wasabi storage regions, please use the appropriate Wasabi service URL as described in this article