playbooks/clone-repo: 1 task for cloning, checking out and updating
Signed-off-by: Marc Mattmüller <marc.mattmueller@netmodule.com>
This commit is contained in:
parent
0b66f54f97
commit
14b51efb5d
|
|
@ -18,11 +18,6 @@
|
||||||
path: "{{ ssh_auto_sshadd_file }}"
|
path: "{{ ssh_auto_sshadd_file }}"
|
||||||
register: auto_sshadd_stat
|
register: auto_sshadd_stat
|
||||||
|
|
||||||
- name: Check if repo exists
|
|
||||||
stat:
|
|
||||||
path: "{{ git_repo_path }}"
|
|
||||||
register: repo_dir_stat
|
|
||||||
|
|
||||||
- name: Prepare auto ssh-add file
|
- name: Prepare auto ssh-add file
|
||||||
register: prepareAutoSshAdd
|
register: prepareAutoSshAdd
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
|
|
@ -31,31 +26,16 @@
|
||||||
chmod +x {{ ssh_auto_sshadd_file }}
|
chmod +x {{ ssh_auto_sshadd_file }}
|
||||||
when: not auto_sshadd_stat.stat.exists
|
when: not auto_sshadd_stat.stat.exists
|
||||||
|
|
||||||
- name: Load SSH key
|
- name: Clone and Update Repository
|
||||||
register: loadingSshKey
|
register: clonerepo
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
eval `ssh-agent -s`
|
eval `ssh-agent -s`
|
||||||
SSH_PASS={{ssh_passphrase}} DISPLAY=1 SSH_ASKPASS="{{ssh_auto_sshadd_file}}" ssh-add {{ssh_keyfile}} < /dev/null
|
SSH_PASS={{ssh_passphrase}} DISPLAY=1 SSH_ASKPASS="{{ssh_auto_sshadd_file}}" ssh-add {{ssh_keyfile}} < /dev/null
|
||||||
- name: Display ssh key loading output
|
|
||||||
debug:
|
|
||||||
msg: "{{loadingSshKey.stdout_lines}}"
|
|
||||||
|
|
||||||
- name: Clone a develop branch
|
|
||||||
register: clonerepo
|
|
||||||
ansible.builtin.shell: |
|
|
||||||
git clone ssh://git@bitbucket.gad.local:7999/nm-nsp/{{git_repo_path}}.git {{git_repo_path}}
|
git clone ssh://git@bitbucket.gad.local:7999/nm-nsp/{{git_repo_path}}.git {{git_repo_path}}
|
||||||
when: not auto_sshadd_stat.stat.exists
|
|
||||||
- name: Display cloning output
|
|
||||||
debug:
|
|
||||||
msg: "{{clonerepo.stdout_lines}}"
|
|
||||||
|
|
||||||
- name: Checkout and update branch
|
|
||||||
register: updaterepo
|
|
||||||
ansible.builtin.shell: |
|
|
||||||
cd nwl-ci
|
cd nwl-ci
|
||||||
git checkout develop
|
git checkout develop
|
||||||
git fetch -ap
|
git fetch -ap
|
||||||
git pull
|
git pull
|
||||||
- name: Display repo update output
|
- name: Display ssh key loading output
|
||||||
debug:
|
debug:
|
||||||
msg: "{{updaterepo.stdout_lines}}"
|
msg: "{{clonerepo.stdout_lines}}"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue