Ansible 文本文件忙错误 [英] Ansible text file busy error

查看:27
本文介绍了Ansible 文本文件忙错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 主机上设置了 Vagrant/Ansible.Ansible 设置为在 Ubuntu 客户机上运行,​​因为 Vagrant up 执行一个 shell 脚本,该脚本将 provisioning yml 文件复制到客户机上,并在客户机上安装 Ansible.

I have a Vagrant / Ansible set up on my Windows host. Ansible is set up to run on the Ubuntu guest, as Vagrant up executes a shell script which copies the provisioning yml files onto the guest and installs Ansible also on the guest.

该脚本使用以下命令在来宾上运行 Ansible 设置:

The script runs the Ansible set up on the guest with the following command:

# Ansible installations
sudo apt-get install -y ansible

# Copy all Ansible scripts to the ubuntu guest
sudo cp -rf -v /vagrant/provisioning /home/vagrant/

# cp /vagrant/hosts /home/vagrant/
sudo chmod 666 /home/vagrant/provisioning/hosts

# Install roles
sudo ansible-playbook /home/vagrant/provisioning/local.yml -i /home/vagrant/provisioning/hosts --connection=local

Ansible 配置过程中的一个步骤是在 /var/www 目录中设置 Laravel 的新副本.拉入 Laravel 后,我的脚本然后复制并编辑文档根目录 (/var/www) 中的 .env 文件.

One of the steps in the Ansible configuration process is setting up a fresh copy of Laravel in the /var/www directory. After pulling in Laravel, my script then copies and then edits the .env file in document root (/var/www).

但这就是问题所在,它失败并显示 text file busy 消息.这是在来宾上作为源和目标发生的副本,所以我想与 VBox 无关.我觉得这与文件名如此不寻常有关,但我还没有找到答案.

But therein is the problem, it fails with text file busy message. This is a copy that is happening on the guest as source and destination, so I guess nothing to do with VBox. I have a feeling it has to do with the file name being so unusual, but I have not found an answer.

我的 Laravel task.yml 文件是:

My task.yml file for Laravel is:

---
- name: Clone git repository
  git: >
      dest=/var/www
      repo=https://github.com/laravel/laravel.git
      update=no
  sudo: yes
  sudo_user: www-data
  register: cloned

- name: copy .env file
  copy: src=env.j2 dest={{ conf_file }}

- name: set APP_DOMAIN={{ server_name }}
  lineinfile: dest=/var/www/.env regexp='^APP_DOMAIN=' line=APP_DOMAIN={{ server_name }}

我也尝试过使用模板方法,但出现同样的错误:

I have also tried using the template method with the same error:

- name: copy .env file
  template: src=env.j2 dest={{ conf_file }}

我的 conf 文件包含:

My conf file contains:

conf_file: /var/www/.env

它在复制步骤失败,如下所示:

It fails at the copy step as follows:

==> default: TASK: [laravel | copy .env file] **********************************************
==> default: failed: [10.0.1.10] => {"failed": true, "md5sum": "a380715fa81750708f7b9b6fea1a48fe"}
==> default: msg: Could not replace file: /root/.ansible/tmp/ansible-tmp-1441176559.19-197929606462535/source to /var/www/.env: [Errno 26] Text file busy
==> default:
==> default: FATAL: all hosts have already failed -- aborting
==> default:
==> default: PLAY RECAP ********************************************************************
==> default:            to retry, use: --limit @/root/local.retry
==> default:
==> default: 10.0.1.10                  : ok=21   changed=18   unreachable=0    failed=1
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

.env 源文件位于 Laravel 任务文件夹下名为 files 的文件夹中,与我配置的其他项目相同,它们可以正常工作.文件 .env 失败后在 www 文件夹中找不到文件,因此不会复制它.

The .env source file is in a folder called files off the Laravel task folder, same as other items I configure which work OK. The file .env is not found in the www folder after it fails so it does not copy it.

推荐答案

在 Virtualbox 共享文件夹上使用 Ansible复制"模块显然存在一些问题(参见 https://github.com/ansible/ansible/issues/9526) - 是 /var/www/ 目录Vagrant 设置的共享文件夹?

There have been some issues with using the Ansible "copy" module on Virtualbox shared folders apparently (cf https://github.com/ansible/ansible/issues/9526) - is the /var/www/ directory a shared folder set up by Vagrant?

也许尝试先touch创建文件,然后复制它:

Maybe try touching the file first to create it, then copying it:

变化:

- name: copy .env file
  copy: src=env.j2 dest={{ conf_file }}

进入:

- name: create .env file
  shell: touch {{ conf_file }}
- name: copy .env file
  copy: src=env.j2 dest={{ conf_file }}

此文件复制错误已在 Ansible 1.9.3 版本(2015 年 7 月 19 日)中为某些用户修复,但对于使用 Windows 的用户来说仍然是一个问题截至 2016 年 6 月 14 日,运行 Virtualbox(与 vboxsf 共享有关)的主机.GitHub 问题仍处于关闭状态,但人们仍在评论并且似乎正在提供可能的修复.

This file copy error was fixed in the Ansible 1.9.3 release (July 19th 2015) for some users, but is still a problem for people on Windows hosts running Virtualbox (to do with vboxsf sharing) as of 2016-06-14. The GitHub issue is still closed, but people are still commenting and seem to be supplying possible fixes.

下面链接的解决方案似乎适用于大多数人(几个赞成).它建议将 Ansible remote_tmp 配置设置添加到您的本地 ~/.ansible.cfg,它指示 Ansible 使用目标(共享)文件系统上的临时文件夹:

The solution linked below appears to work for most people (several upvotes). It suggests adding the Ansible remote_tmp configuration setting to your local ~/.ansible.cfg which instructs Ansible to use a temp folder on the target (shared) filesystem:

https://github.com/ansible/ansible/issues/9526#issuecomment-199443969

这篇关于Ansible 文本文件忙错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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