简体   繁体   English

Ansible无法创建符号链接

[英]Ansible not able to create symlink

I'm trying to create a symlink and I'm not able to solve this error . 我正在尝试创建符号链接,但无法解决此错误。 Please suggest me a solution on how to solve this error 请建议我有关如何解决此错误的解决方案

Code: Creating a symlink for /usr/local/bin/terraform-env/bin/* in folder /usr/local/bin I tried with /usr/local/bin/ (with and without slash) 代码:我尝试使用/ usr / local / bin /(带斜线和不带斜线)在/ usr / local / bin文件夹中为/ usr / local / bin / terraform-env / 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}

Using ansible 2.8.3 使用ansible 2.8.3

the directory /usr/local/bin/ is not empty, refusing to convert it / usr / local / bin /目录不为空,拒绝转换

You are trying to create the symlink directly on the existing directory rather than creating an entry inside that dir to support the symlink. 您试图直接在现有目录上创建符号链接,而不是在该目录中创建条目以支持符号链接。 The following corrected task should get you going: 以下更正的任务应该可以帮助您:

- 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
    force: yes   
  with_items:
    - src: terraform
    - src: tfenv

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM