当我尝试使用Ansible从Bitbucket克隆存储库时,似乎任务“挂起”.
在documentation我找到了一些信息,但我没有使用SSH.
If the task seems to be hanging,first verify remote host is in
kNown_hosts. SSH will prompt user to authorize the first contact with
a remote host. One solution is to add StrictHostKeyChecking no in
.ssh/config which will accept and authorize the connection on behalf
of the user. However,if you run as a different user such as setting
sudo to True),for example,root will not look at the user .ssh/config
setting.
这些是我试过的两本Playbooks.他们都“挂”.
Playbook#1
- hosts: staging_MysqL user: ec2-user sudo: yes vars_files: - vars/mercurial.yml tasks: - name: Mercurial credentials setup action: template src=templates/hgrc.j2 dest=/home/ec2-user/.hgrc - name: Install Mercurial action: yum name=hg - name: Setup API repository action: command hg clone https://bbusername@bitbucket.org/username/my-repo -r default --debug
Playbook#2
- hosts: staging_MysqL user: ec2-user sudo: yes vars_files: - vars/mercurial.yml tasks: - name: Mercurial credentials setup action: template src=templates/hgrc.j2 dest=/home/ec2-user/.hgrc - name: Install Mercurial action: yum name=hg - name: Clone API repo hg: dest=/home/ec2-user repo=https://bbusername@bitbucket.org/username/my-repo
欢迎任何帮助.提前致谢!
解决方法
我为那些想要克隆私有存储库的人找到了更好的答案. Bitbucket具有称为“部署密钥”的功能.登录您的项目,进入“设置”和“部署密钥”. “添加密钥”,然后在项目部署过程中,在hg之前提供此密钥:
- file: dest=/var/www/someuser/.ssh/config state=touch mode=600 - lineinfile: dest=/var/www/someuser/.ssh/config line="Host bitbucket.org" state=present - copy: src=someuser.key dest=/var/www/someuser/.ssh/id_rsa mode=0600 - copy: src=someuser.key.pub dest=/var/www/someuser/.ssh/id_rsa.pub mode=0600 - lineinfile: dest=/var/www/someuser/.ssh/config line="IdentityFile ~/.ssh/id_rsa" - lineinfile: dest=/var/www/someuser/.ssh/config line=" StrictHostKeyChecking no" insertafter="Host bitbucket.org" state=present - name: install site code hg: repo='ssh://hg@bitbucket.org/somecode' dest=someuser revision=stable tags: someuser_code
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。