diff --git a/awx/main/tasks.py b/awx/main/tasks.py index f92a2c3070..7b2702cea3 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -629,6 +629,17 @@ class RunProjectUpdate(BaseTask): scm_password = False scm_url = update_scm_url(scm_type, scm_url, scm_username, scm_password) + + # When using Ansible >= 1.5, pass the extra accept_hostkey parameter to + # the git module. + if scm_type == 'git' and scm_url_parts.scheme == 'ssh': + try: + Version = distutils.version.StrictVersion + if Version(get_ansible_version()) >= Version('1.5'): + extra_vars['scm_accept_hostkey'] = 'true' + except ValueError: + pass + return scm_url, extra_vars def build_args(self, project_update, **kwargs): diff --git a/awx/playbooks/project_update.yml b/awx/playbooks/project_update.yml index 29046cace3..e9a8ba75d0 100644 --- a/awx/playbooks/project_update.yml +++ b/awx/playbooks/project_update.yml @@ -9,6 +9,7 @@ # scm_delete_on_update: true/false # scm_username: username (only for svn) # scm_password: password (only for svn) +# scm_accept_hostkey: true/false (only for git) - hosts: all connection: local @@ -19,9 +20,13 @@ file: path="{{project_path}}" state=absent when: scm_delete_on_update|default('') + - name: update project using git and accept hostkey + git: dest="{{project_path}}" repo="{{scm_url}}" version="{{scm_branch}}" force={{scm_clean}} accept_hostkey={{scm_accept_hostkey}} + when: scm_type == 'git' and scm_accept_hostkey is defined + - name: update project using git git: dest="{{project_path}}" repo="{{scm_url}}" version="{{scm_branch}}" force={{scm_clean}} - when: scm_type == 'git' + when: scm_type == 'git' and scm_accept_hostkey is not defined - name: update project using hg hg: dest="{{project_path}}" repo="{{scm_url}}" revision="{{scm_branch}}" force={{scm_clean}}