在运行shell命令创建符号链接时,Ansible卡住了

时间:2018-05-30 10:57:41

标签: ansible ansible-2.x

对于创建符号链接的下面任务,ansible卡住并且没有输出5分钟

- name: Registering the service my-service
      shell: > 
        sudo ln -s {{KARAF_HOME}}/bin/karaf-service /etc/init.d/

在ctrl + c上输出

♥Process WorkerProcess-19:
Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib/python2.7/dist-packages/ansible/executor/process/worker.py", line 118, in run
    self._rslt_q
  File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 138, in run
    res = self._execute()
  File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 561, in _execute
    result = self._handler.run(task_vars=variables)
  File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/shell.py", line 27, in run
    result = command_action.run(task_vars=task_vars)
  File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/command.py", line 24, in run
 [ERROR]: User interrupted execution

我也尝试过以下选项但又面临错误

file: src="{{KARAF_HOME}}/bin/my-service" dest="/etc/init.d/" state=link  owner=root group=root

产生以下错误

fatal: [my-host]: FAILED! => {"changed": false, "gid": 0, "group": "root", "mode": "0755", "msg": "refusing to convert between directory and link f
or /etc/init.d/", "owner": "root", "path": "/etc/init.d/", "size": 4096, "state": "directory", "uid": 0}

更新: 对于运行shell它寻找密码,但我按照@imjoseangel

的推荐尝试了下面
- file: become=true src="{{KARAF_HOME}}/bin/my-service" dest="/etc/init.d/my-service" state=link

但低于错误

"msg": "Unsupported parameters for (file) module: become Supported parameters include: attributes,...

1 个答案:

答案 0 :(得分:0)

嗨destinatios必须是文件而不是目录。

file: src="{{KARAF_HOME}}/bin/my-service" dest="/etc/init.d/my-service" state=link  owner=root group=root