diff options
Diffstat (limited to '')
32 files changed, 218 insertions, 0 deletions
diff --git a/test/integration/targets/setup_paramiko/aliases b/test/integration/targets/setup_paramiko/aliases new file mode 100644 index 0000000..c49be25 --- /dev/null +++ b/test/integration/targets/setup_paramiko/aliases @@ -0,0 +1 @@ +needs/target/setup_remote_tmp_dir diff --git a/test/integration/targets/setup_paramiko/constraints.txt b/test/integration/targets/setup_paramiko/constraints.txt new file mode 100644 index 0000000..c502ba0 --- /dev/null +++ b/test/integration/targets/setup_paramiko/constraints.txt @@ -0,0 +1 @@ +cryptography >= 2.5, < 3.4 diff --git a/test/integration/targets/setup_paramiko/install-Alpine-3-python-3.yml b/test/integration/targets/setup_paramiko/install-Alpine-3-python-3.yml new file mode 100644 index 0000000..f16d9b5 --- /dev/null +++ b/test/integration/targets/setup_paramiko/install-Alpine-3-python-3.yml @@ -0,0 +1,9 @@ +- name: Setup remote constraints + include_tasks: setup-remote-constraints.yml +- name: Install Paramiko for Python 3 on Alpine + pip: # no apk package manager in core, just use pip + name: paramiko + extra_args: "-c {{ remote_constraints }}" + environment: + # Not sure why this fixes the test, but it does. + SETUPTOOLS_USE_DISTUTILS: stdlib diff --git a/test/integration/targets/setup_paramiko/install-CentOS-6-python-2.yml b/test/integration/targets/setup_paramiko/install-CentOS-6-python-2.yml new file mode 100644 index 0000000..0c7b9e8 --- /dev/null +++ b/test/integration/targets/setup_paramiko/install-CentOS-6-python-2.yml @@ -0,0 +1,3 @@ +- name: Install Paramiko for Python 2 on CentOS 6 + yum: + name: python-paramiko diff --git a/test/integration/targets/setup_paramiko/install-Darwin-python-3.yml b/test/integration/targets/setup_paramiko/install-Darwin-python-3.yml new file mode 100644 index 0000000..8926fe3 --- /dev/null +++ b/test/integration/targets/setup_paramiko/install-Darwin-python-3.yml @@ -0,0 +1,9 @@ +- name: Setup remote constraints + include_tasks: setup-remote-constraints.yml +- name: Install Paramiko for Python 3 on MacOS + pip: # no homebrew package manager in core, just use pip + name: paramiko + extra_args: "-c {{ remote_constraints }}" + environment: + # Not sure why this fixes the test, but it does. + SETUPTOOLS_USE_DISTUTILS: stdlib diff --git a/test/integration/targets/setup_paramiko/install-Fedora-35-python-3.yml b/test/integration/targets/setup_paramiko/install-Fedora-35-python-3.yml new file mode 100644 index 0000000..bbe97a9 --- /dev/null +++ b/test/integration/targets/setup_paramiko/install-Fedora-35-python-3.yml @@ -0,0 +1,9 @@ +- name: Install Paramiko and crypto policies scripts + dnf: + name: + - crypto-policies-scripts + - python3-paramiko + install_weak_deps: no + +- name: Drop the crypto-policy to LEGACY for these tests + command: update-crypto-policies --set LEGACY diff --git a/test/integration/targets/setup_paramiko/install-FreeBSD-python-3.yml b/test/integration/targets/setup_paramiko/install-FreeBSD-python-3.yml new file mode 100644 index 0000000..f737fe3 --- /dev/null +++ b/test/integration/targets/setup_paramiko/install-FreeBSD-python-3.yml @@ -0,0 +1,8 @@ +- name: Setup remote constraints + include_tasks: setup-remote-constraints.yml +- name: Install Paramiko for Python 3 on FreeBSD + pip: # no package in pkg, just use pip + name: paramiko + extra_args: "-c {{ remote_constraints }}" + environment: + SETUPTOOLS_USE_DISTUTILS: stdlib diff --git a/test/integration/targets/setup_paramiko/install-RedHat-8-python-3.yml b/test/integration/targets/setup_paramiko/install-RedHat-8-python-3.yml new file mode 100644 index 0000000..55677f2 --- /dev/null +++ b/test/integration/targets/setup_paramiko/install-RedHat-8-python-3.yml @@ -0,0 +1,8 @@ +- name: Setup remote constraints + include_tasks: setup-remote-constraints.yml +- name: Install Paramiko for Python 3 on RHEL 8 + pip: # no python3-paramiko package exists for RHEL 8 + name: paramiko + extra_args: "-c {{ remote_constraints }}" + environment: + SETUPTOOLS_USE_DISTUTILS: stdlib diff --git a/test/integration/targets/setup_paramiko/install-RedHat-9-python-3.yml b/test/integration/targets/setup_paramiko/install-RedHat-9-python-3.yml new file mode 100644 index 0000000..ca39155 --- /dev/null +++ b/test/integration/targets/setup_paramiko/install-RedHat-9-python-3.yml @@ -0,0 +1,9 @@ +- name: Setup remote constraints + include_tasks: setup-remote-constraints.yml +- name: Install Paramiko for Python 3 on RHEL 9 + pip: # no python3-paramiko package exists for RHEL 9 + name: paramiko + extra_args: "-c {{ remote_constraints }}" + +- name: Drop the crypto-policy to LEGACY for these tests + command: update-crypto-policies --set LEGACY diff --git a/test/integration/targets/setup_paramiko/install-Ubuntu-16-python-2.yml b/test/integration/targets/setup_paramiko/install-Ubuntu-16-python-2.yml new file mode 100644 index 0000000..8f76074 --- /dev/null +++ b/test/integration/targets/setup_paramiko/install-Ubuntu-16-python-2.yml @@ -0,0 +1,3 @@ +- name: Install Paramiko for Python 2 on Ubuntu 16 + apt: + name: python-paramiko diff --git a/test/integration/targets/setup_paramiko/install-fail.yml b/test/integration/targets/setup_paramiko/install-fail.yml new file mode 100644 index 0000000..b4ba464 --- /dev/null +++ b/test/integration/targets/setup_paramiko/install-fail.yml @@ -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." diff --git a/test/integration/targets/setup_paramiko/install-python-2.yml b/test/integration/targets/setup_paramiko/install-python-2.yml new file mode 100644 index 0000000..be337a1 --- /dev/null +++ b/test/integration/targets/setup_paramiko/install-python-2.yml @@ -0,0 +1,3 @@ +- name: Install Paramiko for Python 2 + package: + name: python2-paramiko diff --git a/test/integration/targets/setup_paramiko/install-python-3.yml b/test/integration/targets/setup_paramiko/install-python-3.yml new file mode 100644 index 0000000..ac2a1a2 --- /dev/null +++ b/test/integration/targets/setup_paramiko/install-python-3.yml @@ -0,0 +1,3 @@ +- name: Install Paramiko for Python 3 + package: + name: python3-paramiko diff --git a/test/integration/targets/setup_paramiko/install.yml b/test/integration/targets/setup_paramiko/install.yml new file mode 100644 index 0000000..1868987 --- /dev/null +++ b/test/integration/targets/setup_paramiko/install.yml @@ -0,0 +1,19 @@ +- 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_version }}-python-{{ ansible_python.version.major }}.yml" + - "install-{{ ansible_distribution }}-{{ ansible_distribution_major_version }}-python-{{ ansible_python.version.major }}.yml" + - "install-{{ ansible_os_family }}-{{ ansible_distribution_major_version }}-python-{{ ansible_python.version.major }}.yml" + - "install-{{ ansible_os_family }}-python-{{ ansible_python.version.major }}.yml" + - "install-python-{{ ansible_python.version.major }}.yml" + - "install-fail.yml" diff --git a/test/integration/targets/setup_paramiko/inventory b/test/integration/targets/setup_paramiko/inventory new file mode 100644 index 0000000..8618c72 --- /dev/null +++ b/test/integration/targets/setup_paramiko/inventory @@ -0,0 +1 @@ +localhost ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" diff --git a/test/integration/targets/setup_paramiko/library/detect_paramiko.py b/test/integration/targets/setup_paramiko/library/detect_paramiko.py new file mode 100644 index 0000000..e3a8158 --- /dev/null +++ b/test/integration/targets/setup_paramiko/library/detect_paramiko.py @@ -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() diff --git a/test/integration/targets/setup_paramiko/setup-remote-constraints.yml b/test/integration/targets/setup_paramiko/setup-remote-constraints.yml new file mode 100644 index 0000000..a86d477 --- /dev/null +++ b/test/integration/targets/setup_paramiko/setup-remote-constraints.yml @@ -0,0 +1,12 @@ +- name: Setup remote temporary directory + include_role: + name: setup_remote_tmp_dir + +- name: Record constraints.txt path on remote host + set_fact: + remote_constraints: "{{ remote_tmp_dir }}/constraints.txt" + +- name: Copy constraints.txt to remote host + copy: + src: "constraints.txt" + dest: "{{ remote_constraints }}" diff --git a/test/integration/targets/setup_paramiko/setup.sh b/test/integration/targets/setup_paramiko/setup.sh new file mode 100644 index 0000000..9f7afcb --- /dev/null +++ b/test/integration/targets/setup_paramiko/setup.sh @@ -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_ROLES_PATH=../ ansible-playbook ../setup_paramiko/install.yml -i ../setup_paramiko/inventory "$@" +trap 'ansible-playbook ../setup_paramiko/uninstall.yml -i ../setup_paramiko/inventory "$@"' EXIT diff --git a/test/integration/targets/setup_paramiko/uninstall-Alpine-3-python-3.yml b/test/integration/targets/setup_paramiko/uninstall-Alpine-3-python-3.yml new file mode 100644 index 0000000..e9dcc62 --- /dev/null +++ b/test/integration/targets/setup_paramiko/uninstall-Alpine-3-python-3.yml @@ -0,0 +1,4 @@ +- name: Uninstall Paramiko for Python 3 on Alpine + pip: + name: paramiko + state: absent diff --git a/test/integration/targets/setup_paramiko/uninstall-Darwin-python-3.yml b/test/integration/targets/setup_paramiko/uninstall-Darwin-python-3.yml new file mode 100644 index 0000000..69a68e4 --- /dev/null +++ b/test/integration/targets/setup_paramiko/uninstall-Darwin-python-3.yml @@ -0,0 +1,4 @@ +- name: Uninstall Paramiko for Python 3 on MacOS + pip: + name: paramiko + state: absent diff --git a/test/integration/targets/setup_paramiko/uninstall-Fedora-35-python-3.yml b/test/integration/targets/setup_paramiko/uninstall-Fedora-35-python-3.yml new file mode 100644 index 0000000..6d0e9a1 --- /dev/null +++ b/test/integration/targets/setup_paramiko/uninstall-Fedora-35-python-3.yml @@ -0,0 +1,5 @@ +- name: Revert the crypto-policy back to DEFAULT + command: update-crypto-policies --set DEFAULT + +- name: Uninstall Paramiko and crypto policies scripts using dnf history undo + command: dnf history undo last --assumeyes diff --git a/test/integration/targets/setup_paramiko/uninstall-FreeBSD-python-3.yml b/test/integration/targets/setup_paramiko/uninstall-FreeBSD-python-3.yml new file mode 100644 index 0000000..d3d3739 --- /dev/null +++ b/test/integration/targets/setup_paramiko/uninstall-FreeBSD-python-3.yml @@ -0,0 +1,4 @@ +- name: Uninstall Paramiko for Python 3 on FreeBSD + pip: + name: paramiko + state: absent diff --git a/test/integration/targets/setup_paramiko/uninstall-RedHat-8-python-3.yml b/test/integration/targets/setup_paramiko/uninstall-RedHat-8-python-3.yml new file mode 100644 index 0000000..d3a9493 --- /dev/null +++ b/test/integration/targets/setup_paramiko/uninstall-RedHat-8-python-3.yml @@ -0,0 +1,4 @@ +- name: Uninstall Paramiko for Python 3 on RHEL 8 + pip: # no python3-paramiko package exists for RHEL 8 + name: paramiko + state: absent diff --git a/test/integration/targets/setup_paramiko/uninstall-RedHat-9-python-3.yml b/test/integration/targets/setup_paramiko/uninstall-RedHat-9-python-3.yml new file mode 100644 index 0000000..f46ec55 --- /dev/null +++ b/test/integration/targets/setup_paramiko/uninstall-RedHat-9-python-3.yml @@ -0,0 +1,7 @@ +- name: Uninstall Paramiko for Python 3 on RHEL 9 + pip: # no python3-paramiko package exists for RHEL 9 + name: paramiko + state: absent + +- name: Revert the crypto-policy back to DEFAULT + command: update-crypto-policies --set DEFAULT diff --git a/test/integration/targets/setup_paramiko/uninstall-apt-python-2.yml b/test/integration/targets/setup_paramiko/uninstall-apt-python-2.yml new file mode 100644 index 0000000..507d94c --- /dev/null +++ b/test/integration/targets/setup_paramiko/uninstall-apt-python-2.yml @@ -0,0 +1,5 @@ +- name: Uninstall Paramiko for Python 2 using apt + apt: + name: python-paramiko + state: absent + autoremove: yes diff --git a/test/integration/targets/setup_paramiko/uninstall-apt-python-3.yml b/test/integration/targets/setup_paramiko/uninstall-apt-python-3.yml new file mode 100644 index 0000000..d51fc92 --- /dev/null +++ b/test/integration/targets/setup_paramiko/uninstall-apt-python-3.yml @@ -0,0 +1,5 @@ +- name: Uninstall Paramiko for Python 3 using apt + apt: + name: python3-paramiko + state: absent + autoremove: yes diff --git a/test/integration/targets/setup_paramiko/uninstall-dnf.yml b/test/integration/targets/setup_paramiko/uninstall-dnf.yml new file mode 100644 index 0000000..a56c0dd --- /dev/null +++ b/test/integration/targets/setup_paramiko/uninstall-dnf.yml @@ -0,0 +1,2 @@ +- name: Uninstall Paramiko using dnf history undo + command: dnf history undo last --assumeyes diff --git a/test/integration/targets/setup_paramiko/uninstall-fail.yml b/test/integration/targets/setup_paramiko/uninstall-fail.yml new file mode 100644 index 0000000..bc5e12f --- /dev/null +++ b/test/integration/targets/setup_paramiko/uninstall-fail.yml @@ -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." diff --git a/test/integration/targets/setup_paramiko/uninstall-yum.yml b/test/integration/targets/setup_paramiko/uninstall-yum.yml new file mode 100644 index 0000000..de1c21f --- /dev/null +++ b/test/integration/targets/setup_paramiko/uninstall-yum.yml @@ -0,0 +1,2 @@ +- name: Uninstall Paramiko using yum history undo + command: yum history undo last --assumeyes diff --git a/test/integration/targets/setup_paramiko/uninstall-zypper-python-2.yml b/test/integration/targets/setup_paramiko/uninstall-zypper-python-2.yml new file mode 100644 index 0000000..adb26e5 --- /dev/null +++ b/test/integration/targets/setup_paramiko/uninstall-zypper-python-2.yml @@ -0,0 +1,2 @@ +- name: Uninstall Paramiko for Python 2 using zypper + command: zypper --quiet --non-interactive remove --clean-deps python2-paramiko diff --git a/test/integration/targets/setup_paramiko/uninstall-zypper-python-3.yml b/test/integration/targets/setup_paramiko/uninstall-zypper-python-3.yml new file mode 100644 index 0000000..339be6f --- /dev/null +++ b/test/integration/targets/setup_paramiko/uninstall-zypper-python-3.yml @@ -0,0 +1,2 @@ +- name: Uninstall Paramiko for Python 3 using zypper + command: zypper --quiet --non-interactive remove --clean-deps python3-paramiko diff --git a/test/integration/targets/setup_paramiko/uninstall.yml b/test/integration/targets/setup_paramiko/uninstall.yml new file mode 100644 index 0000000..e517a2b --- /dev/null +++ b/test/integration/targets/setup_paramiko/uninstall.yml @@ -0,0 +1,21 @@ +- 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_version }}-python-{{ ansible_python.version.major }}.yml" + - "uninstall-{{ ansible_distribution }}-{{ ansible_distribution_major_version }}-python-{{ ansible_python.version.major }}.yml" + - "uninstall-{{ ansible_os_family }}-{{ ansible_distribution_major_version }}-python-{{ ansible_python.version.major }}.yml" + - "uninstall-{{ ansible_os_family }}-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 |