Ansible 无法创建目录/$HOME/.ansible/cp [英] Ansible cannot make dir /$HOME/.ansible/cp

查看:85
本文介绍了Ansible 无法创建目录/$HOME/.ansible/cp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行 ansible 时遇到一个非常奇怪的错误:

<前>收集事实 *******************************************************************致命:[i-0f55b6a4] => 无法创建目录/$HOME/.ansible/cp:[Errno 13] 权限被拒绝:'/$HOME'任务:[任务#1] ***************************************************************致命:没有主机匹配或所有主机都已经失败——正在中止播放回顾 ************************************************************************要重试,请使用:--limit @/home/ubuntu/install.retryi-0f55b6a4 : ok=0 已更改=0 无法访问=1 失败=0

通常,这个剧本运行没有问题,但我最近做了一些更改,以便从 start-stop-daemon 调用调用 ansible 的程序,以便我将作为服务运行.最终目标是拥有一个可以在它认为必要时自动运行剧本的服务.

剧本的开头是这样的:

---- 主机:w_vm:main须藤:真的任务:- 名称:任务#1...

sudo 设置为 True,所以我有点确定错误不在目标机器上.

生成的 ansible-playbook 调用如下所示:

ansible-playbook -i/tmp/ansible3397486563152037600.inventory \/home/ubuntu/playbooks/main_playbook.yml \-e @/home/ubuntu/extra_params.json

我不确定 Could not make dir/$HOME/.ansible/cp 错误是否发生在服务器或远程机器上,或者为什么 ansible 试图创建目录在 / 中命名为 $HOME.这仅在从 linux 服务调用调用 ansible 的程序时发生,而不是从命令行显式调用时发生.

<小时>

我在这里问了一个更具体的问题:https://unix.stackexchange.com/questions/220841/start-stop-daemon-services-environment-variables-and-ansible

解决方案

试试 sudo chown -R YOUR_USERNAME/home/YOUR_USERNAME/.ansible

I'm getting a very strange error when I run ansible:

GATHERING FACTS *************************************************************** 
fatal: [i-0f55b6a4] => Could not make dir /$HOME/.ansible/cp: [Errno 13] Permission denied: '/$HOME'

TASK: [Task #1] *************************************************************** 
FATAL: no hosts matched or all hosts have already failed -- aborting


PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/ubuntu/install.retry

i-0f55b6a4                 : ok=0    changed=0    unreachable=1    failed=0   

Normally, this playbook runs without problems, but I've recently made some changes so that the program that calls ansible is called from start-stop-daemon so that I will run as a service. The ultimate goal being to have a service that can run the playbook automatically, when it deems it necessary.

The beginning of the playbook looks like this:

---
- hosts: w_vm:main
  sudo: True
  tasks:
  - name: Task #1
    ...

sudo is set to True so I'm somewhat certain that the error is not on the target machine.

The generated invocation of ansible-playbook looks like this:

ansible-playbook -i /tmp/ansible3397486563152037600.inventory \
                    /home/ubuntu/playbooks/main_playbook.yml \
                    -e @/home/ubuntu/extra_params.json

I'm not sure if that Could not make dir /$HOME/.ansible/cp error is occurring on the server or on the remote machine, or why ansible is trying to make a directory named $HOME in /. This only happens when the program that calls ansible is called from the linux service, not when it's called explicitly from the command line.


I've asked a more specific question here: https://unix.stackexchange.com/questions/220841/start-stop-daemon-services-environment-variables-and-ansible

解决方案

Try sudo chown -R YOUR_USERNAME /home/YOUR_USERNAME/.ansible

这篇关于Ansible 无法创建目录/$HOME/.ansible/cp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆