为 Windows 10 的 WSL(1 和 2)设置 Ansible 主机

4
我看到许多关于相反情况的信息(即如何使用WSL作为服务器来配置Windows,使用winrm),但我找不到任何有关在另一台机器上使用ansible配置WSL(1和2)的信息。
我的设置如下:
- 在Ubuntu Server 18.04中编排Ansible的服务器 - 在Windows 10上运行WSL 1和WST 2实例的主机
hosts.yml中使用以下内容:
all:
  children:
    desktops:
      hosts:
        wsl:
          ansible_host: 192.168.1.204
          ansible_user: my-windows-user

我得到了以下输出(至少可以理解那里有一台机器):
> ansible wsl -m ping                                                                                                                                                                     

wsl | UNREACHABLE! => {
    "changed": false,
    "msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo ~/.ansible/tmp/ansible-tmp-1574712678.8429368-151724391009763 `\" && echo ansible-tmp-1574712678.8429368-151724391009763=\"` echo ~/.ansible/tmp/ansible-tmp-1574712678.8429368-151724391009763 `\" ), exited with result 1",
    "unreachable": true
}

这种情况发生在WSL 1和WSL 2实例中。有什么想法吗?
附言:如果WSL实例的用户名/密码错误,则输出变为(因此在某些级别上存在一些正确的身份验证):
wsl | UNREACHABLE! => {                                                                                                                                                                           
    "changed": false,                                                                                                                                                                                        
    "msg": "Invalid/incorrect password: Permission denied, please try again.",                                                                                                                               
    "unreachable": true                                                                                                                                                                                      
}       
1个回答

0
默认情况下,WSL2不运行服务。要启用systemd,请在编辑/etc/wsl.conf后重新启动。
[boot]
systemd=true

然后继续在您选择的发行版中安装、启用并启动openssh-server软件包。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接