1、相关git参数:
git_version: 2.0.0
git_dir: /usr/local
2、roles包共两个部分,一个是common,一个是git_install,其中common负责用yum安装相关组件:
3、git_install包负责解压,设置链接:
- name: Copy Git Software To Redhat Client
copy: src=git-{{ git_version }}.tar.gz dest=/tmp/git-{{ git_version }}.tar.gz owner=root group=root
- name: Uncompression Git Software To Redhat Client
shell: tar zxf /tmp/git-{{ git_version }}.tar.gz -C {{ git_dir }}
- name: Delete Git Software Variable In Redhat Client
shell: cp -a -f /usr/bin/{{ item }} /usr/bin/{{ item }}_back
with_items:
- git
- git-cvsserver
- gitk
- git-receive-pack
- git-shell
- git-upload-archive
- git-upload-pack
ignore_errors: True
- name: Copy Git Variable To Redhat Client
shell: ln -s -f {{ git_dir }}/git-{{ git_version }}/bin/{{ item }} /usr/bin/{{ item }}
with_items:
- git
- git-cvsserver
- gitk
- git-receive-pack
- git-shell
- git-upload-archive
- git-upload-pack
4、完整的安装步骤如下:
下载roles包:https://pan.baidu.com/s/1wh-zyfyDBemoYqx8E4348A
执行安装:ansible-playbook /你的路径/git_install.yml --extra-vars "host=你的主机群组 user=root"