首页 > 解决方案 > 使用 Ansible 配置 Ubuntu WSL 环境

问题描述

我可以通过在 Ubuntu WSL 中运行 Ansible 来使用 Ansible/Chocolatey 配置 Windows 10。我现在正在尝试使用同一个 Ansible 实例来配置 Ubuntu WSL 环境。它似乎正确地进行了身份验证,但是当我尝试从 Ubuntu WSL 本身配置 Ubuntu WSL 时出现以下权限错误:

fatal: [localhost-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 /tmp/.ansible-${USER}/tmp/ansible-tmp-1594006839.9280272-267367995921233 `\" && echo ansible-tmp-1594006839.9280272-267367995921233=\"` echo /tmp/.ansible-${USER}/tmp/ansible-tmp-1594006839.9280272-267367995921233 `\" ), exited with 
result 1, stdout output: ansible-tmp-1594006839.9280272-267367995921233=/tmp/.ansible-***/tmp/ansible-tmp-1594006839.9280272-267367995921233\n", "unreachable": true}
[WARNING]: Failure using method (v2_runner_on_unreachable) in callback plugin      
(<ansible.plugins.callback.mail.CallbackModule object at 0x7feccbade550>): [Errno  
111] Connection refused

这是我的inventory.yml:

all:  
  children:
    ubuntu-wsl:
      hosts:        
        localhost-wsl:
          ansible_port: 22
          ansible_host: localhost
          ansible_password: "{{ passwordd}}"
          ansible_user: "{{ usernamee}}"

这是我的 ansible.cfg:

[defaults]
inventory = inventory.ymlforks = 50
transport = ssh
gathering = smart
fact_caching = jsonfile
fact_caching_connection =  ~/.ansible/factcachingconnection
callback_whitelist = mailfact_caching_timeout = 60480000hash_behavior = merge
retry_files_enable = False
pipelining = True
host_key_checking = False
remote_tmp = /tmp/.ansible-${USER}/tmp

[winrm_connection]
server_cert_validation = ignore
transport = credssp,ssl

[ssh_connection]
transfer_method = piped

任何人都可以发现错误或提出可能的解决方案吗?我也无法使用本地类型连接使其工作(上面使用的是 SSH)。

谢谢

标签: ansible

解决方案


解决方案是将 Ubuntu WSL 环境升级到 WSL 2。请参阅https://docs.microsoft.com/en-us/windows/wsl/install-win10#update-to-wsl-2


推荐阅读