我一直在尝试让 Ansible 来配置远程计算机,并且我希望远程计算机能够使用自己的密钥进行设置,并且能够从 Bitbucket 克隆 git 存储库。
用户已设置,拥有自己的 id_rsa.pub,并且密钥已注册到 bitbucket。
但是,当我使用 Ansible Git 模块时,该模块看起来总是尝试使用运行 playbook 的机器上的密钥。
如何让 git 模块使用远程计算机上的 id_rsa.pub?
相关任务是这样的:
- name: be sure prom-king has an up-to-date clone of its own repository
git:
repo: "ssh://[email protected] /cdn-cgi/l/email-protection/prom-king.git"
dest: /home/promking/prom-king
accept_hostkey: yes
clone: yes
key_file: /home/promking/.ssh/id_rsa.pub
update: yes
相关库存是这个
# inventory file for use with the vagrant box in the testing directory.
[prom-king]
192.168.168.192 ansible_ssh_host=127.0.0.1 ansible_sudo=true ansible_connection=ssh ansible_ssh_port=2222 ansible_ssh_user=vagrant ansible_ssh_private_key_file=testing/.vagrant/machines/default/virtualbox/private_key
这就是我使用远程服务器上的密钥文件集从 Github 进行部署的方式。如果keyfile
参数为git
不起作用,那么你的剧本有问题:
- name: Creates .ssh directory for root
sudo: yes
file: path=/root/.ssh state=directory
# This public key is set on Github repo Settings under "Deploy keys"
- name: Upload the private key used for Github cloning
sudo: yes
copy: src=keys/github dest=/root/.ssh/github
- name: Correct SSH deploy key permissions
sudo: yes
file: dest=/root/.ssh/github mode=0600
- name: Deploy site files from Github repository
sudo: yes
git:
repo: [email protected] /cdn-cgi/l/email-protection:miohtama/foobar.git
dest: /srv/django/foobar
key_file: /root/.ssh/github
accept_hostkey: yes
force: yes
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)