请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

ansible-playbook -i inventory/testenv ./deploy.yml提示line 1, column 3错误

(.py3-a2.5-env) [deploy@iZuf6iq8e7ya9v3ix71k0pZ test_playbooks]$ ansible-playbook -i inventory/testenv ./deploy.yml

ERROR! The requested action was not found in configured module paths. Additionally, core modules are missing. If this is a checkout, run 'git submodule update --init --recursive' to correct this problem.

The error appears to have been in '/home/deploy/test_playbooks/roles/testbox/tasks/main.yml': line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Print server name and user to remote testbox
  ^ here


The error appears to have been in '/home/deploy/test_playbooks/roles/testbox/tasks/main.yml': line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Print server name and user to remote testbox
  ^ here

main.yml

- name: Print server name and user to remote testbox
  shell: "echo 'Currently {{ user }} is logining {{ server_name }}' > {{ output }}"

正在回答 回答被采纳积分+3

6回答

提问者 smniuhe 2020-07-18 17:21:05

遇到这个问题,应该是某个安装环节出了问题,我是继续先前学,然后重新再安装,解决了,建议尽量和老师环境一样,可以减少错误率,github clone ansible repository 的问题可以通过 gitee 去解决

1 回复 有任何疑惑可以回复我~
一路向北 2020-07-12 10:32:57

在ansible目录执行git submodule update --init --recursive
然后再尝试 deploy

0 回复 有任何疑惑可以回复我~
  • 提问者 smniuhe #1
    执行完后,-bash: ansible-playbook: 未找到命令
    回复 有任何疑惑可以回复我~ 2020-07-12 11:15:56
  • 提问者 smniuhe #2
    第一次应该是执行完成的,后面发现 ansible 命令都找不到了,第二次执行出现下面问题,是否是网络问题,老师 ansible 版本分支是 stabel-2.1
    
    ```
    
    
    
    (.py3-a2.5-env) [deploy@iZuf6iq8e7ya9v3ix71k0pZ ansible]$ git submodule update --init --recursive
    
    正克隆到 'lib/ansible/modules/core'...
    
    remote: Enumerating objects: 44408, done.
    
    error: RPC failed; result=18, HTTP code = 200.00 KiB/s
    
    fatal: The remote end hung up unexpectedly
    
    fatal: 过早的文件结束符(EOF)
    
    fatal: index-pack failed
    
    无法克隆 'https://github.com/ansible/ansible-modules-core' 到子模组路径 'lib/ansible/modules/core'
    ```
    
    ```
    (.py3-a2.5-env) [deploy@iZuf6iq8e7ya9v3ix71k0pZ ansible]$ ansible-playbook --version
    ansible-playbook 2.1.6.0 (stable-2.1 7baf994f2c) last updated 2019/12/22 15:32:58 (GMT +800)
      lib/ansible/modules/core:  not found - use git submodule update --init lib/ansible/modules/core
      lib/ansible/modules/extras:  not found - use git submodule update --init lib/ansible/modules/extras
      config file =
      configured module search path = Default w/o overrides
    ```
    回复 有任何疑惑可以回复我~ 2020-07-12 11:25:59
  • 应该是网络问题,建议删除官方仓库,使用国内ansible镜像仓库
    https://gitee.com/mirrors/ansible
    重新进行ansible安装
    回复 有任何疑惑可以回复我~ 2020-07-12 13:14:11
提问者 smniuhe 2020-07-12 09:57:03

(.py3-a2.5-env) [deploy@iZuf6iq8e7ya9v3ix71k0pZ test_playbooks]$ vim deploy.yml


//img1.sycdn.imooc.com//szimg/5f0a6d9309c0d99708880348.jpg



(.py3-a2.5-env) [deploy@iZuf6iq8e7ya9v3ix71k0pZ test_playbooks]$ vim inventory/testenv

//img1.sycdn.imooc.com/szimg/5f0a6dc5097dd7d306720410.jpg


(.py3-a2.5-env) [deploy@iZuf6iq8e7ya9v3ix71k0pZ test_playbooks]$ vim roles/testbox/tasks/main.yml
//img1.sycdn.imooc.com//szimg/5f0a6dea09fc20a512100258.jpg

0 回复 有任何疑惑可以回复我~
一路向北 2020-07-12 09:54:09

建议把代码内容发过来

0 回复 有任何疑惑可以回复我~
  • 提问者 smniuhe #1
    贴出来了
    回复 有任何疑惑可以回复我~ 2020-07-12 09:58:01
提问者 smniuhe 2020-07-12 09:45:24

相关代码和结构

https://img1.sycdn.imooc.com//szimg/5f0a6b1209a8275414440448.jpghttps://img1.sycdn.imooc.com//szimg/5f0a6b00098e2f4213200220.jpg

0 回复 有任何疑惑可以回复我~
一路向北 2020-07-12 09:43:04

建议把代码贴过来看一下

0 回复 有任何疑惑可以回复我~
  • 提问者 smniuhe #1
    老师,我贴上面了
    回复 有任何疑惑可以回复我~ 2020-07-12 09:45:41
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信