From cbb5d1e5d502ee14a58e218f223b690fb4a1dce5 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Wed, 5 Jul 2017 13:19:07 -0700 Subject: [PATCH] Update git test to not rm ~/.ssh/known_hosts. --- test/integration/credentials.template | 3 --- .../targets/git/tasks/missing_hostkey.yml | 15 ++++++--------- test/integration/targets/git/vars/main.yml | 2 ++ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/test/integration/credentials.template b/test/integration/credentials.template index 61d5d6e38f..b183e46938 100644 --- a/test/integration/credentials.template +++ b/test/integration/credentials.template @@ -18,9 +18,6 @@ gce_project_id: azure_subscription_id: "{{ lookup('env', 'AZURE_SUBSCRIPTION_ID') }}" azure_cert_path: "{{ lookup('env', 'AZURE_CERT_PATH') }}" -# GITHUB SSH private key - a path to a SSH private key for use with github.com -github_ssh_private_key: "{{ lookup('env','HOME') }}/.ssh/id_rsa" - # Cloudflare Credentials cloudflare_api_token: cloudflare_email: diff --git a/test/integration/targets/git/tasks/missing_hostkey.yml b/test/integration/targets/git/tasks/missing_hostkey.yml index c58b5834f0..1de79a6a18 100644 --- a/test/integration/targets/git/tasks/missing_hostkey.yml +++ b/test/integration/targets/git/tasks/missing_hostkey.yml @@ -1,15 +1,10 @@ --- -- name: remove known_host files - file: - state: absent - path: '{{ item }}' - with_items: "{{known_host_files}}" - - name: checkout ssh://git@github.com repo without accept_hostkey (expected fail) git: repo: '{{ repo_format2 }}' dest: '{{ checkout_dir }}' + ssh_opts: '-o UserKnownHostsFile={{ output_dir }}/known_hosts' register: git_result ignore_errors: true @@ -23,19 +18,20 @@ dest: '{{ checkout_dir }}' accept_hostkey: true key_file: '{{ github_ssh_private_key }}' + ssh_opts: '-o UserKnownHostsFile={{ output_dir }}/known_hosts' register: git_result when: github_ssh_private_key is defined - assert: that: - 'git_result.changed' - when: not git_result|skipped - + when: github_ssh_private_key is defined - name: clear checkout_dir file: state: absent path: '{{ checkout_dir }}' + when: github_ssh_private_key is defined - name: checkout ssh://git@github.com repo with accept_hostkey (expected pass) git: @@ -44,10 +40,11 @@ version: 'master' accept_hostkey: false # should already have been accepted key_file: '{{ github_ssh_private_key }}' + ssh_opts: '-o UserKnownHostsFile={{ output_dir }}/known_hosts' register: git_result when: github_ssh_private_key is defined - assert: that: - 'git_result.changed' - when: not git_result|skipped + when: github_ssh_private_key is defined diff --git a/test/integration/targets/git/vars/main.yml b/test/integration/targets/git/vars/main.yml index 1a3b6dbe04..f4364bc481 100644 --- a/test/integration/targets/git/vars/main.yml +++ b/test/integration/targets/git/vars/main.yml @@ -18,3 +18,5 @@ known_host_files: - '/etc/ssh/ssh_known_hosts' git_version_supporting_depth: 1.9.1 git_version_supporting_ls_remote: 1.7.5 +# path to a SSH private key for use with github.com (tests skipped if undefined) +# github_ssh_private_key: "{{ lookup('env', 'HOME') }}/.ssh/id_rsa"