-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from sitewards/ADHOC-add-azure-blob-support
Adhoc add azure blob support
- Loading branch information
Showing
7 changed files
with
94 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
- name: "Install the required python packages for AWS" | ||
pip: | ||
name: "{{ item }}" | ||
state: "latest" | ||
become: "True" | ||
become_user: "root" | ||
with_items: | ||
- "boto3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- name: "Install the required python packages for Azure" | ||
pip: | ||
name: "{{ item }}" | ||
state: "latest" | ||
become: "True" | ||
become_user: "root" | ||
with_items: | ||
- packaging | ||
- msrestazure | ||
- ansible[azure] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
# Note: The AWS keys are deliberately omitted for this task. They should be set in the session: | ||
# $ export AWS_ACCESS_KEY_ID="YOUR_ACCESS_KEY" | ||
# $ export AWS_SECRET_ACCESS_KEY="YOUR_SECRET_KEY" | ||
- name: "Download the copy of the DB from AWS S3" | ||
aws_s3: | ||
bucket: "{{ import_db_s3_bucket }}" | ||
object: "{{ import_db_s3_object_name }}" | ||
dest: "{{ import_db_tmp_path }}/db_dump.sql.gz" | ||
region: "{{ import_db_s3_region }}" | ||
aws_access_key: "{{ import_db_aws_access_key_id }}" | ||
aws_secret_key: "{{ import_db_aws_secret_access_key }}" | ||
mode: "get" | ||
register: "import_db_downloaded_archive" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
#- name: "Download the copy of the DB from Azure Storage" | ||
# azure_rm_storageblob: | ||
# resource_group: "{{ lookup('env','AZURE_PROD_RESOURCE_GROUP') }}" | ||
# storage_account_name: "{{ lookup('env','AZURE_STORAGE_ACCOUNT') }}" | ||
# container: "{{ import_db_azure_container_name }}" | ||
# blob: "{{ import_db_azure_object_name }}" | ||
# dest: "{{ import_db_tmp_path }}/db_dump.sql.gz" | ||
# environment: | ||
# AZURE_CLIENT_ID: "{{ lookup('env','AZURE_CLIENT_ID') }}" | ||
# AZURE_SECRET: "{{ lookup('env','AZURE_SECRET') }}" | ||
# AZURE_TENANT: "{{ lookup('env','AZURE_TENANT') }}" | ||
# AZURE_SUBSCRIPTION_ID: "{{ lookup('env','AZURE_SUBSCRIPTION_ID') }}" | ||
# AZURE_STORAGE_ACCOUNT: "{{ lookup('env','AZURE_STORAGE_ACCOUNT') }}" | ||
# AZURE_STORAGE_KEY: "{{ lookup('env','AZURE_STORAGE_KEY') }}" | ||
# register: "import_db_downloaded_archive" | ||
# | ||
# This expects to authenticate based on the invokers Azure credentials, supplied through environment variables | ||
- name: "Download the copy of the DB from Azure Storage" | ||
shell: | | ||
AZURE_CLIENT_ID="{{ lookup('env','AZURE_CLIENT_ID') }}" \ | ||
AZURE_SECRET="{{ lookup('env','AZURE_SECRET') }}" \ | ||
AZURE_TENANT="{{ lookup('env','AZURE_TENANT') }}" \ | ||
AZURE_SUBSCRIPTION_ID="{{ lookup('env','AZURE_SUBSCRIPTION_ID') }}" \ | ||
AZURE_STORAGE_ACCOUNT="{{ lookup('env','AZURE_STORAGE_ACCOUNT') }}" \ | ||
AZURE_STORAGE_KEY="{{ lookup('env','AZURE_STORAGE_KEY') }}" \ | ||
az storage blob download --container-name="{{ import_db_azure_container_name }}" --file={{ import_db_tmp_path }}/db_dump.sql.gz --name={{ import_db_azure_object_name }} | ||
register: "import_db_downloaded_archive" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters