美文网首页
ansible split 使用

ansible split 使用

作者: _fishman | 来源:发表于2020-04-01 09:08 被阅读0次
    - name: deploy | 获取branch
      set_fact:
        branch: "{{serviceNAME.split('-')[-2] }}" 
    - debug: var=branch 

    - name: deploy | 获取commitid
      set_fact:
        commitid: "{{serviceNAME.split('-')[-1] }}"

    - debug: var=commitid

    - name: deploy | 获取commitid
      set_fact:
        commitid: "{{commitid.split('.')[0]}}"
    - debug: var=commitid 
TASK [debug] **********************************************************************************************************************************************************
ok: [10.111.0.2] => {
    "serviceNAME": "yt-sync-center-master-72b45076.zip"
}

TASK [deploy | 获取branch] **********************************************************************************************************************************************
ok: [10.111.0.2]

TASK [debug] **********************************************************************************************************************************************************
ok: [10.111.0.2] => {
    "branch": "master"
}

TASK [deploy | 获取commitid] ********************************************************************************************************************************************
ok: [10.111.0.2]

TASK [debug] **********************************************************************************************************************************************************
ok: [10.111.0.2] => {
    "commitid": "72b45076.zip"
}

TASK [deploy | 获取commitid] ********************************************************************************************************************************************
ok: [10.111.0.2]

TASK [debug] **********************************************************************************************************************************************************
ok: [10.111.0.2] => {
    "commitid": "72b45076"
}

PLAY RECAP ************************************************************************************************************************************************************
10.111.0.2                 : ok=22   changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0  
    - name: deploy | 获取commitid
      set_fact:
        commitid: "{{commitid.split('.zip')[0]}}"
    - debug: var=commitid 

相关文章

网友评论

      本文标题:ansible split 使用

      本文链接:https://www.haomeiwen.com/subject/zvfouhtx.html