执行ansible-playbook时报错:TASK [elasticsearch : Create Elasticsearch configuration directory symbolic link] *** fatal: [ngiam-01]: FAILED! => {"changed": false, "gid": 499, "group": "elasticsearch", "mode": "0750", "msg": "refusing to convert from directory to symlink for /etc/elasticsearch", "owner": "elasticsearch", "path": "/etc/elasticsearch", "size": 237, "state": "directory", "uid": 499} fatal: [ngiam-02]: FAILED! => {"changed": false, "gid": 499, "group": "elasticsearch", "mode": "0750", "msg": "refusing to convert from directory to symlink for /etc/elasticsearch", "owner": "elasticsearch", "path": "/etc/elasticsearch", "size": 237, "state": "directory", "uid": 499} fatal: [ngiam-03]: FAILED! => {"changed": false, "gid": 499, "group": "elasticsearch", "mode": "0750", "msg": "refusing to convert from directory to symlink for /etc/elasticsearch", "owner": "elasticsearch", "path": "/etc/elasticsearch", "size": 237, "state": "directory", "uid": 499},是什么问题,该怎么解决
时间: 2023-07-05 14:31:40 浏览: 250
docker-ansible-playbook:用于创建执行ansible-playbook的基本控制节点的Docker容器
这个错误是因为Ansible在尝试将目录(/etc/elasticsearch)转换为符号链接时失败了,因为该目录已经存在并且是一个目录而不是符号链接。要解决这个问题,可以在playbook中添加一个任务,检查目录是否存在并且是一个目录而不是符号链接,如果是,则删除目录并创建符号链接。具体操作如下:
```yaml
- name: Ensure Elasticsearch configuration directory is a symbolic link
stat:
path: /etc/elasticsearch
register: elasticsearch_dir
- name: Remove Elasticsearch configuration directory if it is a directory
file:
path: /etc/elasticsearch
state: absent
when: elasticsearch_dir.stat.isdir
- name: Create Elasticsearch configuration directory symbolic link
file:
src: "{{ elasticsearch_config_dir }}"
dest: /etc/elasticsearch
state: link
```
其中,elasticsearch_config_dir是一个变量,它包含实际的Elasticsearch配置目录的路径。这个任务将检查/etc/elasticsearch是否是一个目录并删除它(如果是),然后创建一个符号链接,指向实际的Elasticsearch配置目录。
希望这可以帮助你解决问题。
阅读全文