ansible git模块
ansible 127.0.0.1 -m git -a "repo='https://github.com/ansible/ansible.git' dest='/tmp/ansible'"
通过用户名和密码拉取git代码
---
- hosts: all
gather_facts: no
become: yes
tasks:
- name: install git package
apt:
name: git
- name: Get updated files from git repository
git:
repo: "http://{{ githubuser | urlencode }}:{{ githubpassword | urlencode }}@github.com/dong4stop/hello.git"
dest: /tmp/git
version: v1.0
若密码中有特殊字符可以加上urlencode,{{ githubpassword | urlencode }}。
ansible-playbook git.yml -e "githubuser=*\*\\*\*"; -e "githubpassword=\*\**";