From 6f49293b79cd1ae1218b869734323697fcd11bb7 Mon Sep 17 00:00:00 2001 From: abrown38 Date: Mon, 15 Apr 2024 14:29:41 +0000 Subject: [PATCH] win_dfs role --- ansible/playbooks/win_dfs.yml | 9 ++++ ansible/roles/win_dfs/tasks/configure.yml | 62 +++++++++++++++++++++++ ansible/roles/win_dfs/tasks/features.yml | 32 ++++++++++++ ansible/roles/win_dfs/tasks/main.yml | 3 ++ 4 files changed, 106 insertions(+) create mode 100644 ansible/playbooks/win_dfs.yml create mode 100644 ansible/roles/win_dfs/tasks/configure.yml create mode 100644 ansible/roles/win_dfs/tasks/features.yml create mode 100644 ansible/roles/win_dfs/tasks/main.yml diff --git a/ansible/playbooks/win_dfs.yml b/ansible/playbooks/win_dfs.yml new file mode 100644 index 0000000..f5f48a1 --- /dev/null +++ b/ansible/playbooks/win_dfs.yml @@ -0,0 +1,9 @@ +--- +- hosts: "meta-variant_file_server" + gather_facts: false + vars_files: + - ../vars/common.yml + - ../vars/connection.yml + roles: + - role: win_dfs + tags: win_dfs \ No newline at end of file diff --git a/ansible/roles/win_dfs/tasks/configure.yml b/ansible/roles/win_dfs/tasks/configure.yml new file mode 100644 index 0000000..eea843e --- /dev/null +++ b/ansible/roles/win_dfs/tasks/configure.yml @@ -0,0 +1,62 @@ +--- +- name: Configure dfs + tags: configure_dfs + block: + - name: Configure DFS namespace root + win_dsc: + resource_name: xDFSNamespaceRoot + Ensure: Present + Path: \\{{ win_project }}.loc\Study_Data + TargetPath: \\{{ win_project }}-fs01\Study_Data_DFS + Type: DomainV2 + PsDscRunAsCredential_username: Administrator + PsDscRunAsCredential_password: "{{ ansible_password }}" + + - name: Configure DFS replicated group + win_dsc: + resource_name: xDFSReplicationGroup + Ensure: Present + GroupName: "{{ win_project }}_Data" + DomainName: "{{ win_project }}.loc" + # Testing this: + Folders: "Study_Data_DFS" + PsDscRunAsCredential_username: Administrator + PsDscRunAsCredential_password: "{{ ansible_password }}" + Members: "{{ win_project }}-fs01, {{ win_project }}-fs02" + + - name: Configure DFS replication connections + win_dsc: + resource_name: xDFSReplicationGroupConnection + Ensure: Present + GroupName: "{{ win_project }}_Data" + SourceComputerName: "{{ win_project }}-fs01" + DestinationComputerName: "{{ win_project }}-fs02" + DomainName: "{{ win_project }}.loc" + PsDscRunAsCredential_username: Administrator + PsDscRunAsCredential_password: "{{ ansible_password }}" + + - name: Configure DFS replication primary member (FS01) and membership + win_dsc: + resource_name: xDFSReplicationGroupMembership + GroupName: "{{ win_project }}_Data" + FolderName: "Study_Data_DFS" + ContentPath: S:\ + ComputerName: "{{ win_project }}-fs01" + PrimaryMember: true + #StagingPathQuotaInMB: 16384 + DomainName: "{{ win_project }}.loc" + PsDscRunAsCredential_username: Administrator + PsDscRunAsCredential_password: "{{ ansible_password }}" + + - name: Configure DFS replication secondary member (FS02) and membership + win_dsc: + resource_name: xDFSReplicationGroupMembership + GroupName: "{{ win_project }}_Data" + FolderName: "Study_Data_DFS" + ContentPath: S:\ + ComputerName: "{{ win_project }}-fs02" + #StagingPathQuotaInMB: 16384 + DomainName: "{{ win_project }}.loc" + PsDscRunAsCredential_username: Administrator + PsDscRunAsCredential_password: "{{ ansible_password }}" + when: inventory_hostname in groups['meta-name_fs01'] diff --git a/ansible/roles/win_dfs/tasks/features.yml b/ansible/roles/win_dfs/tasks/features.yml new file mode 100644 index 0000000..cb8d640 --- /dev/null +++ b/ansible/roles/win_dfs/tasks/features.yml @@ -0,0 +1,32 @@ +--- +- name: DFS Features + tags: dfs_features + block: + - name: Install DFS features + win_feature: + name: + - FS-DFS-Namespace + - FS-DFS-Replication + - RSAT-DFS-Mgmt-con + state: present + inlcude_management_tools: True + register: feature_status + + - name: Rebooting Servers post feature installation + win_reboot: + reboot_timeout_sec: 1200 + when: feature_status.reboot_required == true + +- name: DFS Features + tags: dfs_powershell + block: + - name: Install NuGet packageprovider (requirement for xDFS DSC module installation) + ansible.windows.win_powershell: + script: | + Find-PackageProvider -Name Nuget -ForceBootstrap -IncludeDependencies -Force + + - name: Install xDFS DSC module + win_psmodule: + name: xDFS + state: Present + accept_license: true \ No newline at end of file diff --git a/ansible/roles/win_dfs/tasks/main.yml b/ansible/roles/win_dfs/tasks/main.yml new file mode 100644 index 0000000..791a67f --- /dev/null +++ b/ansible/roles/win_dfs/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- import_tasks: features.yml +- import_tasks: configure.yml