我想从git中获取我的RoR代码,进行构建,然后通过Ansible脚本将其推送到多个远程计算机。我已经在Ansible的hosts文件下提到了所有机器的详细信息。
我已经创建了ssh密钥并将其推送到我的github帐户的ssh密钥部分下。 这是我的剧本。yml看起来像这样。
---
- hosts: ansibleserver
tasks:
- git:
repo: git@github.com:abc/abc.git
dest: /tmp/LMS/
version: master
key_file: /root/.ssh/id_rsa
- hosts: redisservers
tasks:
- name: Copy file to a remote server
copy:
src: /root/LMS/
dest: /root/LMS/
- hosts: webservers
user: root
vars:
user: root
home_directory: "/root/LMS/app/"
rails_env: "development"
deploy_to: "{{ /root/LMS/ }}"
~
我无法执行一项任务,以下是错误。
PLAY [ansibleserver] ***************************************************************************************************************************************************
TASK [Gathering Facts] *************************************************************************************************************************************************
fatal: [192.168.193.30]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: \\S\nKernel \\r on an \\m\n !!!WARNING!!! \n############################################################################\nACCESS TO THIS SYSTEM IS STRICTLY RESTRICTED TO AUTHORIZED PERSONS ONLY \nUNAUTHORIZED ACCESS TO THIS SYSTEM IS NOT ALLOWED AND EVERY ACTIVITY IS MONITORED ON THIS \n SYSTEM. \t\t\n###########################################################################################\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", "unreachable": true}
PLAY RECAP *************************************************************************************************************************************************************
192.168.193.30 : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
由于它在第一项任务上失败,因此无法移至第二和第三项。
答案 0 :(得分:0)
首先检查这是否不是YAML语法问题:
- git: Cloning LMS code from git
repo: git@github.com:**/abc.git
dest: /root/deployer/setup/abc/
version: master
含义:与Git本身相比,Git module的选项应该缩进。
参见the examples:
# Example git checkout from Ansible Playbooks
- git:
repo: 'https://foosball.example.org/path/to/repo.git'
dest: /srv/checkout
version: release-0.22