first commit

This commit is contained in:
root
2024-07-12 12:58:40 +02:00
commit 30fdad3be5
557 changed files with 11142 additions and 0 deletions

120
central_fs-sync-pon.yml Normal file
View File

@@ -0,0 +1,120 @@
---
- 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: get folder stats
ansible.windows.win_stat:
path: F:\Data\GUE
register: folderinfo1
- 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\PON\" "https://saapewormsprd2prd.blob.core.windows.net/coapewormsprd2prd-0/Data/PON/{{ansible_date_time.year + ansible_date_time.month + ansible_date_time.day}}/?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"
when: ponfolder != 0
- 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/PON$
path: /mnt/smbshare
fstype: cifs
opts: "username=sys-cfscopier4pon,password={{ passpon }}"
state: mounted
boot: no
become_method: sudo
become: true
- name: check if folder exists
ansible.builtin.stat:
path: /mnt/smbshare
register: state
- name:
debug:
var: ponfolder
- name: check folder content
ansible.builtin.find:
paths: /mnt/smbshare
file_type: any
recurse: yes
register: 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'