Ansible无法创建符号链接

0 人关注

我正试图创建一个符号链接,但我无法解决这个错误。请给我一个解决方案,如何解决这个错误。

代码。为/usr/local/bin/terraform-env/bin/*文件夹中的/usr/local/bin创建一个符号链接 我试着用/usr/local/bin/(有斜线和无斜线)来做。

- name: Move tfenv   file:
    src: "/usr/local/bin/terraform-env/bin/{{ item.src }}"
    dest: "/usr/local/bin/"
    state: link
    owner: root
    group: root
    mode: 755
    force: yes   
  with_items:
    - src: terraform
    - src: tfenv
TASK [terraform : Move tfenv] **************************************************
task path: /opt/ansible/roles/terraform/tasks/main.yml:16
failed: [127.0.0.1] (item={'src': 'terraform'}) => {"changed": false, "gid": 0, "group": "root", "item": {"src": "terraform"}, "mode": "0755", "msg": "the directory /usr/local/bin/ is not empty, refusing to convert it", "owner": "root", "path": "/usr/local/bin/", "size": 4096, "state": "directory", "uid": 0}
failed: [127.0.0.1] (item={'src': 'tfenv'}) => {"changed": false, "gid": 0, "group": "root", "item": {"src": "tfenv"}, "mode": "0755", "msg": "the directory /usr/local/bin/ is not empty, refusing to convert it", "owner": "root", "path": "/usr/local/bin/", "size": 4096, "state": "directory", "uid": 0}

使用ansible 2.8.3

linux
ansible
ansible-2.x
user6826691
user6826691
发布于 2019-09-10
1 个回答
Zeitounator
Zeitounator
发布于 2019-09-10
已采纳
0 人赞同

目录/usr/local/bin/不是空的,拒绝转换它

你试图直接在现有目录上创建符号链接,而不是在目录中创建一个条目来支持符号链接。下面这个正确的任务应该能让你开始工作。

- name: Move tfenv   file:
    src: "/usr/local/bin/terraform-env/bin/{{ item.src }}"
    dest: "/usr/local/bin/{{ item.src }}"
    state: link
    owner: root
    group: root
    mode: 755