diff --git a/ansible/roles/win_chocolatey/vars/main.yml b/ansible/roles/win_chocolatey/vars/main.yml index 79fe04c..3e04acf 100644 --- a/ansible/roles/win_chocolatey/vars/main.yml +++ b/ansible/roles/win_chocolatey/vars/main.yml @@ -44,4 +44,6 @@ community_packages: - visualstudio2019professional - sql-server-2017 - sql-server-management-studio - - netfx-4.7.2 \ No newline at end of file + - netfx-4.7.2 + - rtools + \ No newline at end of file diff --git a/ansible/roles/win_client/tasks/main.yml b/ansible/roles/win_client/tasks/main.yml index 2ba3891..6d8ad42 100644 --- a/ansible/roles/win_client/tasks/main.yml +++ b/ansible/roles/win_client/tasks/main.yml @@ -3,3 +3,4 @@ - import_tasks: chocolatey.yml - import_tasks: rdgw.yml - import_tasks: start_menu.yml +- import_tasks: runonce.yml diff --git a/ansible/roles/win_client/tasks/runonce.yml b/ansible/roles/win_client/tasks/runonce.yml new file mode 100644 index 0000000..77a3769 --- /dev/null +++ b/ansible/roles/win_client/tasks/runonce.yml @@ -0,0 +1,9 @@ +--- +- name: Copy logon script to VMs + tags: runonce + win_template: + src: "logon.ps1.j2" + dest: "C:\\eidf\\logon.ps1" + force: true + when: project_zone == 'protected' + \ No newline at end of file diff --git a/ansible/roles/win_client/templates/logon.ps1.j2 b/ansible/roles/win_client/templates/logon.ps1.j2 new file mode 100644 index 0000000..467476d --- /dev/null +++ b/ansible/roles/win_client/templates/logon.ps1.j2 @@ -0,0 +1,20 @@ +$bashProfilePath = Join-Path $HOME ".bash_profile" + +if ( -not ( Test-Path -Path $bashProfilePath ) ) { + $requiredLine = 'eval "$(''/C/tools/miniforge3/Scripts/conda.exe'' ''shell.bash'' ''hook'')"' + + Add-Content -Path $bashProfilePath -Value $requiredLine + Set-ItemProperty -Path $bashProfilePath -Name Attributes -Value ([System.IO.FileAttributes]::Hidden) +} + + +$Renviron_path = Join-Path $HOME "Documents\.Renviron" + +if ( -not ( Test-Path -Path $Renviron_path ) ) { + $Renviron_contents = @" +http_proxy=http://{{ proxy_address }} +https_proxy=http://{{ proxy_address }} +"@ + + Add-Content $Renviron_path $Renviron_contents +} \ No newline at end of file diff --git a/ansible/roles/win_client/vars/main.yml b/ansible/roles/win_client/vars/main.yml index b0b83ac..d770c16 100644 --- a/ansible/roles/win_client/vars/main.yml +++ b/ansible/roles/win_client/vars/main.yml @@ -3,3 +3,5 @@ start_menu_xml: "C:\\eidf\\{{ win_project }}.xml" backup_xml: "C:\\eidf\\{{ win_project }}-old.xml" script_name: newXML.py script_path: "C:\\eidf\\{{ script_name }}" +proxy_vm: "{{ os_project }}-{{ win_project }}-proxy" +proxy_address: "{{ hostvars[proxy_vm].ansible_host }}:3128" diff --git a/ansible/roles/win_domain_controller/files/logon.ps1 b/ansible/roles/win_domain_controller/files/logon.ps1 deleted file mode 100644 index fadf979..0000000 --- a/ansible/roles/win_domain_controller/files/logon.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -$bashProfilePath = Join-Path $HOME ".bash_profile" -$requiredLine = 'eval "$(''/C/tools/miniforge3/Scripts/conda.exe'' ''shell.bash'' ''hook'')"' - -Add-Content -Path $bashProfilePath -Value $requiredLine -Set-ItemProperty -Path $bashProfilePath -Name Attributes -Value ([System.IO.FileAttributes]::Hidden) diff --git a/ansible/roles/win_domain_controller/tasks/logon.yml b/ansible/roles/win_domain_controller/tasks/logon.yml deleted file mode 100644 index 83e63cd..0000000 --- a/ansible/roles/win_domain_controller/tasks/logon.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Copy logon script to VMs - tags: - - logon - block: - - name: Copy logon script to VMs - win_copy: - src: "logon.ps1" - dest: "C:\\eidf\\" - force: true diff --git a/ansible/roles/win_domain_controller/tasks/main.yml b/ansible/roles/win_domain_controller/tasks/main.yml index 3666add..a9f80eb 100644 --- a/ansible/roles/win_domain_controller/tasks/main.yml +++ b/ansible/roles/win_domain_controller/tasks/main.yml @@ -1,4 +1,3 @@ --- - import_tasks: features.yml -- import_tasks: setup.yml -- import_tasks: logon.yml +- import_tasks: setup.yml \ No newline at end of file diff --git a/ansible/roles/win_domain_controller/templates/proxy_gpo.ps1.j2 b/ansible/roles/win_domain_controller/templates/proxy_gpo.ps1.j2 index f745e35..7b7a1c3 100644 --- a/ansible/roles/win_domain_controller/templates/proxy_gpo.ps1.j2 +++ b/ansible/roles/win_domain_controller/templates/proxy_gpo.ps1.j2 @@ -1,7 +1,7 @@ New-GPO -Name "Squid Proxy" -comment "Configure Client VMs to use Squid HTTP proxy" Set-GPRegistryValue -Name "Squid Proxy" -ValueName "ProxyEnable" -key "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Value 1 -Type DWord Set-GPRegistryValue -Name "Squid Proxy" -ValueName "ProxyServer" -key "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Value "{{ proxy_address }}" -Type String -Set-GPRegistryValue -Name "Squid Proxy" -ValueName "ProxyOverride" -key "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Value ",{{ win_project }}-choc.{{ win_project }}.loc" -Type String +Set-GPRegistryValue -Name "Squid Proxy" -ValueName "ProxyOverride" -key "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Value ",{{ win_project }}-choc.{{ win_project }}.loc,{{ win_project }}-wsus.{{ win_project }}.loc" -Type String Set-GPRegistryValue -Name "Squid Proxy" -ValueName "Proxy" -key "HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel" -Value 1 -Type DWord $DomainInfo = Get-ADDomain diff --git a/ansible/roles/win_domain_controller/vars/main.yml b/ansible/roles/win_domain_controller/vars/main.yml index 9c68342..8516f58 100644 --- a/ansible/roles/win_domain_controller/vars/main.yml +++ b/ansible/roles/win_domain_controller/vars/main.yml @@ -13,6 +13,9 @@ study_data_dfs: \\{{ win_project }}\{{ share_name }} study_data_label: Study Data study_data_letter: S +proxy_vm: "{{ os_project }}-{{ win_project }}-proxy" +proxy_address: "{{ hostvars[proxy_vm].ansible_host }}:3128" + OUs: - Project Users - Project Groups