Checkout branch locally in idempotent manner
This commit is contained in:
parent
1b2aeebdbf
commit
f72141acb2
@ -2,7 +2,21 @@
|
||||
# Clone system-config locally in the command machine
|
||||
- git: repo="{{ system_config_repo_url }}"
|
||||
dest=/tmp/infra-ansible/system-config/production
|
||||
version="{{ system_config_branch }}"
|
||||
accept_hostkey=True
|
||||
force=True
|
||||
tags: clone_system_config_locally
|
||||
|
||||
- command: git symbolic-ref --short -q HEAD
|
||||
args:
|
||||
chdir: /tmp/infra-ansible/system-config/production
|
||||
register: checked_out_branch
|
||||
|
||||
- command: git show-ref --verify --quiet "{{ system_config_branch }}"
|
||||
register: system_config_branch_exists
|
||||
ignore_errors: True
|
||||
|
||||
- command: git checkout -b "{{ system_config_branch }}"
|
||||
when: system_config_branch_exists|failed
|
||||
|
||||
- command: git checkout "{{ system_config_branch }}"
|
||||
when: system_config_branch_exists|success and checked_out_branch.stdout != "{{ system_config_branch }}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user