wintus / ansible-wsl Goto Github PK
View Code? Open in Web Editor NEWProvisioning your Windows from inside of WSL by Ansible
License: MIT License
Provisioning your Windows from inside of WSL by Ansible
License: MIT License
Because it's simply impossible:
No, Ansible can only manage Windows hosts. Ansible cannot run on a Windows host natively, though it can run under the Windows Subsystem for Linux (WSL).
Setup step
https://docs.ansible.com/ansible/latest/user_guide/windows_setup.html#setup-winrm-listener
Error
PS C:\WINDOWS\system32> winrm quickconfig -transport:https
WinRM サービスは、既にこのコンピューターで実行されています。
WSManFault
Message
ProviderFault
WSManFault
Message = このコンピューターには適切な証明書がないため、HTTPS 上に WinRM リスナーを作成できません。SSL に使用するには、ホスト名に一致する CN を持ち、サーバー認証に適しており、有効期限内であり、失効しておらず、自己署名されたものでない証明書が必要です。
エラー番号: -2144108267 0x80338115
このコンピューターには適切な証明書がないため、HTTPS 上に WinRM リスナーを作成できません。SSL に使用するには、ホスト名に 一致する CN を持ち、サーバー認証に適しており、有効期限内であり、失効しておらず、自己署名されたものでない証明書が必要です。
https://support.microsoft.com/ja-jp/help/2019527/how-to-configure-winrm-for-https
or HTTP
still error
https://docs.ansible.com/ansible/latest/user_guide/windows_setup.html#common-winrm-issues
Winrs error:宛先のコンピューター (localhost:5986) のサーバー証明書に次のエラーがあります:
SSL 証明書が不明の証明機関によって署名されています。
SSL 証明書にホスト名と一致しない共通名 (CN) が含まれています。
This is intended.
The final command succeeded.
i.e. skip it
Add files under host_vars/
for connection setting, etc. which is named like:
wsl.yml.example
win.yml.example
As configured in:
Lines 1 to 5 in 991c18c
This play is removable:
Lines 2 to 5 in 991c18c
Ansible-WSL/roles/ubuntu/tasks/main.yml
Line 18 in 991c18c
https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html#synopsis
If Chocolatey is missing from the system, the module will install it.
Lines 4 to 5 in 991c18c
This connection should be WinRM:
https://docs.ansible.com/ansible/latest/user_guide/windows_winrm.html#inventory-options
extract to chocolaty.yml
Ansible-WSL/roles/chocolatey/tasks/main.yml
Lines 10 to 13 in 991c18c
Ansible-WSL/roles/chocolatey/tasks/main.yml
Lines 2 to 5 in 991c18c
and use as
- name: self hosting chocolaty
import_tasks: chocolaty.yml
var:
packages:
- name: chocolatey
- name: chocolateygui
- name: install softwares in the package list.
import_tasks: chocolaty.yml
var:
packages: "{{ chocolaty_packages }}"
causing error of WinRM WSMan setting
https://docs.ansible.com/ansible/latest/user_guide/windows_setup.html#winrm-service-options
PS C:\WINDOWS\system32> Set-Item -Path WSMan:\localhost\Service\AllowUnencrypted -Value false
Set-Item : このコンピューターのネットワーク接続の種類の 1 つが Public に設定されているため、WinRM ファイアウォール例外
は機能しません。 ネットワーク接続の種類を Domain または Private に変更して、やり直してください。
発生場所 行:1 文字:1
+ Set-Item -Path WSMan:\localhost\Service\AllowUnencrypted -Value false
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-Item], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.SetItemCommand
also error:
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
solutions
related #13
other than Ubuntu
Since every connections of provisioning is limited within a single host, no need to expose WinRM to LAN/WAN.
options:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.