以下是ssh&的我的ansible playbook文件克隆回购。
- name: Creates .ssh directory for root
sudo: yes
file: path=/root/.ssh state=directory
- name: Configure SSH public key & permissions
copy: src=id_rsa dest=/root/.ssh/id_rsa.pub mode=0644 owner=root group=root
- name: Configure SSH private key & permissions
copy: src=id_rsa dest=/root/.ssh/id_rsa mode=0600 owner=root group=root
- name: Configure SSH config
copy: src=config dest=/root/.ssh/config
- name: Application installation
git: repo={{ repo_name }}
dest={{ project_path }}
version={{ deployment_version }}
recursive=yes
track_submodules=yes
accept_hostkey=yes
clone=yes
key_file=/root/.ssh/id_rsa
从sudo用户运行此脚本时,我收到以下错误。请帮我看看我做错了哪里。
致命:[127.0.0.1]:失败! => {"已更改":false," cmd":" / usr / bin / git 克隆 - 原始来源'' / var / www / html / myapp","失败":是的, " msg":"克隆到' / var / www / html / myapp' ... \ nkey_load_public: 格式无效\ r \ n \ nkey_load_public:格式无效\ r \ n否则授权 (publickey)。\ r \ n \ nfatal:无法从远程读取 存储库。\ n \ n请确保您具有正确的访问权限 权利\ n和存储库存在。"," rc":128," stderr":"克隆 进入' / var / www / html / myapp' ... \ nkey_load_public:无效 format \ r \ nkey_load_public:格式无效\ r \ n允许拒绝 (publickey)。\ r \ n \ nfatal:无法从远程读取 存储库。\ n \ n请确保您具有正确的访问权限 版权所有。\ n"," stdout":""," stdout_lines": []}
答案 0 :(得分:0)
您正在为公共和私人部分复制相同的密钥。我认为您需要检查:
- name: Configure SSH public key & permissions
sudo: yes
copy: src=id_rsa.pub dest=/root/.ssh/id_rsa.pub mode=0644 owner=root group=root