Debian Codegraph @

test/integration/targets/git/tasks/missing_hostkey_acceptnew.yml

raw
1 - name: MISSING-HOSTKEY | check accept_newhostkey support
2 shell: ssh -o StrictHostKeyChecking=accept-new -V
3 register: ssh_supports_accept_newhostkey
4 ignore_errors: true
5
6 - block:
7 - name: MISSING-HOSTKEY | accept_newhostkey when ssh does not support the option
8 git:
9 repo: '{{ repo_format2 }}'
10 dest: '{{ checkout_dir }}'
11 accept_newhostkey: true
12 ssh_opts: '-o UserKnownHostsFile={{ remote_tmp_dir }}/known_hosts'
13 register: git_result
14 ignore_errors: true
15
16 - assert:
17 that:
18 - git_result is failed
19 - git_result.warnings is search("does not support")
20
21 when: ssh_supports_accept_newhostkey.rc != 0
22
23 - name: MISSING-HOSTKEY | checkout ssh://[email protected] repo without accept_newhostkey (expected fail)
24 git:
25 repo: '{{ repo_format2 }}'
26 dest: '{{ checkout_dir }}'
27 ssh_opts: '-o UserKnownHostsFile={{ remote_tmp_dir }}/known_hosts'
28 register: git_result
29 ignore_errors: true
30
31 - assert:
32 that:
33 - git_result is failed
34
35 - block:
36 - name: MISSING-HOSTKEY | checkout [email protected] repo with accept_newhostkey (expected pass)
37 git:
38 repo: '{{ repo_format2 }}'
39 dest: '{{ checkout_dir }}'
40 accept_newhostkey: true
41 key_file: '{{ github_ssh_private_key }}'
42 ssh_opts: '-o UserKnownHostsFile={{ remote_tmp_dir }}/known_hosts'
43 register: git_result
44
45 - assert:
46 that:
47 - git_result is changed
48
49 - name: MISSING-HOSTKEY | clear checkout_dir
50 file:
51 state: absent
52 path: '{{ checkout_dir }}'
53
54 - name: MISSING-HOSTKEY | checkout ssh://[email protected] repo with accept_newhostkey (expected pass)
55 git:
56 repo: '{{ repo_format3 }}'
57 dest: '{{ checkout_dir }}'
58 version: >-
59 {{ git_default_branch }}
60 accept_newhostkey: false # should already have been accepted
61 key_file: '{{ github_ssh_private_key }}'
62 ssh_opts: '-o UserKnownHostsFile={{ remote_tmp_dir }}/known_hosts'
63 register: git_result
64
65 - assert:
66 that:
67 - git_result is changed
68
69 - name: MISSING-HOSTEKY | Remove github.com hostkey from known_hosts
70 lineinfile:
71 dest: '{{ remote_tmp_dir }}/known_hosts'
72 regexp: "github.com"
73 state: absent
74
75 - name: MISSING-HOSTKEY | clear checkout_dir
76 file:
77 state: absent
78 path: '{{ checkout_dir }}'
79 when: github_ssh_private_key is defined and ssh_supports_accept_newhostkey.rc == 0