Unverified Commit be05234a authored by Keshav Prasad's avatar Keshav Prasad
Browse files

feat: upload plugins using existing roles


Signed-off-by: default avatarKeshav Prasad <keshavprasadms@gmail.com>
Showing with 19 additions and 11 deletions
+19 -11
......@@ -30,6 +30,7 @@
storage_account_sas_token: "{{ azure_public_storage_account_sas }}"
tags:
- always
no_log: True
- block:
- name: delete files and folders from azure storage using azcopy
......@@ -77,17 +78,18 @@
name: azure-cloud-storage
tasks_from: blob-delete-batch.yml
vars:
blob_delete_pattern: "content-plugins/{{ item }}"
with_lines: "cat {{ plugin_list_to_delete_and_upload }}"
blob_delete_pattern: "content-plugins/{{ item }}/*"
with_lines: cat {{ plugin_list_to_delete_and_upload }}
- name: upload batch of files to azure storage
include_role:
name: azure-cloud-storage
tasks_from: blob-upload-batch.yml
vars:
blob_container_folder_path: "/content-plugins"
local_file_or_folder_path: "{{ source_file }}/{{ item }}"
with_lines: "cat {{ plugin_list_to_delete_and_upload }}"
blob_container_folder_path: "/content-plugins/{{ item }}"
local_file_or_folder_path: "{{ source_folder }}/{{ item }}"
create_container: false
with_lines: cat {{ plugin_list_to_delete_and_upload }}
tags:
- plugins
when: cloud_service_provider == "azure"
......
......@@ -64,4 +64,9 @@ blob_container_folder_path: ""
# This variable affects only new containers and has no affect on a container if it already exists
# If the container already exists, the access level will not be changed
# You will need to change the access level from Azure portal or using az storage container set-permission command
container_public_access: ""
\ No newline at end of file
container_public_access: ""
# Create the container by default before running the specific azure tasks
# If we would like to skip container creation (in case of a looped execution), you can set this value to false
# in order to skip the task for every iteration
create_container: true
\ No newline at end of file
---
- name: delete files and folders from a blob container recursively
- name: delete files and folders - deleting {{ blob_container_name }}/{{ blob_delete_pattern }}
shell: "az storage blob delete-batch --source {{ blob_container_name }} --pattern '{{ blob_delete_pattern }}' --account-name {{ storage_account_name }} --account-key {{ storage_account_key }}"
async: 3600
poll: 10
\ No newline at end of file
......@@ -3,8 +3,9 @@
include_role:
name: azure-cloud-storage
tasks_from: container-create.yml
when: create_container is true
- name: upload files and folders from a local directory to azure storage container
- name: upload files and folders - uploading {{ blob_container_name }}{{ blob_container_folder_path }}
shell: "az storage blob upload-batch --destination {{ blob_container_name }}{{ blob_container_folder_path }} --source {{ local_file_or_folder_path }} --account-name {{ storage_account_name }} --account-key {{ storage_account_key }}"
async: 3600
poll: 10
\ No newline at end of file
---
- name: create container in azure storage if it doesn't exist
- name: create container if it doesn't exist
shell: "az storage container create --name {{ blob_container_name }} --public-access {{ container_public_access }} --account-name {{ storage_account_name }} --account-key {{ storage_account_key }}"
when: storage_account_key | length > 0
- name: create container in azure storage if it doesn't exist
- name: create container if it doesn't exist
shell: "az storage container create --name {{ blob_container_name }} --public-access {{ container_public_access }} --account-name {{ storage_account_name }} --sas-token '{{ storage_account_sas_token }}'"
when: storage_account_sas_token | length > 0
\ No newline at end of file
......@@ -34,7 +34,7 @@ node() {
mv content-plugins ansible
"""
ansiblePlaybook = "${currentWs}/ansible/deploy-plugins.yml"
ansibleExtraArgs = "--tags plugins --extra-vars \" source_file=${currentWs}/ansible/content-plugins plugin_list_to_delete_and_upload=${currentWs}/ansible/content-plugins/plugin_list_to_delete_and_upload.txt\" --vault-password-file /var/lib/jenkins/secrets/vault-pass"
ansibleExtraArgs = "--tags plugins --extra-vars \" source_folder=${currentWs}/ansible/content-plugins plugin_list_to_delete_and_upload=${currentWs}/ansible/content-plugins/plugins_to_delete_and_upload.txt\" --vault-password-file /var/lib/jenkins/secrets/vault-pass"
values.put('ansiblePlaybook', ansiblePlaybook)
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment