sur*_*190 6 git ansible ansible-playbook
我想SHA-1用Ansible 存储当前检出的代码版本的提交哈希.
我希望set_fact将此版本用于其他角色.
Mic*_*sek 17
gitAnsible中的模块为您返回此信息,您只需将其注册到变量中(变量gitresult在下面的示例中).
- hosts: web
tasks:
- name: Checkout repo
git:
repo=https://github.com/michalgasek/www-discogs.git
dest=/vagrant/checkout
update=yes
accept_hostkey=yes
register: gitresult
- debug: msg="SHA-1 before git update is {{ gitresult.before }}"
- debug: msg="SHA-1 after git update is {{ gitresult.after }}"
Run Code Online (Sandbox Code Playgroud)
跑步:
PLAY ***************************************************************************
TASK [setup] *******************************************************************
ok: [192.168.2.201]
TASK [Checkout repo] ***********************************************************
ok: [192.168.2.201]
TASK [debug] *******************************************************************
ok: [192.168.2.201] => {
"msg": "SHA-1 before git update is 87544e2ea1c8dec30e5fc68302caa262b10affda"
}
TASK [debug] *******************************************************************
ok: [192.168.2.201] => {
"msg": "SHA-1 after git update is 87544e2ea1c8dec30e5fc68302caa262b10affda"
}
Run Code Online (Sandbox Code Playgroud)
我希望它能解决你的问题.
| 归档时间: |
|
| 查看次数: |
3852 次 |
| 最近记录: |