ansible에서 활용할 수 있는 git clone 레시피이다.

git clone 하려면 기본적으로 권한이 필요한다. public일 때는 이슈는 없지만 private일 때는 rsa 키가 필요하다. 

github 키를 얻는다 (github.com에서 github 키를 얻는 방법은 https://github.com/KennethanCeyer/tutorial-git 참고) 

private 키를 roles/files에 추가한다

- name: github 키를 복사
  sudo: yes
  copy: src=github_key dest={{ item }} mode=0600 group=www owner=www
  with_items:
  - /home/www/.ssh/github_key

 

- name: ansible-webserver 소스 복사
  git:
    repo: git@github.com:knight76/ansible-example.git
    dest: "{{program_path}}/nsible-example"
    force: yes
    clone: yes
    accept_hostkey: yes
    key_file: /home/www/.ssh/github_key
Posted by '김용환'
,