Ansible 通过 Mathias 安装程序安装 .dotfiles

Ansible install .dotfiles through Mathias installer

我正在尝试使用 ansible 在远程服务器上安装以下文件 (mathiasbynens dotfiles)。

这里是 roles/dotfiles/tasks/main.yml 文件内容:

---
 - name: Flag if dotfiles directory exists
   stat: path=/home/path/dotfiles
   register: dotfilesdirectory

 - name: Remove old dotfiles directory
   file: path=/home/path/dotfiles state=absent
   when: dotfilesdirectory.stat.exists
   register: olddirectoryremoved

 - name: Clone repository
   git: repo=https://github.com/mathiasbynens/dotfiles.git dest=/home/path/dotfiles
   when: not dotfilesdirectory.stat.exists or olddirectoryremoved|success
   register: repositorycloned

 - name: Instantiate dotfiles
   shell: source bootstrap.sh
   args:
    chdir: /home/path/dotfiles
    executable: /bin/bash
   when: repositorycloned|success

运行使用剧本并使用 -vvvv:

时,我得到以下输出
fatal: [ready]: FAILED! => {"changed": true, "cmd": "bootstrap.sh", "delta": "0:00:00.003190", "end": "2016-04-17 12:25:22.480491", "failed": true, "invocation": {"module_args": {"_raw_params": "bootstrap.sh", "_uses_shell": true, "chdir": "/home/path/dotfiles", "creates": null, "executable": "/bin/bash", "removes": null, "warn": true}, "module_name": "command"}, "rc": 127, "start": "2016-04-17 12:25:22.477301", "stderr": "/bin/bash: bootstrap.sh: command not found", "stdout": "", "stdout_lines": [], "warnings": []}

知道我做错了什么吗?当我在点文件目录(即 source /home/path/dotfiles/bootstrap.sh)中时,我想要做的就是 运行 source 的 shell 命令和 bootstrap.sh 的参数。我尝试的所有操作要么导致脚本在执行到列表中的最后一个任务时挂起,要么因上面的错误消息而出错。

提前致谢!

你看过bootstrap.sh的内容了吗?您不想获取该文件。你应该按如下方式执行

./bootstrap.sh --force

或者如果您真的需要获取它(可能不是 Ansible 任务),您可以完全按照 README.md 文件

中的说明进行操作

set -- -f; source bootstrap.sh