Only use Paramiko in tests when needed. (#54826)
This commit is contained in:
parent
c309570540
commit
ab7f810874
33 changed files with 182 additions and 12 deletions
|
@ -1,2 +1,4 @@
|
|||
needs/ssh
|
||||
shippable/posix/group3
|
||||
needs/target/setup_paramiko
|
||||
destructive # potentially installs/uninstalls OS packages via setup_paramiko
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../connection_posix/test.sh
|
7
test/integration/targets/connection_paramiko_ssh/runme.sh
Executable file
7
test/integration/targets/connection_paramiko_ssh/runme.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
source ../setup_paramiko/setup.sh
|
||||
|
||||
./test.sh
|
1
test/integration/targets/connection_paramiko_ssh/test.sh
Symbolic link
1
test/integration/targets/connection_paramiko_ssh/test.sh
Symbolic link
|
@ -0,0 +1 @@
|
|||
../connection_posix/test.sh
|
|
@ -0,0 +1,3 @@
|
|||
- name: Install Paramiko for Python 2 on CentOS 6
|
||||
yum:
|
||||
name: python-paramiko
|
|
@ -0,0 +1,3 @@
|
|||
- name: Install Paramiko for Python 2 on FreeBSD 11
|
||||
pkgng:
|
||||
name: py27-paramiko
|
|
@ -0,0 +1,9 @@
|
|||
- name: Downgrade to pip version 18.1 to work around a PEP 517 virtualenv bug
|
||||
# pip 19.0.0 added support for PEP 517
|
||||
# versions as recent as 19.0.3 fail to install paramiko in a virtualenv due to a BackendUnavailable exception
|
||||
# installation without a virtualenv succeeds
|
||||
pip:
|
||||
name: pip==18.1
|
||||
- name: Install Paramiko for Python 3 on FreeBSD 11
|
||||
pip: # no py36-paramiko package exists for FreeBSD 11
|
||||
name: paramiko
|
|
@ -0,0 +1,3 @@
|
|||
- name: Install Paramiko for Python 2 on FreeBSD 12
|
||||
pkgng:
|
||||
name: py27-paramiko
|
|
@ -0,0 +1,3 @@
|
|||
- name: Install Paramiko for Python 3 on FreeBSD 12
|
||||
pkgng:
|
||||
name: py36-paramiko
|
|
@ -0,0 +1,4 @@
|
|||
- name: Install Paramiko for Python 3 on RHEL 8
|
||||
yum:
|
||||
# src https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/setup_paramiko/python-paramiko-2.4.2-4.el8.src.rpm
|
||||
name: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/setup_paramiko/python3-ansible_paramiko-2.4.2-4.el8.noarch.rpm
|
|
@ -0,0 +1,3 @@
|
|||
- name: Install Paramiko for Python 2 on Ubuntu 16
|
||||
apt:
|
||||
name: python-paramiko
|
7
test/integration/targets/setup_paramiko/install-fail.yml
Normal file
7
test/integration/targets/setup_paramiko/install-fail.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
- name: Install Paramiko
|
||||
fail:
|
||||
msg: "Install of Paramiko on distribution '{{ ansible_distribution }}' with major version '{{ ansible_distribution_major_version }}'
|
||||
with package manager '{{ ansible_pkg_mgr }}' on Python {{ ansible_python.version.major }} has not been implemented.
|
||||
Use native OS packages if available, otherwise use pip.
|
||||
Be sure to uninstall automatically installed dependencies when possible.
|
||||
Do not implement a generic fallback to pip, as that would allow distributions not yet configured to go undetected."
|
|
@ -0,0 +1,3 @@
|
|||
- name: Install Paramiko for Python 2
|
||||
package:
|
||||
name: python2-paramiko
|
|
@ -0,0 +1,3 @@
|
|||
- name: Install Paramiko for Python 3
|
||||
package:
|
||||
name: python3-paramiko
|
16
test/integration/targets/setup_paramiko/install.yml
Normal file
16
test/integration/targets/setup_paramiko/install.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Detect Paramiko
|
||||
detect_paramiko:
|
||||
register: detect_paramiko
|
||||
- name: Persist Result
|
||||
copy:
|
||||
content: "{{ detect_paramiko }}"
|
||||
dest: "{{ lookup('env', 'OUTPUT_DIR') }}/detect-paramiko.json"
|
||||
- name: Install Paramiko
|
||||
when: not detect_paramiko.found
|
||||
include_tasks: "{{ item }}"
|
||||
with_first_found:
|
||||
- "install-{{ ansible_distribution }}-{{ ansible_distribution_major_version }}-python-{{ ansible_python.version.major }}.yml"
|
||||
- "install-python-{{ ansible_python.version.major }}.yml"
|
||||
- "install-fail.yml"
|
1
test/integration/targets/setup_paramiko/inventory
Normal file
1
test/integration/targets/setup_paramiko/inventory
Normal file
|
@ -0,0 +1 @@
|
|||
localhost ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}"
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/python
|
||||
"""Ansible module to detect the presence of both the normal and Ansible-specific versions of Paramiko."""
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
try:
|
||||
import paramiko
|
||||
except ImportError:
|
||||
paramiko = None
|
||||
|
||||
try:
|
||||
import ansible_paramiko
|
||||
except ImportError:
|
||||
ansible_paramiko = None
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(argument_spec={})
|
||||
module.exit_json(**dict(
|
||||
found=bool(paramiko or ansible_paramiko),
|
||||
paramiko=bool(paramiko),
|
||||
ansible_paramiko=bool(ansible_paramiko),
|
||||
))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
8
test/integration/targets/setup_paramiko/setup.sh
Normal file
8
test/integration/targets/setup_paramiko/setup.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
# Usage: source ../setup_paramiko/setup.sh
|
||||
|
||||
set -eux
|
||||
|
||||
source virtualenv.sh # for pip installs, if needed, otherwise unused
|
||||
ansible-playbook ../setup_paramiko/install.yml -i ../setup_paramiko/inventory "$@"
|
||||
trap 'ansible-playbook ../setup_paramiko/uninstall.yml -i ../setup_paramiko/inventory "$@"' EXIT
|
|
@ -0,0 +1,4 @@
|
|||
- name: Uninstall Paramiko for Python 2 on FreeBSD 11
|
||||
pkgng:
|
||||
name: py27-paramiko
|
||||
state: absent
|
|
@ -0,0 +1,4 @@
|
|||
- name: Uninstall Paramiko for Python 3 on FreeBSD 11
|
||||
pip: # no py36-paramiko package exists for FreeBSD 11
|
||||
name: paramiko
|
||||
state: absent
|
|
@ -0,0 +1,4 @@
|
|||
- name: Uninstall Paramiko for Python 2 on FreeBSD 12
|
||||
pkgng:
|
||||
name: py27-paramiko
|
||||
state: absent
|
|
@ -0,0 +1,4 @@
|
|||
- name: Uninstall Paramiko for Python 3 on FreeBSD 12
|
||||
pkgng:
|
||||
name: py36-paramiko
|
||||
state: absent
|
|
@ -0,0 +1,5 @@
|
|||
- name: Uninstall Paramiko for Python 2 using apt
|
||||
apt:
|
||||
name: python-paramiko
|
||||
state: absent
|
||||
autoremove: yes
|
|
@ -0,0 +1,5 @@
|
|||
- name: Uninstall Paramiko for Python 3 using apt
|
||||
apt:
|
||||
name: python3-paramiko
|
||||
state: absent
|
||||
autoremove: yes
|
|
@ -0,0 +1,4 @@
|
|||
- name: Uninstall Paramiko using dnf history undo
|
||||
command: dnf history undo last --assumeyes
|
||||
args:
|
||||
warn: no
|
|
@ -0,0 +1,7 @@
|
|||
- name: Uninstall Paramiko
|
||||
fail:
|
||||
msg: "Uninstall of Paramiko on distribution '{{ ansible_distribution }}' with major version '{{ ansible_distribution_major_version }}'
|
||||
with package manager '{{ ansible_pkg_mgr }}' on Python {{ ansible_python.version.major }} has not been implemented.
|
||||
Use native OS packages if available, otherwise use pip.
|
||||
Be sure to uninstall automatically installed dependencies when possible.
|
||||
Do not implement a generic fallback to pip, as that would allow distributions not yet configured to go undetected."
|
|
@ -0,0 +1,4 @@
|
|||
- name: Uninstall Paramiko using yum history undo
|
||||
command: yum history undo last --assumeyes
|
||||
args:
|
||||
warn: no
|
|
@ -0,0 +1,4 @@
|
|||
- name: Uninstall Paramiko for Python 2 using zypper
|
||||
command: zypper --quiet --non-interactive remove --clean-deps python2-paramiko
|
||||
args:
|
||||
warn: no
|
|
@ -0,0 +1,4 @@
|
|||
- name: Uninstall Paramiko for Python 3 using zypper
|
||||
command: zypper --quiet --non-interactive remove --clean-deps python3-paramiko
|
||||
args:
|
||||
warn: no
|
18
test/integration/targets/setup_paramiko/uninstall.yml
Normal file
18
test/integration/targets/setup_paramiko/uninstall.yml
Normal file
|
@ -0,0 +1,18 @@
|
|||
- hosts: localhost
|
||||
vars:
|
||||
detect_paramiko: '{{ lookup("file", lookup("env", "OUTPUT_DIR") + "/detect-paramiko.json") | from_json }}'
|
||||
tasks:
|
||||
- name: Uninstall Paramiko and Verify Results
|
||||
when: not detect_paramiko.found
|
||||
block:
|
||||
- name: Uninstall Paramiko
|
||||
include_tasks: "{{ item }}"
|
||||
with_first_found:
|
||||
- "uninstall-{{ ansible_distribution }}-{{ ansible_distribution_major_version }}-python-{{ ansible_python.version.major }}.yml"
|
||||
- "uninstall-{{ ansible_pkg_mgr }}-python-{{ ansible_python.version.major }}.yml"
|
||||
- "uninstall-{{ ansible_pkg_mgr }}.yml"
|
||||
- "uninstall-fail.yml"
|
||||
- name: Verify Paramiko was uninstalled
|
||||
detect_paramiko:
|
||||
register: detect_paramiko
|
||||
failed_when: detect_paramiko.found
|
|
@ -1,9 +1,9 @@
|
|||
default name=quay.io/ansible/default-test-container:1.6.0 python=3.6,2.6,2.7,3.5,3.7,3.8 python3.8=/usr/local/bin/python3.8 seccomp=unconfined
|
||||
centos6 name=quay.io/ansible/centos6-test-container:1.4.0 python=2.6 seccomp=unconfined
|
||||
centos7 name=quay.io/ansible/centos7-test-container:1.4.0 python=2.7 seccomp=unconfined
|
||||
fedora28 name=quay.io/ansible/fedora28-test-container:1.5.0 python=2.7
|
||||
fedora29 name=quay.io/ansible/fedora29-test-container:1.5.0 python=3.7
|
||||
opensuse15py2 name=quay.io/ansible/opensuse15py2-test-container:1.7.0 python=2.7
|
||||
opensuse15 name=quay.io/ansible/opensuse15-test-container:1.7.0 python=3.6
|
||||
ubuntu1604 name=quay.io/ansible/ubuntu1604-test-container:1.4.0 python=2.7 seccomp=unconfined
|
||||
ubuntu1804 name=quay.io/ansible/ubuntu1804-test-container:1.6.0 python=3.6 seccomp=unconfined
|
||||
centos6 name=quay.io/ansible/centos6-test-container:1.8.0 python=2.6 seccomp=unconfined
|
||||
centos7 name=quay.io/ansible/centos7-test-container:1.8.0 python=2.7 seccomp=unconfined
|
||||
fedora28 name=quay.io/ansible/fedora28-test-container:1.8.0 python=2.7
|
||||
fedora29 name=quay.io/ansible/fedora29-test-container:1.8.0 python=3.7
|
||||
opensuse15py2 name=quay.io/ansible/opensuse15py2-test-container:1.8.0 python=2.7
|
||||
opensuse15 name=quay.io/ansible/opensuse15-test-container:1.8.0 python=3.6
|
||||
ubuntu1604 name=quay.io/ansible/ubuntu1604-test-container:1.8.0 python=2.7 seccomp=unconfined
|
||||
ubuntu1804 name=quay.io/ansible/ubuntu1804-test-container:1.8.0 python=3.6 seccomp=unconfined
|
||||
|
|
|
@ -2,5 +2,4 @@ cryptography
|
|||
jinja2
|
||||
junit-xml
|
||||
ordereddict ; python_version < '2.7'
|
||||
paramiko
|
||||
pyyaml
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
cryptography
|
||||
jinja2
|
||||
mock
|
||||
paramiko
|
||||
pycodestyle
|
||||
pylint ; python_version >= '3.5' # pylint 2.0.0 and later require python 3+
|
||||
pytest
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
cryptography
|
||||
jinja2
|
||||
junit-xml
|
||||
paramiko
|
||||
ntlm-auth
|
||||
requests-ntlm
|
||||
requests-credssp
|
||||
|
|
Loading…
Reference in a new issue