Ansible找不到下载的文件

时间:2019-07-09 08:36:27

标签: ansible

我对Ansible还是陌生的,他试图使安装TeamSpeak 3服务器的工作自动化。不幸的是,我遇到了一些错误:

  • 如果我尝试使用ansible-playbook命令运行它,即使我在清单中明确声明了become_pass,它也会要求输入sudo密码
  • 如果我使用--ask-become-pass参数重试它,则会运行前两个步骤,并指出在连接到服务器时找不到下载的文件,但是我可以确保它存在

这是权限错误吗?还是因为尚未存储ssh密钥而无法访问主目录?

这是剧本(目前):

---
- hosts: all
  gather_facts: false
  become: yes
  tasks:
    - name: Adding TeamSpeak User
      user:
        name: ts3

    - name: Download TeamSpeak
      get_url:
        url: https://files.teamspeak-services.com/releases/server/3.9.1/teamspeak3-server_linux_amd64-3.9.1.tar.bz2
        dest: /home/ts3/

    - name: Extract downloaded folder
      unarchive:
        src: /home/ts3/teamspeak3-server_linux_amd64-3.9.1.tar.bz2
        dest: /home/ts3

1 个答案:

答案 0 :(得分:1)

remote_src丢失

- name: Unarchive a file that is already on the remote machine
  unarchive:
    src: /tmp/foo.zip
    dest: /usr/local/bin
    remote_src: yes

通过将src替换为如下所示的URL,您可以将两个任务合并为一个任务

- name: Unarchive a file that needs to be downloaded (added in 2.0)
  unarchive:
    src: https://example.com/example.zip
    dest: /usr/local/bin
    remote_src: yes