win_ansible_role_sshd/tasks/powershell.yml

23 lines
932 B
YAML
Raw Permalink Normal View History

2022-12-29 04:16:38 +01:00
---
# See https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse?tabs=powershell
2022-12-31 15:50:42 +01:00
- name: Set Powershell Execution to Remote Signed
ansible.windows.win_powershell:
script: "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine"
changed_when: _fw.changed
2022-12-29 04:16:38 +01:00
- name: Install the OpenSSH Server
ansible.windows.win_powershell:
script: "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0"
2022-12-29 04:20:28 +01:00
changed_when: _fw.changed
2022-12-29 04:16:38 +01:00
- name: Set service startup mode to auto and ensure sshd is started
ansible.windows.win_service:
name: sshd
start_mode: auto
state: started
2022-12-29 16:40:39 +01:00
- name: Configure Powershell as default
ansible.windows.win_powershell:
script: 'New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "$Env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force'
changed_when: _fw.changed