How do I use Ansible with Wasabi?
Ansible is a development tool that can be used with Wasabi by following the instructions below.
Pre-requisites:
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 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"
}
This example discusses using 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.