Debian Codegraph @

ansible_collections/community/docker/tests/integration/targets/generic_ssh_connection/tasks/main.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 ####################################################################
7 # WARNING: These are designed specifically for Ansible tests #
8 # and should not be used as examples of how to write Ansible roles #
9 ####################################################################
10
11 - name: Get docker daemon information directly
12 community.docker.docker_host_info:
13 register: output
14
15 - name: Make sure we got information
16 ansible.builtin.assert:
17 that:
18 - 'output.host_info.Name is string'
19 - 'output.containers is not defined'
20 - 'output.networks is not defined'
21 - 'output.volumes is not defined'
22 - 'output.images is not defined'
23 - 'output.disk_usage is not defined'
24
25 - name: Show contents of ~/.ssh
26 ansible.builtin.command: ls -lah ~/.ssh
27 ignore_errors: true
28
29 - name: Recover home directory on remote
30 ansible.builtin.command: echo $HOME
31 register: remote_home
32
33 - name: Print remote home directory
34 ansible.builtin.debug:
35 var: remote_home.stdout
36
37 - name: Create SSH config
38 ansible.builtin.copy:
39 dest: "{{ remote_home.stdout }}/.ssh/config"
40 mode: '0600'
41 content: |
42 Host localhost
43 User root
44 IdentityFile ~/.ssh/id_rsa
45
46 - name: Get docker daemon information via ssh (paramiko) to localhost
47 community.docker.docker_host_info:
48 docker_host: "ssh://root@localhost"
49 register: output
50 ignore_errors: true
51
52 - name: Make sure we got information
53 ansible.builtin.assert:
54 that:
55 - 'output.host_info.Name is string'
56 - 'output.containers is not defined'
57 - 'output.networks is not defined'
58 - 'output.volumes is not defined'
59 - 'output.images is not defined'
60 - 'output.disk_usage is not defined'
61 when: output is succeeded or 'Failed to import the required Python library (paramiko)' not in output.msg
62 # Sometimes paramiko being installed isn't enough: importing it can fail
63 # due to 'ImportError: No module named x25519' when it executes
64 # `from cryptography.hazmat.primitives.asymmetric.x25519 import ...`.
65
66 - name: Get docker daemon information via ssh (OpenSSH) to localhost
67 community.docker.docker_host_info:
68 docker_host: "ssh://root@localhost"
69 use_ssh_client: true
70 register: output
71
72 - name: Make sure we got information
73 ansible.builtin.assert:
74 that:
75 - output is succeeded
76 - 'output.host_info.Name is string'
77 - 'output.containers is not defined'
78 - 'output.networks is not defined'
79 - 'output.volumes is not defined'
80 - 'output.images is not defined'
81 - 'output.disk_usage is not defined'