diff --git a/tests_new/integration/destructive.yml b/tests_new/integration/destructive.yml index a6ba60c13e..f35152ca05 100644 --- a/tests_new/integration/destructive.yml +++ b/tests_new/integration/destructive.yml @@ -1,4 +1,5 @@ - hosts: testhost gather_facts: True - roles: [] + roles: + - { role: test_pip, tags: test_pip } diff --git a/tests_new/integration/roles/test_pip/meta/main.yml b/tests_new/integration/roles/test_pip/meta/main.yml new file mode 100644 index 0000000000..1050c23ce3 --- /dev/null +++ b/tests_new/integration/roles/test_pip/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + diff --git a/tests_new/integration/roles/test_pip/tasks/main.yml b/tests_new/integration/roles/test_pip/tasks/main.yml new file mode 100644 index 0000000000..117031739c --- /dev/null +++ b/tests_new/integration/roles/test_pip/tasks/main.yml @@ -0,0 +1,84 @@ +# test code for the pip module +# (c) 2014, Michael DeHaan + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +# FIXME: replace the python test package + +# first some tests installed system-wide +# verify things were not installed to start with + +- name: ensure a package is not installed (precondition setup) + pip: name={{ pip_test_package }} state=absent + +# verify that a package that is uninstalled being set to absent +# results in an unchanged state and that the test package is not +# installed + +- name: ensure a package is not installed + pip: name={{ pip_test_package }} state=absent + register: uninstall_result + +- debug: var=installed_result +- name: removing an unremoved package should return unchanged + assert: + that: + - "not uninstall_result.changed" + +- shell: "python -c 'import {{ pip_test_package }}'" + register: absent_result + ignore_errors: True + +- name: verify {{ pip_test_package }} is not present + assert: + that: + - "absent_result.rc != 0" + +# now we're going to install the test package knowing it is uninstalled +# and check that installation was ok + +- name: ensure a package is installed + pip: name={{ pip_test_package }} state=present + register: install_result + +- name: verify we recorded a change + assert: + that: + - "install_result.changed == True" + +- shell: "python -c 'import {{ pip_test_package }}'" + register: installed_result + +# now remove it to test uninstallation of a package we are sure is installed + +- name: now uninstall so we can see that a change occured + pip: name={{ pip_test_package }} state=absent + register: absent2 + +- name: assert a change occured on uninstallation + assert: + that: + - "absent2.changed" + +# put the test package back + +- name: now put it back in case someone wanted it (like us!) + pip: name={{ pip_test_package }} state=present + + + + +