14
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

「ansible」github private repository clone 時の「はまりポイント」解決

Last updated at Posted at 2015-06-23

githubのprivateリポジトリを引っ張ってくる時にハマったのでメモ
private repositoryの情報がうまく見つけられなかったのでメモっておこうと思う。後で見直すかもしれない

以下のエラーが出て先に進めなくなった

  • no file
  • no directory
  • permission denied

解決策

  • Vagrantfileに以下を追加して調査する(変数名は何でも可)
.sh
  config.vm.provision "ansible" do |anchan|
    anchan.verbose = "vvvv"
  end

以下の様にファイルに修正や追加を加える

~/.ssh/config

  • StrinctHostKeyCheckingをnoにする
  • ForwardAgentをyesにする
.sh
Host github.com
  HostName github.com
  User git
  Port 22
  #IdentityFile ~/.ssh/work_private_rsa
  #IdentityFile ~/.ssh/work2_private_rsa
  #IdentityFile ~/.ssh/work3_private_rsa
  #IdentityFile ~/.ssh/master_private_rsa
  #IdentityFile ~/.ssh/sinsnk_private_rsa
  IdentityFile ~/.ssh/id_rsa
  TCPKeepAlive yes
  IdentitiesOnly yes
  StrictHostKeyChecking no
  ForwardAgent yes

ansible.cfg

  • ForwardAgentをyesにする
.sh
[defaults]
private_key_file=~/.ssh/id_rsa

[ssh_connection]
ssh_args = -o ForwardAgent=yes

hosts

.ssh
[servers]
192.168.1.10 ansible_ssh_user=vagrant ansible_ssh_private_key_file=/Users/sinsnk/workspace/hogechan/.vagrant/machines/default/virtualbox/private_key

playbook.yml

  • 以下のように設定する
  • 特にハマったのは、sudo: false←これないとpermission deniedが出続ける
.sh
- hosts: all
  user: vagrant
  sudo: yes
  vars:
    work_dir: /home/vagrant
    repos_dir: "{{ work_dir }}/hogechan"
    branch: master
  tasks:
    - name: clone hogechan
      git: repo=git@github.com:sinsnk/hogechan.git dest={{ repos_dir }} version={{ branch }} accept_hostkey=yes key_file=/Users/sinsnk/workspace/hogechan/vagrant/.vagrant/machines/default/virtualbox/private_key
      sudo: false

今回僕のように設定は書いたはずなのにうまくいかない時は、ログをverboseレベルにして追って、原因を見るのがよいでしょう

14
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?