121 lines
4.1 KiB
YAML
121 lines
4.1 KiB
YAML
---
|
|
- name: push data to WORM
|
|
hosts: all
|
|
tasks:
|
|
# - name: check if folder isn't empty
|
|
# ansible.windows.win_stat:
|
|
# path: F:\Data\PON
|
|
# register: folderinfo
|
|
# environment:
|
|
# ponfolder: folderinfo.stat.size
|
|
|
|
# - name: set fact
|
|
# set_fact: ponfolder="{{folderinfo.stat.size}}"
|
|
|
|
- name: make host group from survey hosts list
|
|
add_host:
|
|
hostname: "awe-mgt-050.adagility.net"
|
|
groups: new_group
|
|
ansible_connection: ssh
|
|
ansible_port: 22
|
|
ansible_user: sys-awx-srvautomate@ADAGILITY.NET
|
|
become_user: root
|
|
become: yes
|
|
ansible_ssh_pass: "{{pass}}"
|
|
ansible_sudo_pass: "{{pass}}"
|
|
# ponfolder: "{{folderinfo.stat.size}}"
|
|
delegate_to: localhost
|
|
|
|
- name: mount
|
|
hosts: new_group
|
|
tasks:
|
|
- name: mount central file server
|
|
ansible.posix.mount:
|
|
src: //awe-mps-006.adagility.net/COR$
|
|
path: /mnt/smbshare
|
|
fstype: cifs
|
|
opts: "username=adm-bvandendaele,password={{ passcor }}"
|
|
state: mounted
|
|
boot: no
|
|
become_method: sudo
|
|
become: true
|
|
- name: check if folder exists
|
|
ansible.builtin.stat:
|
|
path: /mnt/smbshare
|
|
register: state
|
|
|
|
|
|
# - name: check folder content
|
|
# ansible.builtin.find:
|
|
# paths: "/mnt/smbshare/{{'%Y%m%d' | strftime((ansible_date_time['epoch']|int)-(86400*(item | int))) }}"
|
|
# file_type: any
|
|
# recurse: no
|
|
# with_sequence: start=60 end=30 stride=-1
|
|
# register: output
|
|
|
|
- name: Delete content & directory
|
|
ansible.builtin.file:
|
|
state: absent
|
|
path: "/mnt/smbshare/{{'%Y%m%d' | strftime((ansible_date_time['epoch']|int)-(86400*(item | int))) }}"
|
|
with_sequence: start=20 end=3 stride=-1
|
|
become: true
|
|
|
|
|
|
# - name: get folder
|
|
# ansible.builtin.debug:
|
|
# var: output
|
|
# - name: create list
|
|
# set_fact:
|
|
# paths: []
|
|
|
|
# - name: append paths to list
|
|
# set_fact:
|
|
# paths: "{{paths + [item.path]}}"
|
|
# with_items: "{{output.files}}"
|
|
# - name: get items
|
|
# debug:
|
|
# var: paths
|
|
|
|
|
|
# - name: upload files to blob
|
|
# azure.azcollection.azure_rm_storageblob:
|
|
# resource_group: rg-project-wormbackup-prd
|
|
# storage_account_name: saapewormsprd2prd
|
|
# container: coapewormsprd2prd-0
|
|
# batch_upload_dst: Data/PON/{{ansible_date_time.year + ansible_date_time.month + ansible_date_time.day}}/test/
|
|
# batch_upload_src: /mnt/smbshare/{{ item }}
|
|
# auth_source: env
|
|
# force: false
|
|
# with_items: paths
|
|
# when: ponfolder != 0
|
|
|
|
# - name: clean local folder
|
|
# ansible.builtin.file:
|
|
# path: "{{item}}"
|
|
# state: absent
|
|
# with_items: "{{paths}}"
|
|
# when: ponfolder != 0
|
|
# become: true
|
|
|
|
|
|
|
|
environment:
|
|
- AZURE_CLIENT_ID: "{{AZURE_CLIENT_ID}}"
|
|
- AZURE_SECRET: "{{AZURE_SECRET}}"
|
|
- AZURE_SUBSCRIPTION_ID: "{{AZURE_SUBSCRIPTION_ID}}"
|
|
- AZURE_TENANT: "{{AZURE_TENANT}}"
|
|
|
|
|
|
|
|
# - name: Copy local folder to WORM
|
|
# ansible.windows.win_powershell:
|
|
# script: |
|
|
# C:\Windows\System32\azcopy_windows_amd64_10.16.2\azcopy.exe copy --recursive "F:\Data\COR\$((get-date).AddDays(-1).ToString("yyyyMMdd"))" "https://saapewormsprd2prd.blob.core.windows.net/coapewormsprd2prd-0/Data/COR/?sv=2021-06-08&ss=bfqt&srt=co&sp=rwdlacupiytfx&se=2024-03-03T15:34:11Z&st=2023-03-03T07:34:11Z&spr=https&sig=X4o7LwIgrctnl5M9C%2B4VrI%2FwFp3Ahk049YVN0fgAauU%3D"
|
|
|
|
# - name: Copy local google drive folder to WORM
|
|
# ansible.windows.win_powershell:
|
|
# script: |
|
|
# C:\Windows\System32\azcopy_windows_amd64_10.16.2\azcopy.exe copy --recursive "E:\Shared drives\Global IT Infrastructure Library\Design Documentation\Network" "https://saapewormsprd2prd.blob.core.windows.net/coapewormsprd2prd-0/Data/COR/$((get-date).AddDays(-1).ToString("yyyyMMdd"))/GDrive/?sv=2021-06-08&ss=bfqt&srt=co&sp=rwdlacupiytfx&se=2024-03-03T15:34:11Z&st=2023-03-03T07:34:11Z&spr=https&sig=X4o7LwIgrctnl5M9C%2B4VrI%2FwFp3Ahk049YVN0fgAauU%3D" --include-pattern '*.vsd;*.vsdx;*.pdf;*.png;*.jpg'
|
|
|
|
|