脚本内容
- hosts: prod
vars:
gitkey_path: /home/ubuntu/.ssh/gitkey
project_path: /home/ubuntu/qin-server
tasks:
- name: Create project directory
file:
path: "{{ project_path }}"
recurse: yes
state: directory
- name: Clone Git repository
git:
repo: git@e.coding.net:mangofuture/qin-server.git
dest: "{{ project_path }}"
key_file: "{{ gitkey_path }}"
accept_hostkey: yes
force: yes
version: product_alg
ignore_errors: yes
- name: add key to git pull command
command:
chdir: "{{ project_path }}"
cmd: "git config core.sshCommand 'ssh -i {{ gitkey_path }}'"