community.docker/tests/integration/targets/generic_ssh_connection/tasks/main.yml
patchback[bot] 41b1337d8e
[PR #563/c0d9ca67 backport][stable-2] Fix CI (#565)
* Restrict to old enough paramiko on RHEL 8 or other systems using Python 3.6. (#563)

(cherry picked from commit c0d9ca67c4)

* Make sure paramiko is installed on localhost as well.

* Revert "Make sure paramiko is installed on localhost as well."

This reverts commit f36406c2db.

* Fix check.

* ...

Co-authored-by: Felix Fontein <felix@fontein.de>
2023-01-22 19:06:56 +01:00

90 lines
2.9 KiB
YAML

---
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- name: Get docker daemon information directly
docker_host_info:
register: output
- name: Make sure we got information
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks is not defined'
- 'output.volumes is not defined'
- 'output.images is not defined'
- 'output.disk_usage is not defined'
- name: Show contents of ~/.ssh
command: ls -lah ~/.ssh
ignore_errors: true
- name: Recover home directory on remote
command: echo $HOME
register: remote_home
- name: Print remote home directory
debug:
var: remote_home.stdout
- name: Create SSH config
copy:
dest: "{{ remote_home.stdout }}/.ssh/config"
mode: '0600'
content: |
Host localhost
User root
IdentityFile ~/.ssh/id_rsa
- name: Get docker daemon information via ssh (paramiko) to localhost
docker_host_info:
docker_host: "ssh://root@localhost"
register: output
ignore_errors: true
- name: Make sure we got information
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks is not defined'
- 'output.volumes is not defined'
- 'output.images is not defined'
- 'output.disk_usage is not defined'
when: output is succeeded or 'Install paramiko package to enable' not in output.msg
# For whatever reason, even though paramiko is installed, *sometimes* this error
# shows up. I have no idea why it sometimes works and sometimes not...
- name: Get docker daemon information via ssh (OpenSSH) to localhost
docker_host_info:
docker_host: "ssh://root@localhost"
use_ssh_client: true
register: output
ignore_errors: true
- name: Make sure we got information
assert:
that:
- output is succeeded
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks is not defined'
- 'output.volumes is not defined'
- 'output.images is not defined'
- 'output.disk_usage is not defined'
when: docker_py_version is version('4.4.0', '>=') and (output is succeeded or 'Install paramiko package to enable' not in output.msg)
# For whatever reason, even though paramiko is installed, *sometimes* this error
# shows up. I have no idea why it sometimes works and sometimes not...
# (Also note that due to the way Docker SDK for Python has been written, SSH by
# shell only works if paramiko is around...)
- name: Make sure we got information
assert:
that:
- output is failed
- "'use_ssh_client=True requires Docker SDK for Python 4.4.0 or newer' in output.msg"
when: docker_py_version is version('4.4.0', '<')