mirror of https://github.com/ansible/ansible.git
parent
c7334ea92c
commit
f024cf35d7
@ -0,0 +1,2 @@
|
||||
removed_features:
|
||||
- "With the removal of Python 2 support, the yum module and yum action plugin are removed and redirected to ``dnf``."
|
File diff suppressed because it is too large
Load Diff
@ -1,110 +0,0 @@
|
||||
# (c) 2018, Ansible Project
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
from __future__ import annotations
|
||||
|
||||
from ansible.errors import AnsibleActionFail
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.utils.display import Display
|
||||
|
||||
display = Display()
|
||||
|
||||
VALID_BACKENDS = frozenset(('yum', 'yum4', 'dnf', 'dnf4', 'dnf5'))
|
||||
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
|
||||
TRANSFERS_FILES = False
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
'''
|
||||
Action plugin handler for yum3 vs yum4(dnf) operations.
|
||||
|
||||
Enables the yum module to use yum3 and/or yum4. Yum4 is a yum
|
||||
command-line compatibility layer on top of dnf. Since the Ansible
|
||||
modules for yum(aka yum3) and dnf(aka yum4) call each of yum3 and yum4's
|
||||
python APIs natively on the backend, we need to handle this here and
|
||||
pass off to the correct Ansible module to execute on the remote system.
|
||||
'''
|
||||
|
||||
self._supports_check_mode = True
|
||||
self._supports_async = True
|
||||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
# Carry-over concept from the package action plugin
|
||||
if 'use' in self._task.args and 'use_backend' in self._task.args:
|
||||
raise AnsibleActionFail("parameters are mutually exclusive: ('use', 'use_backend')")
|
||||
|
||||
module = self._task.args.get('use', self._task.args.get('use_backend', 'auto'))
|
||||
|
||||
if module == 'dnf':
|
||||
module = 'auto'
|
||||
|
||||
if module == 'auto':
|
||||
try:
|
||||
if self._task.delegate_to: # if we delegate, we should use delegated host's facts
|
||||
module = self._templar.template("{{hostvars['%s']['ansible_facts']['pkg_mgr']}}" % self._task.delegate_to)
|
||||
else:
|
||||
module = self._templar.template("{{ansible_facts.pkg_mgr}}")
|
||||
except Exception:
|
||||
pass # could not get it from template!
|
||||
|
||||
if module not in VALID_BACKENDS:
|
||||
facts = self._execute_module(
|
||||
module_name="ansible.legacy.setup", module_args=dict(filter="ansible_pkg_mgr", gather_subset="!all"),
|
||||
task_vars=task_vars)
|
||||
display.debug("Facts %s" % facts)
|
||||
module = facts.get("ansible_facts", {}).get("ansible_pkg_mgr", "auto")
|
||||
if (not self._task.delegate_to or self._task.delegate_facts) and module != 'auto':
|
||||
result['ansible_facts'] = {'pkg_mgr': module}
|
||||
|
||||
if module not in VALID_BACKENDS:
|
||||
result.update(
|
||||
{
|
||||
'failed': True,
|
||||
'msg': ("Could not detect which major revision of yum is in use, which is required to determine module backend.",
|
||||
"You should manually specify use_backend to tell the module whether to use the yum (yum3) or dnf (yum4) backend})"),
|
||||
}
|
||||
)
|
||||
|
||||
else:
|
||||
if module in {"yum4", "dnf4"}:
|
||||
module = "dnf"
|
||||
|
||||
# eliminate collisions with collections search while still allowing local override
|
||||
module = 'ansible.legacy.' + module
|
||||
|
||||
if not self._shared_loader_obj.module_loader.has_plugin(module):
|
||||
result.update({'failed': True, 'msg': "Could not find a yum module backend for %s." % module})
|
||||
else:
|
||||
new_module_args = self._task.args.copy()
|
||||
if 'use_backend' in new_module_args:
|
||||
del new_module_args['use_backend']
|
||||
if 'use' in new_module_args:
|
||||
del new_module_args['use']
|
||||
|
||||
display.vvvv("Running %s as the backend for the yum action plugin" % module)
|
||||
result.update(self._execute_module(
|
||||
module_name=module, module_args=new_module_args, task_vars=task_vars, wrap_async=self._task.async_val))
|
||||
|
||||
# Cleanup
|
||||
if not self._task.async_val:
|
||||
# remove a temporary path we created
|
||||
self._remove_tmp_path(self._connection._shell.tmpdir)
|
||||
|
||||
return result
|
@ -1,10 +0,0 @@
|
||||
- name: Enable RHEL7 extras
|
||||
# EPEL 7 depends on RHEL 7 extras, which is not enabled by default on RHEL.
|
||||
# See: https://docs.fedoraproject.org/en-US/epel/epel-policy/#_policy
|
||||
command: yum-config-manager --enable rhel-7-server-rhui-extras-rpms
|
||||
when: ansible_facts.distribution == 'RedHat' and ansible_facts.distribution_major_version == '7'
|
||||
- name: Install EPEL
|
||||
yum:
|
||||
name: https://ci-files.testing.ansible.com/test/integration/targets/setup_epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm
|
||||
disable_gpg_check: true
|
||||
when: ansible_facts.distribution in ['RedHat', 'CentOS']
|
@ -1 +0,0 @@
|
||||
needs/target/setup_epel
|
@ -1,4 +0,0 @@
|
||||
destructive
|
||||
shippable/posix/group1
|
||||
skip/freebsd
|
||||
skip/macos
|
@ -1,5 +0,0 @@
|
||||
[main]
|
||||
gpgcheck=1
|
||||
installonly_limit=3
|
||||
clean_requirements_on_remove=True
|
||||
tsflags=nodocs
|
@ -1,22 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def filter_list_of_tuples_by_first_param(lst, search, startswith=False):
|
||||
out = []
|
||||
for element in lst:
|
||||
if startswith:
|
||||
if element[0].startswith(search):
|
||||
out.append(element)
|
||||
else:
|
||||
if search in element[0]:
|
||||
out.append(element)
|
||||
return out
|
||||
|
||||
|
||||
class FilterModule(object):
|
||||
''' filter '''
|
||||
|
||||
def filters(self):
|
||||
return {
|
||||
'filter_list_of_tuples_by_first_param': filter_list_of_tuples_by_first_param,
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
dependencies:
|
||||
- prepare_tests
|
||||
- setup_rpm_repo
|
||||
- setup_remote_tmp_dir
|
@ -1,16 +0,0 @@
|
||||
---
|
||||
- name: Test cacheonly (clean before testing)
|
||||
command: yum clean all
|
||||
|
||||
- name: Try installing from cache where it has been cleaned
|
||||
yum:
|
||||
name: sos
|
||||
state: latest
|
||||
cacheonly: true
|
||||
register: yum_result
|
||||
ignore_errors: true
|
||||
|
||||
- name: Verify yum failure
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is failed"
|
@ -1,61 +0,0 @@
|
||||
- name: install htop in check mode to verify changes dict returned
|
||||
yum:
|
||||
name: htop
|
||||
state: present
|
||||
check_mode: yes
|
||||
register: yum_changes_check_mode_result
|
||||
|
||||
- name: install verify changes dict returned in check mode
|
||||
assert:
|
||||
that:
|
||||
- "yum_changes_check_mode_result is success"
|
||||
- "yum_changes_check_mode_result is changed"
|
||||
- "'changes' in yum_changes_check_mode_result"
|
||||
- "'installed' in yum_changes_check_mode_result['changes']"
|
||||
- "'htop' in yum_changes_check_mode_result['changes']['installed']"
|
||||
|
||||
- name: install htop to verify changes dict returned
|
||||
yum:
|
||||
name: htop
|
||||
state: present
|
||||
register: yum_changes_result
|
||||
|
||||
- name: install verify changes dict returned
|
||||
assert:
|
||||
that:
|
||||
- "yum_changes_result is success"
|
||||
- "yum_changes_result is changed"
|
||||
- "'changes' in yum_changes_result"
|
||||
- "'installed' in yum_changes_result['changes']"
|
||||
- "'htop' in yum_changes_result['changes']['installed']"
|
||||
|
||||
- name: remove htop in check mode to verify changes dict returned
|
||||
yum:
|
||||
name: htop
|
||||
state: absent
|
||||
check_mode: yes
|
||||
register: yum_changes_check_mode_result
|
||||
|
||||
- name: remove verify changes dict returned in check mode
|
||||
assert:
|
||||
that:
|
||||
- "yum_changes_check_mode_result is success"
|
||||
- "yum_changes_check_mode_result is changed"
|
||||
- "'changes' in yum_changes_check_mode_result"
|
||||
- "'removed' in yum_changes_check_mode_result['changes']"
|
||||
- "'htop' in yum_changes_check_mode_result['changes']['removed']"
|
||||
|
||||
- name: remove htop to verify changes dict returned
|
||||
yum:
|
||||
name: htop
|
||||
state: absent
|
||||
register: yum_changes_result
|
||||
|
||||
- name: remove verify changes dict returned
|
||||
assert:
|
||||
that:
|
||||
- "yum_changes_result is success"
|
||||
- "yum_changes_result is changed"
|
||||
- "'changes' in yum_changes_result"
|
||||
- "'removed' in yum_changes_result['changes']"
|
||||
- "'htop' in yum_changes_result['changes']['removed']"
|
@ -1,28 +0,0 @@
|
||||
- block:
|
||||
- name: Make sure testing package is not installed
|
||||
yum:
|
||||
name: sos
|
||||
state: absent
|
||||
|
||||
- name: Create bogus lock file
|
||||
copy:
|
||||
content: bogus content for this lock file
|
||||
dest: /var/run/yum.pid
|
||||
|
||||
- name: Install a package, lock file should be deleted by the module
|
||||
yum:
|
||||
name: sos
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- yum_result is success
|
||||
|
||||
always:
|
||||
- name: Clean up
|
||||
yum:
|
||||
name: sos
|
||||
state: absent
|
||||
|
||||
when: ansible_pkg_mgr == 'yum'
|
@ -1,82 +0,0 @@
|
||||
# (c) 2014, James Tanner <tanner.jc@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Note: We install the yum package onto Fedora so that this will work on dnf systems
|
||||
# We want to test that for people who don't want to upgrade their systems.
|
||||
|
||||
- block:
|
||||
- name: ensure test packages are removed before starting
|
||||
yum:
|
||||
name:
|
||||
- sos
|
||||
state: absent
|
||||
|
||||
- import_tasks: yum.yml
|
||||
always:
|
||||
- name: remove installed packages
|
||||
yum:
|
||||
name:
|
||||
- sos
|
||||
state: absent
|
||||
|
||||
- name: remove installed group
|
||||
yum:
|
||||
name: "@Custom Group"
|
||||
state: absent
|
||||
|
||||
- name: On Fedora 28 the above won't remove the group which results in a failure in repo.yml below
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: absent
|
||||
when:
|
||||
- ansible_distribution in ['Fedora']
|
||||
|
||||
when:
|
||||
- ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux', 'Fedora']
|
||||
|
||||
|
||||
- block:
|
||||
- import_tasks: repo.yml
|
||||
- import_tasks: yum_group_remove.yml
|
||||
when:
|
||||
- ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux']
|
||||
always:
|
||||
- yum_repository:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
loop: "{{ repos }}"
|
||||
|
||||
- command: yum clean metadata
|
||||
when:
|
||||
- ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux', 'Fedora']
|
||||
|
||||
|
||||
- import_tasks: yuminstallroot.yml
|
||||
when:
|
||||
- ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux', 'Fedora']
|
||||
|
||||
|
||||
- import_tasks: proxy.yml
|
||||
when:
|
||||
- ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux', 'Fedora']
|
||||
|
||||
|
||||
- import_tasks: check_mode_consistency.yml
|
||||
when:
|
||||
- (ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and ansible_distribution_major_version|int == 7)
|
||||
|
||||
|
||||
- import_tasks: lock.yml
|
||||
when:
|
||||
- ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux']
|
||||
|
||||
- import_tasks: multiarch.yml
|
||||
when:
|
||||
- ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux']
|
||||
- ansible_architecture == 'x86_64'
|
||||
# Our output parsing expects us to be on yum, not dnf
|
||||
- ansible_distribution_major_version is version('7', '<=')
|
||||
|
||||
- import_tasks: cacheonly.yml
|
||||
when:
|
||||
- ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux', 'Fedora']
|
@ -1,154 +0,0 @@
|
||||
- block:
|
||||
- name: Set up test yum repo
|
||||
yum_repository:
|
||||
name: multiarch-test-repo
|
||||
description: ansible-test multiarch test repo
|
||||
baseurl: "{{ multiarch_repo_baseurl }}"
|
||||
gpgcheck: no
|
||||
repo_gpgcheck: no
|
||||
|
||||
- name: Install two out of date packages from the repo
|
||||
yum:
|
||||
name:
|
||||
- multiarch-a-1.0
|
||||
- multiarch-b-1.0
|
||||
register: outdated
|
||||
|
||||
- name: See what we installed
|
||||
command: rpm -q multiarch-a multiarch-b
|
||||
register: rpm_q
|
||||
|
||||
# Here we assume we're running on x86_64 (and limit to this in main.yml)
|
||||
# (avoid comparing ansible_architecture because we only have test RPMs
|
||||
# for i686 and x86_64 and ansible_architecture could be other things.)
|
||||
- name: Assert that we got the right architecture
|
||||
assert:
|
||||
that:
|
||||
- outdated is changed
|
||||
- outdated.changes.installed | length == 2
|
||||
- rpm_q.stdout_lines | length == 2
|
||||
- rpm_q.stdout_lines[0].endswith('x86_64')
|
||||
- rpm_q.stdout_lines[1].endswith('x86_64')
|
||||
|
||||
- name: Install the same versions, but i686 instead
|
||||
yum:
|
||||
name:
|
||||
- multiarch-a-1.0*.i686
|
||||
- multiarch-b-1.0*.i686
|
||||
register: outdated_i686
|
||||
|
||||
- name: See what we installed
|
||||
command: rpm -q multiarch-a multiarch-b
|
||||
register: rpm_q
|
||||
|
||||
- name: Assert that all four are installed
|
||||
assert:
|
||||
that:
|
||||
- outdated_i686 is changed
|
||||
- outdated.changes.installed | length == 2
|
||||
- rpm_q.stdout_lines | length == 4
|
||||
|
||||
- name: Update them all to 2.0
|
||||
yum:
|
||||
name: multiarch-*
|
||||
state: latest
|
||||
update_only: true
|
||||
register: yum_latest
|
||||
|
||||
- name: Assert that all were updated and shown in results
|
||||
assert:
|
||||
that:
|
||||
- yum_latest is changed
|
||||
# This is just testing UI stability. The behavior is arguably not
|
||||
# correct, because multiple packages are being updated. But the
|
||||
# "because of (at least)..." wording kinda locks us in to only
|
||||
# showing one update in this case. :(
|
||||
- yum_latest.changes.updated | length == 1
|
||||
|
||||
- name: Downgrade them so we can upgrade them a different way
|
||||
yum:
|
||||
name:
|
||||
- multiarch-a-1.0*
|
||||
- multiarch-b-1.0*
|
||||
allow_downgrade: true
|
||||
register: downgrade
|
||||
|
||||
- name: See what we installed
|
||||
command: rpm -q multiarch-a multiarch-b --queryformat '%{name}-%{version}.%{arch}\n'
|
||||
register: rpm_q
|
||||
|
||||
- name: Ensure downgrade worked
|
||||
assert:
|
||||
that:
|
||||
- downgrade is changed
|
||||
- rpm_q.stdout_lines | sort == ['multiarch-a-1.0.i686', 'multiarch-a-1.0.x86_64', 'multiarch-b-1.0.i686', 'multiarch-b-1.0.x86_64']
|
||||
|
||||
# This triggers a different branch of logic that the partial wildcard
|
||||
# above, but we're limited to check_mode here since it's '*'.
|
||||
- name: Upgrade with full wildcard
|
||||
yum:
|
||||
name: '*'
|
||||
state: latest
|
||||
update_only: true
|
||||
update_cache: true
|
||||
check_mode: true
|
||||
register: full_wildcard
|
||||
|
||||
# https://github.com/ansible/ansible/issues/73284
|
||||
- name: Ensure we report things correctly (both arches)
|
||||
assert:
|
||||
that:
|
||||
- full_wildcard is changed
|
||||
- full_wildcard.changes.updated | filter_list_of_tuples_by_first_param('multiarch', startswith=True) | length == 4
|
||||
|
||||
- name: Downgrade them so we can upgrade them a different way
|
||||
yum:
|
||||
name:
|
||||
- multiarch-a-1.0*
|
||||
- multiarch-b-1.0*
|
||||
allow_downgrade: true
|
||||
register: downgrade
|
||||
|
||||
- name: Try to install again via virtual provides, should be unchanged
|
||||
yum:
|
||||
name:
|
||||
- virtual-provides-multiarch-a
|
||||
- virtual-provides-multiarch-b
|
||||
state: present
|
||||
register: install_vp
|
||||
|
||||
- name: Ensure the above did not change
|
||||
assert:
|
||||
that:
|
||||
- install_vp is not changed
|
||||
|
||||
- name: Try to upgrade via virtual provides
|
||||
yum:
|
||||
name:
|
||||
- virtual-provides-multiarch-a
|
||||
- virtual-provides-multiarch-b
|
||||
state: latest
|
||||
update_only: true
|
||||
register: upgrade_vp
|
||||
|
||||
- name: Ensure we report things correctly (both arches)
|
||||
assert:
|
||||
that:
|
||||
- upgrade_vp is changed
|
||||
# This is just testing UI stability, like above.
|
||||
# We'll only have one package in "updated" per spec, even though
|
||||
# (in this case) two are getting updated per spec.
|
||||
- upgrade_vp.changes.updated | length == 2
|
||||
|
||||
always:
|
||||
- name: Remove test yum repo
|
||||
yum_repository:
|
||||
name: multiarch-test-repo
|
||||
state: absent
|
||||
|
||||
- name: Remove all test packages installed
|
||||
yum:
|
||||
name:
|
||||
- multiarch-*
|
||||
- virtual-provides-multiarch-*
|
||||
state: absent
|
@ -1,186 +0,0 @@
|
||||
- name: test yum proxy settings
|
||||
block:
|
||||
- name: install tinyproxy
|
||||
yum:
|
||||
name: 'https://ci-files.testing.ansible.com/test/integration/targets/yum/tinyproxy-1.10.0-3.el7.x86_64.rpm'
|
||||
state: installed
|
||||
|
||||
# systemd doesn't play nice with this in a container for some reason
|
||||
- name: start tinyproxy (systemd with tiny proxy does not work in container)
|
||||
shell: tinyproxy
|
||||
changed_when: false
|
||||
|
||||
# test proxy without auth
|
||||
- name: set unauthenticated proxy in yum.conf
|
||||
lineinfile:
|
||||
path: /etc/yum.conf
|
||||
line: "proxy=http://127.0.0.1:8888"
|
||||
state: present
|
||||
|
||||
- name: clear proxy logs
|
||||
shell: ': > /var/log/tinyproxy/tinyproxy.log'
|
||||
changed_when: false
|
||||
args:
|
||||
executable: /usr/bin/bash
|
||||
|
||||
- name: install ninvaders with unauthenticated proxy
|
||||
yum:
|
||||
name: 'https://ci-files.testing.ansible.com/test/integration/targets/yum/ninvaders-0.1.1-18.el7.x86_64.rpm'
|
||||
state: installed
|
||||
register: yum_proxy_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "yum_proxy_result.changed"
|
||||
- "'msg' in yum_proxy_result"
|
||||
- "'rc' in yum_proxy_result"
|
||||
|
||||
- name: check that it install via unauthenticated proxy
|
||||
command: grep -q Request /var/log/tinyproxy/tinyproxy.log
|
||||
|
||||
- name: uninstall ninvaders with unauthenticated proxy
|
||||
yum:
|
||||
name: ninvaders
|
||||
state: absent
|
||||
register: yum_proxy_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "yum_proxy_result.changed"
|
||||
- "'msg' in yum_proxy_result"
|
||||
- "'rc' in yum_proxy_result"
|
||||
|
||||
- name: unset unauthenticated proxy in yum.conf
|
||||
lineinfile:
|
||||
path: /etc/yum.conf
|
||||
line: "proxy=http://127.0.0.1:8888"
|
||||
state: absent
|
||||
|
||||
# test proxy with auth
|
||||
- name: set authenticated proxy config in tinyproxy.conf
|
||||
lineinfile:
|
||||
path: /etc/tinyproxy/tinyproxy.conf
|
||||
line: "BasicAuth 1testuser 1testpassword"
|
||||
state: present
|
||||
|
||||
# systemd doesn't play nice with this in a container for some reason
|
||||
- name: SIGHUP tinyproxy to reload config (workaround because of systemd+tinyproxy in container)
|
||||
shell: kill -HUP $(ps -ef | grep tinyproxy | grep -v grep | awk '{print $2}')
|
||||
changed_when: false
|
||||
args:
|
||||
executable: /usr/bin/bash
|
||||
|
||||
- name: set authenticated proxy config in yum.conf
|
||||
lineinfile:
|
||||
path: /etc/yum.conf
|
||||
line: "proxy=http://1testuser:1testpassword@127.0.0.1:8888"
|
||||
state: present
|
||||
|
||||
- name: clear proxy logs
|
||||
shell: ': > /var/log/tinyproxy/tinyproxy.log'
|
||||
changed_when: false
|
||||
args:
|
||||
executable: /usr/bin/bash
|
||||
|
||||
- name: install ninvaders with authenticated proxy
|
||||
yum:
|
||||
name: 'https://ci-files.testing.ansible.com/test/integration/targets/yum/ninvaders-0.1.1-18.el7.x86_64.rpm'
|
||||
state: installed
|
||||
register: yum_proxy_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "yum_proxy_result.changed"
|
||||
- "'msg' in yum_proxy_result"
|
||||
- "'rc' in yum_proxy_result"
|
||||
|
||||
- name: check that it install via authenticated proxy
|
||||
command: grep -q Request /var/log/tinyproxy/tinyproxy.log
|
||||
|
||||
- name: uninstall ninvaders with authenticated proxy
|
||||
yum:
|
||||
name: ninvaders
|
||||
state: absent
|
||||
|
||||
- name: unset authenticated proxy config in yum.conf
|
||||
lineinfile:
|
||||
path: /etc/yum.conf
|
||||
line: "proxy=http://1testuser:1testpassword@127.0.0.1:8888"
|
||||
state: absent
|
||||
|
||||
- name: set proxy config in yum.conf
|
||||
lineinfile:
|
||||
path: /etc/yum.conf
|
||||
line: "proxy=http://127.0.0.1:8888"
|
||||
state: present
|
||||
|
||||
- name: set proxy_username config in yum.conf
|
||||
lineinfile:
|
||||
path: /etc/yum.conf
|
||||
line: "proxy_username=1testuser"
|
||||
state: present
|
||||
|
||||
- name: set proxy_password config in yum.conf
|
||||
lineinfile:
|
||||
path: /etc/yum.conf
|
||||
line: "proxy_password=1testpassword"
|
||||
state: present
|
||||
|
||||
- name: clear proxy logs
|
||||
shell: ': > /var/log/tinyproxy/tinyproxy.log'
|
||||
changed_when: false
|
||||
args:
|
||||
executable: /usr/bin/bash
|
||||
|
||||
- name: install ninvaders with proxy, proxy_username, and proxy_password config in yum.conf
|
||||
yum:
|
||||
name: 'https://ci-files.testing.ansible.com/test/integration/targets/yum/ninvaders-0.1.1-18.el7.x86_64.rpm'
|
||||
state: installed
|
||||
register: yum_proxy_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "yum_proxy_result.changed"
|
||||
- "'msg' in yum_proxy_result"
|
||||
- "'rc' in yum_proxy_result"
|
||||
|
||||
- name: check that it install via proxy with proxy_username, proxy_password config in yum.conf
|
||||
command: grep -q Request /var/log/tinyproxy/tinyproxy.log
|
||||
|
||||
always:
|
||||
#cleanup
|
||||
- name: uninstall tinyproxy
|
||||
yum:
|
||||
name: tinyproxy
|
||||
state: absent
|
||||
|
||||
- name: uninstall ninvaders
|
||||
yum:
|
||||
name: ninvaders
|
||||
state: absent
|
||||
|
||||
- name: ensure unset authenticated proxy
|
||||
lineinfile:
|
||||
path: /etc/yum.conf
|
||||
line: "proxy=http://1testuser:1testpassword@127.0.0.1:8888"
|
||||
state: absent
|
||||
|
||||
- name: ensure unset proxy
|
||||
lineinfile:
|
||||
path: /etc/yum.conf
|
||||
line: "proxy=http://127.0.0.1:8888"
|
||||
state: absent
|
||||
|
||||
- name: ensure unset proxy_username
|
||||
lineinfile:
|
||||
path: /etc/yum.conf
|
||||
line: "proxy_username=1testuser"
|
||||
state: absent
|
||||
|
||||
- name: ensure unset proxy_password
|
||||
lineinfile:
|
||||
path: /etc/yum.conf
|
||||
line: "proxy_password=1testpassword"
|
||||
state: absent
|
||||
when:
|
||||
- (ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and ansible_distribution_major_version|int == 7 and ansible_architecture in ['x86_64'])
|
@ -1,729 +0,0 @@
|
||||
- block:
|
||||
- name: Install dinginessentail-1.0-1
|
||||
yum:
|
||||
name: dinginessentail-1.0-1
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
# ============================================================================
|
||||
- name: Install dinginessentail-1.0-1 again
|
||||
yum:
|
||||
name: dinginessentail-1.0-1
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
# ============================================================================
|
||||
- name: Install dinginessentail-1:1.0-2
|
||||
yum:
|
||||
name: "dinginessentail-1:1.0-2.{{ ansible_architecture }}"
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: Remove dinginessentail
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: absent
|
||||
# ============================================================================
|
||||
- name: Downgrade dinginessentail
|
||||
yum:
|
||||
name: dinginessentail-1.0-1
|
||||
state: present
|
||||
allow_downgrade: yes
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
# ============================================================================
|
||||
- name: Update to the latest dinginessentail
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: latest
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.1-1')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
# ============================================================================
|
||||
- name: Install dinginessentail-1.0-1 from a file (higher version is already installed)
|
||||
yum:
|
||||
name: "{{ repodir }}/dinginessentail-1.0-1.{{ ansible_architecture }}.rpm"
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.1-1')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: Remove dinginessentail
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: absent
|
||||
# ============================================================================
|
||||
- name: Install dinginessentail-1.0-1 from a file
|
||||
yum:
|
||||
name: "{{ repodir }}/dinginessentail-1.0-1.{{ ansible_architecture }}.rpm"
|
||||
state: present
|
||||
disable_gpg_check: true
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
# ============================================================================
|
||||
- name: Install dinginessentail-1.0-1 from a file again
|
||||
yum:
|
||||
name: "{{ repodir }}/dinginessentail-1.0-1.{{ ansible_architecture }}.rpm"
|
||||
state: present
|
||||
disable_gpg_check: true
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
# ============================================================================
|
||||
- name: Install dinginessentail-1.0-2 from a file
|
||||
yum:
|
||||
name: "{{ repodir }}/dinginessentail-1.0-2.{{ ansible_architecture }}.rpm"
|
||||
state: present
|
||||
disable_gpg_check: true
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
# ============================================================================
|
||||
- name: Install dinginessentail-1.0-2 from a file again
|
||||
yum:
|
||||
name: "{{ repodir }}/dinginessentail-1.0-2.{{ ansible_architecture }}.rpm"
|
||||
state: present
|
||||
disable_gpg_check: true
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
# ============================================================================
|
||||
- name: Try to downgrade dinginessentail without allow_downgrade being set
|
||||
yum:
|
||||
name: dinginessentail-1.0-1
|
||||
state: present
|
||||
allow_downgrade: no
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
# ============================================================================
|
||||
- name: Update dinginessentail with update_only set
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: latest
|
||||
update_only: yes
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.1-1')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: Remove dinginessentail
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: absent
|
||||
# ============================================================================
|
||||
- name: Try to update dinginessentail which is not installed, update_only is set
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: latest
|
||||
update_only: yes
|
||||
register: yum_result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "rpm_result.rc == 1"
|
||||
- "yum_result.rc == 0"
|
||||
- "not yum_result.changed"
|
||||
- "not yum_result is failed"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
# ============================================================================
|
||||
- name: Try to install incompatible arch
|
||||
yum:
|
||||
name: "{{ repodir_ppc64 }}/dinginessentail-1.0-1.ppc64.rpm"
|
||||
state: present
|
||||
register: yum_result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "rpm_result.rc == 1"
|
||||
- "yum_result.rc == 1"
|
||||
- "not yum_result.changed"
|
||||
- "yum_result is failed"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
# ============================================================================
|
||||
- name: Make sure latest dinginessentail is installed
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: latest
|
||||
|
||||
- name: Downgrade dinginessentail using rpm file
|
||||
yum:
|
||||
name: "{{ repodir }}/dinginessentail-1.0-1.{{ ansible_architecture }}.rpm"
|
||||
state: present
|
||||
allow_downgrade: yes
|
||||
disable_gpg_check: yes
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
# ============================================================================
|
||||
- block:
|
||||
- name: make sure dinginessentail is not installed
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: absent
|
||||
|
||||
- name: install dinginessentail both archs
|
||||
yum:
|
||||
name: "{{ pkgs }}"
|
||||
state: present
|
||||
disable_gpg_check: true
|
||||
vars:
|
||||
pkgs:
|
||||
- "{{ repodir }}/dinginessentail-1.1-1.x86_64.rpm"
|
||||
- "{{ repodir_i686 }}/dinginessentail-1.1-1.i686.rpm"
|
||||
|
||||
- name: try to install lower version of dinginessentail from rpm file, without allow_downgrade, just one arch
|
||||
yum:
|
||||
name: "{{ repodir_i686 }}/dinginessentail-1.0-1.i686.rpm"
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: verify installation
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result.changed"
|
||||
- "rpm_result.stdout_lines[0].startswith('dinginessentail-1.1-1')"
|
||||
- "rpm_result.stdout_lines[1].startswith('dinginessentail-1.1-1')"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
when: ansible_architecture == "x86_64"
|
||||
# ============================================================================
|
||||
- block:
|
||||
- name: make sure dinginessentail is not installed
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: absent
|
||||
|
||||
- name: install dinginessentail both archs
|
||||
yum:
|
||||
name: "{{ pkgs }}"
|
||||
state: present
|
||||
disable_gpg_check: true
|
||||
vars:
|
||||
pkgs:
|
||||
- "{{ repodir }}/dinginessentail-1.0-1.x86_64.rpm"
|
||||
- "{{ repodir_i686 }}/dinginessentail-1.0-1.i686.rpm"
|
||||
|
||||
- name: Update both arch in one task using rpm files
|
||||
yum:
|
||||
name: "{{ repodir }}/dinginessentail-1.1-1.x86_64.rpm,{{ repodir_i686 }}/dinginessentail-1.1-1.i686.rpm"
|
||||
state: present
|
||||
disable_gpg_check: yes
|
||||
register: yum_result
|
||||
|
||||
- name: check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout_lines[0].startswith('dinginessentail-1.1-1')"
|
||||
- "rpm_result.stdout_lines[1].startswith('dinginessentail-1.1-1')"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
when: ansible_architecture == "x86_64"
|
||||
# ============================================================================
|
||||
always:
|
||||
- name: Clean up
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: absent
|
||||
|
||||
# FIXME: dnf currently doesn't support epoch as part of it's pkg_spec for
|
||||
# finding install candidates
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1619687
|
||||
- block:
|
||||
- name: Install 1:dinginessentail-1.0-2
|
||||
yum:
|
||||
name: "1:dinginessentail-1.0-2.{{ ansible_architecture }}"
|
||||
state: present
|
||||
disable_gpg_check: true
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
always:
|
||||
- name: Clean up
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: absent
|
||||
|
||||
when: ansible_pkg_mgr == 'yum'
|
||||
|
||||
# DNF1 (Fedora < 26) had some issues:
|
||||
# - did not accept architecture tag as valid component of a package spec unless
|
||||
# installing a file (i.e. can't search the repo)
|
||||
# - doesn't handle downgrade transactions via the API properly, marks it as a
|
||||
# conflict
|
||||
#
|
||||
# NOTE: Both DNF1 and Fedora < 26 have long been EOL'd by their respective
|
||||
# upstreams
|
||||
- block:
|
||||
# ============================================================================
|
||||
- name: Install dinginessentail-1.0-2
|
||||
yum:
|
||||
name: "dinginessentail-1.0-2.{{ ansible_architecture }}"
|
||||
state: present
|
||||
disable_gpg_check: true
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: Install dinginessentail-1.0-2 again
|
||||
yum:
|
||||
name: dinginessentail-1.0-2
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
always:
|
||||
- name: Clean up
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: absent
|
||||
when: not (ansible_distribution == "Fedora" and ansible_distribution_major_version|int < 26)
|
||||
|
||||
# https://github.com/ansible/ansible/issues/47689
|
||||
- block:
|
||||
- name: Install dinginessentail == 1.0
|
||||
yum:
|
||||
name: "dinginessentail == 1.0"
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
always:
|
||||
- name: Clean up
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: absent
|
||||
|
||||
when: ansible_pkg_mgr == 'yum'
|
||||
|
||||
|
||||
# https://github.com/ansible/ansible/pull/54603
|
||||
- block:
|
||||
- name: Install dinginessentail < 1.1
|
||||
yum:
|
||||
name: "dinginessentail < 1.1"
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.0')"
|
||||
|
||||
- name: Install dinginessentail >= 1.1
|
||||
yum:
|
||||
name: "dinginessentail >= 1.1"
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.1')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
always:
|
||||
- name: Clean up
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: absent
|
||||
|
||||
when: ansible_pkg_mgr == 'yum'
|
||||
|
||||
# https://github.com/ansible/ansible/issues/45250
|
||||
- block:
|
||||
- name: Install dinginessentail-1.0, dinginessentail-olive-1.0, landsidescalping-1.0
|
||||
yum:
|
||||
name: "dinginessentail-1.0,dinginessentail-olive-1.0,landsidescalping-1.0"
|
||||
state: present
|
||||
|
||||
- name: Upgrade dinginessentail*
|
||||
yum:
|
||||
name: dinginessentail*
|
||||
state: latest
|
||||
register: yum_result
|
||||
|
||||
- name: Check dinginessentail with rpm
|
||||
shell: rpm -q dinginessentail
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify update of dinginessentail
|
||||
assert:
|
||||
that:
|
||||
- "rpm_result.stdout.startswith('dinginessentail-1.1-1')"
|
||||
|
||||
- name: Check dinginessentail-olive with rpm
|
||||
shell: rpm -q dinginessentail-olive
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify update of dinginessentail-olive
|
||||
assert:
|
||||
that:
|
||||
- "rpm_result.stdout.startswith('dinginessentail-olive-1.1-1')"
|
||||
|
||||
- name: Check landsidescalping with rpm
|
||||
shell: rpm -q landsidescalping
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify landsidescalping did NOT get updated
|
||||
assert:
|
||||
that:
|
||||
- "rpm_result.stdout.startswith('landsidescalping-1.0-1')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is changed"
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
always:
|
||||
- name: Clean up
|
||||
yum:
|
||||
name: dinginessentail,dinginessentail-olive,landsidescalping
|
||||
state: absent
|
||||
|
||||
- block:
|
||||
- yum:
|
||||
name: dinginessentail
|
||||
state: present
|
||||
|
||||
- yum:
|
||||
list: dinginessentail*
|
||||
register: list_out
|
||||
|
||||
- set_fact:
|
||||
passed: true
|
||||
loop: "{{ list_out.results }}"
|
||||
when: item.yumstate == 'installed'
|
||||
|
||||
- name: Test that there is yumstate=installed in the result
|
||||
assert:
|
||||
that:
|
||||
- passed is defined
|
||||
always:
|
||||
- name: Clean up
|
||||
yum:
|
||||
name: dinginessentail
|
||||
state: absent
|
@ -1,884 +0,0 @@
|
||||
# Setup by setup_rpm_repo
|
||||
- set_fact:
|
||||
package1: dinginessentail
|
||||
package2: dinginessentail-olive
|
||||
|
||||
# UNINSTALL
|
||||
- name: uninstall {{ package1 }}
|
||||
yum: name={{ package1 }} state=removed
|
||||
register: yum_result
|
||||
|
||||
- name: check {{ package1 }} with rpm
|
||||
shell: rpm -q {{ package1 }}
|
||||
ignore_errors: True
|
||||
register: rpm_result
|
||||
|
||||
- name: verify uninstallation of {{ package1 }}
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "rpm_result is failed"
|
||||
|
||||
# UNINSTALL AGAIN
|
||||
- name: uninstall {{ package1 }} again in check mode
|
||||
yum: name={{ package1 }} state=removed
|
||||
check_mode: true
|
||||
register: yum_result
|
||||
|
||||
- name: verify no change on re-uninstall in check mode
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result is changed"
|
||||
|
||||
- name: uninstall {{ package1 }} again
|
||||
yum: name={{ package1 }} state=removed
|
||||
register: yum_result
|
||||
|
||||
- name: verify no change on re-uninstall
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result is changed"
|
||||
|
||||
# INSTALL
|
||||
- name: install {{ package1 }} in check mode
|
||||
yum: name={{ package1 }} state=present
|
||||
check_mode: true
|
||||
register: yum_result
|
||||
|
||||
- name: verify installation of {{ package1 }} in check mode
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is changed"
|
||||
|
||||
- name: install {{ package1 }}
|
||||
yum: name={{ package1 }} state=present
|
||||
register: yum_result
|
||||
|
||||
- name: verify installation of {{ package1 }}
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "yum_result is changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: check {{ package1 }} with rpm
|
||||
shell: rpm -q {{ package1 }}
|
||||
|
||||
# INSTALL AGAIN
|
||||
- name: install {{ package1 }} again in check mode
|
||||
yum: name={{ package1 }} state=present
|
||||
check_mode: true
|
||||
register: yum_result
|
||||
- name: verify no change on second install in check mode
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result is changed"
|
||||
|
||||
- name: install {{ package1 }} again
|
||||
yum: name={{ package1 }} state=present
|
||||
register: yum_result
|
||||
- name: verify no change on second install
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result is changed"
|
||||
|
||||
- name: install {{ package1 }} again with empty string enablerepo
|
||||
yum: name={{ package1 }} state=present enablerepo=""
|
||||
register: yum_result
|
||||
- name: verify no change on third install with empty string enablerepo
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "not yum_result is changed"
|
||||
|
||||
# This test case is unfortunately distro specific because we have to specify
|
||||
# repo names which are not the same across Fedora/RHEL/CentOS for base/updates
|
||||
- name: install {{ package1 }} again with missing repo enablerepo
|
||||
yum:
|
||||
name: '{{ package1 }}'
|
||||
state: present
|
||||
enablerepo: '{{ repos + ["thisrepodoesnotexist"] }}'
|
||||
disablerepo: "*"
|
||||
register: yum_result
|
||||
when: ansible_distribution == 'CentOS'
|
||||
- name: verify no change on fourth install with missing repo enablerepo (yum)
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "yum_result is not changed"
|
||||
when: ansible_distribution == 'CentOS'
|
||||
|
||||
# This test case is unfortunately distro specific because we have to specify
|
||||
# repo names which are not the same across Fedora/RHEL/CentOS for base/updates
|
||||
- name: install repos again with disable all and enable select repo(s)
|
||||
yum:
|
||||
name: '{{ package1 }}'
|
||||
state: present
|
||||
enablerepo: '{{ repos }}'
|
||||
disablerepo: "*"
|
||||
register: yum_result
|
||||
when: ansible_distribution == 'CentOS'
|
||||
- name: verify no change on fourth install with missing repo enablerepo (yum)
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "yum_result is not changed"
|
||||
when: ansible_distribution == 'CentOS'
|
||||
|
||||
- name: install {{ package1 }} again with only missing repo enablerepo
|
||||
yum:
|
||||
name: '{{ package1 }}'
|
||||
state: present
|
||||
enablerepo: "thisrepodoesnotexist"
|
||||
ignore_errors: true
|
||||
register: yum_result
|
||||
- name: verify no change on fifth install with only missing repo enablerepo (yum)
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is not success"
|
||||
when: ansible_pkg_mgr == 'yum'
|
||||
- name: verify no change on fifth install with only missing repo enablerepo (dnf)
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
when: ansible_pkg_mgr == 'dnf'
|
||||
|
||||
# INSTALL AGAIN WITH LATEST
|
||||
- name: install {{ package1 }} again with state latest in check mode
|
||||
yum: name={{ package1 }} state=latest
|
||||
check_mode: true
|
||||
register: yum_result
|
||||
- name: verify install {{ package1 }} again with state latest in check mode
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result is changed"
|
||||
|
||||
- name: install {{ package1 }} again with state latest idempotence
|
||||
yum: name={{ package1 }} state=latest
|
||||
register: yum_result
|
||||
- name: verify install {{ package1 }} again with state latest idempotence
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result is changed"
|
||||
|
||||
# INSTALL WITH LATEST
|
||||
- name: uninstall {{ package1 }}
|
||||
yum: name={{ package1 }} state=removed
|
||||
register: yum_result
|
||||
- name: verify uninstall {{ package1 }}
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is successful"
|
||||
|
||||
- name: copy yum.conf file in case it is missing
|
||||
copy:
|
||||
src: yum.conf
|
||||
dest: /etc/yum.conf
|
||||
force: False
|
||||
register: yum_conf_copy
|
||||
|
||||
- block:
|
||||
- name: install {{ package1 }} with state latest in check mode with config file param
|
||||
yum: name={{ package1 }} state=latest conf_file=/etc/yum.conf
|
||||
check_mode: true
|
||||
register: yum_result
|
||||
- name: verify install {{ package1 }} with state latest in check mode with config file param
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is changed"
|
||||
|
||||
always:
|
||||
- name: remove tmp yum.conf file if we created it
|
||||
file:
|
||||
path: /etc/yum.conf
|
||||
state: absent
|
||||
when: yum_conf_copy is changed
|
||||
|
||||
- name: install {{ package1 }} with state latest in check mode
|
||||
yum: name={{ package1 }} state=latest
|
||||
check_mode: true
|
||||
register: yum_result
|
||||
- name: verify install {{ package1 }} with state latest in check mode
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is changed"
|
||||
|
||||
- name: install {{ package1 }} with state latest
|
||||
yum: name={{ package1 }} state=latest
|
||||
register: yum_result
|
||||
- name: verify install {{ package1 }} with state latest
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is changed"
|
||||
|
||||
- name: install {{ package1 }} with state latest idempotence
|
||||
yum: name={{ package1 }} state=latest
|
||||
register: yum_result
|
||||
- name: verify install {{ package1 }} with state latest idempotence
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result is changed"
|
||||
|
||||
- name: install {{ package1 }} with state latest idempotence with config file param
|
||||
yum: name={{ package1 }} state=latest
|
||||
register: yum_result
|
||||
- name: verify install {{ package1 }} with state latest idempotence with config file param
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result is changed"
|
||||
|
||||
|
||||
# Multiple packages
|
||||
- name: uninstall {{ package1 }} and {{ package2 }}
|
||||
yum: name={{ package1 }},{{ package2 }} state=removed
|
||||
|
||||
- name: check {{ package1 }} with rpm
|
||||
shell: rpm -q {{ package1 }}
|
||||
ignore_errors: True
|
||||
register: rpm_package1_result
|
||||
|
||||
- name: check {{ package2 }} with rpm
|
||||
shell: rpm -q {{ package2 }}
|
||||
ignore_errors: True
|
||||
register: rpm_package2_result
|
||||
|
||||
- name: verify packages installed
|
||||
assert:
|
||||
that:
|
||||
- "rpm_package1_result is failed"
|
||||
- "rpm_package2_result is failed"
|
||||
|
||||
- name: install {{ package1 }} and {{ package2 }} as comma separated
|
||||
yum: name={{ package1 }},{{ package2 }} state=present
|
||||
register: yum_result
|
||||
|
||||
- name: verify packages installed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "yum_result is changed"
|
||||
|
||||
- name: check {{ package1 }} with rpm
|
||||
shell: rpm -q {{ package1 }}
|
||||
|
||||
- name: check {{ package2 }} with rpm
|
||||
shell: rpm -q {{ package2 }}
|
||||
|
||||
- name: uninstall {{ package1 }} and {{ package2 }}
|
||||
yum: name={{ package1 }},{{ package2 }} state=removed
|
||||
register: yum_result
|
||||
|
||||
- name: install {{ package1 }} and {{ package2 }} as list
|
||||
yum:
|
||||
name:
|
||||
- '{{ package1 }}'
|
||||
- '{{ package2 }}'
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: verify packages installed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "yum_result is changed"
|
||||
|
||||
- name: check {{ package1 }} with rpm
|
||||
shell: rpm -q {{ package1 }}
|
||||
|
||||
- name: check {{ package2 }} with rpm
|
||||
shell: rpm -q {{ package2 }}
|
||||
|
||||
- name: uninstall {{ package1 }} and {{ package2 }}
|
||||
yum: name={{ package1 }},{{ package2 }} state=removed
|
||||
register: yum_result
|
||||
|
||||
- name: install {{ package1 }} and {{ package2 }} as comma separated with spaces
|
||||
yum:
|
||||
name: "{{ package1 }}, {{ package2 }}"
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: verify packages installed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "yum_result is changed"
|
||||
|
||||
- name: check {{ package1 }} with rpm
|
||||
shell: rpm -q {{ package1 }}
|
||||
|
||||
- name: check {{ package2 }} with rpm
|
||||
shell: rpm -q {{ package2 }}
|
||||
|
||||
- name: uninstall {{ package1 }} and {{ package2 }}
|
||||
yum: name={{ package1 }},{{ package2 }} state=removed
|
||||
|
||||
- name: install non-existent rpm
|
||||
yum:
|
||||
name: does-not-exist
|
||||
register: non_existent_rpm
|
||||
ignore_errors: True
|
||||
|
||||
- name: check non-existent rpm install failed
|
||||
assert:
|
||||
that:
|
||||
- non_existent_rpm is failed
|
||||
|
||||
# Install in installroot='/'
|
||||
- name: install {{ package1 }}
|
||||
yum: name={{ package1 }} state=present installroot='/'
|
||||
register: yum_result
|
||||
|
||||
- name: verify installation of {{ package1 }}
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "yum_result is changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: check {{ package1 }} with rpm
|
||||
shell: rpm -q {{ package1 }} --root=/
|
||||
|
||||
- name: uninstall {{ package1 }}
|
||||
yum:
|
||||
name: '{{ package1 }}'
|
||||
installroot: '/'
|
||||
state: removed
|
||||
register: yum_result
|
||||
|
||||
# Seems like some yum versions won't download a package from local file repository, continue to use sos for this test.
|
||||
# https://stackoverflow.com/questions/58295660/yum-downloadonly-ignores-packages-in-local-repo
|
||||
- name: Test download_only
|
||||
yum:
|
||||
name: sos
|
||||
state: latest
|
||||
download_only: true
|
||||
register: yum_result
|
||||
|
||||
- name: verify download of sos (part 1 -- yum "install" succeeded)
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "yum_result is changed"
|
||||
|
||||
- name: uninstall sos (noop)
|
||||
yum:
|
||||
name: sos
|
||||
state: removed
|
||||
register: yum_result
|
||||
|
||||
- name: verify download of sos (part 2 -- nothing removed during uninstall)
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "not yum_result is changed"
|
||||
|
||||
- name: uninstall sos for downloadonly/downloaddir test
|
||||
yum:
|
||||
name: sos
|
||||
state: absent
|
||||
|
||||
- name: Test download_only/download_dir
|
||||
yum:
|
||||
name: sos
|
||||
state: latest
|
||||
download_only: true
|
||||
download_dir: "/var/tmp/packages"
|
||||
register: yum_result
|
||||
|
||||
- name: verify yum output
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "yum_result is changed"
|
||||
|
||||
- command: "ls /var/tmp/packages"
|
||||
register: ls_out
|
||||
|
||||
- name: Verify specified download_dir was used
|
||||
assert:
|
||||
that:
|
||||
- "'sos' in ls_out.stdout"
|
||||
|
||||
- name: install group
|
||||
yum:
|
||||
name: "@Custom Group"
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: verify installation of the group
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "yum_result is changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: install the group again
|
||||
yum:
|
||||
name: "@Custom Group"
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: verify nothing changed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "not yum_result is changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: install the group again but also with a package that is not yet installed
|
||||
yum:
|
||||
name:
|
||||
- "@Custom Group"
|
||||
- '{{ package2 }}'
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: verify {{ package3 }} is installed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "yum_result is changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: try to install the group again, with --check to check 'changed'
|
||||
yum:
|
||||
name: "@Custom Group"
|
||||
state: present
|
||||
check_mode: yes
|
||||
register: yum_result
|
||||
|
||||
- name: verify nothing changed
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result is changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: try to install non existing group
|
||||
yum:
|
||||
name: "@non-existing-group"
|
||||
state: present
|
||||
register: yum_result
|
||||
ignore_errors: True
|
||||
|
||||
- name: verify installation of the non existing group failed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is failed"
|
||||
- "not yum_result is changed"
|
||||
- "yum_result is failed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: try to install non existing file
|
||||
yum:
|
||||
name: /tmp/non-existing-1.0.0.fc26.noarch.rpm
|
||||
state: present
|
||||
register: yum_result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: verify installation failed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is failed"
|
||||
- "not yum_result is changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
|
||||
- name: try to install from non existing url
|
||||
yum:
|
||||
name: https://ci-files.testing.ansible.com/test/integration/targets/yum/non-existing-1.0.0.fc26.noarch.rpm
|
||||
state: present
|
||||
register: yum_result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: verify installation failed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is failed"
|
||||
- "not yum_result is changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
|
||||
- name: use latest to install httpd
|
||||
yum:
|
||||
name: httpd
|
||||
state: latest
|
||||
register: yum_result
|
||||
|
||||
- name: verify httpd was installed
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
|
||||
- name: uninstall httpd
|
||||
yum:
|
||||
name: httpd
|
||||
state: removed
|
||||
|
||||
- name: update httpd only if it exists
|
||||
yum:
|
||||
name: httpd
|
||||
state: latest
|
||||
update_only: yes
|
||||
register: yum_result
|
||||
|
||||
- name: verify httpd not installed
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result is changed"
|
||||
- "'Packages providing httpd not installed due to update_only specified' in yum_result.results"
|
||||
|
||||
- name: try to install uncompatible arch rpm on non-ppc64le, should fail
|
||||
yum:
|
||||
name: https://ci-files.testing.ansible.com/test/integration/targets/yum/banner-1.3.4-3.el7.ppc64le.rpm
|
||||
state: present
|
||||
register: yum_result
|
||||
ignore_errors: True
|
||||
when:
|
||||
- ansible_architecture not in ['ppc64le']
|
||||
|
||||
- name: verify that yum failed on non-ppc64le
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result is changed"
|
||||
- "yum_result is failed"
|
||||
when:
|
||||
- ansible_architecture not in ['ppc64le']
|
||||
|
||||
- name: try to install uncompatible arch rpm on ppc64le, should fail
|
||||
yum:
|
||||
name: https://ci-files.testing.ansible.com/test/integration/targets/yum/tinyproxy-1.10.0-3.el7.x86_64.rpm
|
||||
state: present
|
||||
register: yum_result
|
||||
ignore_errors: True
|
||||
when:
|
||||
- ansible_architecture in ['ppc64le']
|
||||
|
||||
- name: verify that yum failed on ppc64le
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result is changed"
|
||||
- "yum_result is failed"
|
||||
when:
|
||||
- ansible_architecture in ['ppc64le']
|
||||
|
||||
# setup for testing installing an RPM from url
|
||||
|
||||
- set_fact:
|
||||
pkg_name: noarchfake
|
||||
pkg_path: '{{ repodir }}/noarchfake-1.0-1.noarch.rpm'
|
||||
|
||||
- name: cleanup
|
||||
yum:
|
||||
name: "{{ pkg_name }}"
|
||||
state: absent
|
||||
|
||||
# setup end
|
||||
|
||||
- name: install a local noarch rpm from file
|
||||
yum:
|
||||
name: "{{ pkg_path }}"
|
||||
state: present
|
||||
disable_gpg_check: true
|
||||
register: yum_result
|
||||
|
||||
- name: verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "yum_result is changed"
|
||||
- "yum_result is not failed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: install the downloaded rpm again
|
||||
yum:
|
||||
name: "{{ pkg_path }}"
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "not yum_result is changed"
|
||||
- "yum_result is not failed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: clean up
|
||||
yum:
|
||||
name: "{{ pkg_name }}"
|
||||
state: absent
|
||||
|
||||
- name: install from url
|
||||
yum:
|
||||
name: "file://{{ pkg_path }}"
|
||||
state: present
|
||||
disable_gpg_check: true
|
||||
register: yum_result
|
||||
|
||||
- name: verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result is success"
|
||||
- "yum_result is changed"
|
||||
- "yum_result is not failed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: Create a temp RPM file which does not contain nevra information
|
||||
file:
|
||||
name: "/tmp/non_existent_pkg.rpm"
|
||||
state: touch
|
||||
|
||||
- name: Try installing RPM file which does not contain nevra information
|
||||
yum:
|
||||
name: "/tmp/non_existent_pkg.rpm"
|
||||
state: present
|
||||
register: no_nevra_info_result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Verify RPM failed to install
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in no_nevra_info_result"
|
||||
- "'msg' in no_nevra_info_result"
|
||||
|
||||
- name: Delete a temp RPM file
|
||||
file:
|
||||
name: "/tmp/non_existent_pkg.rpm"
|
||||
state: absent
|
||||
|
||||
- name: get yum version
|
||||
yum:
|
||||
list: yum
|
||||
register: yum_version
|
||||
|
||||
- name: set yum_version of installed version
|
||||
set_fact:
|
||||
yum_version: "{%- if item.yumstate == 'installed' -%}{{ item.version }}{%- else -%}{{ yum_version }}{%- endif -%}"
|
||||
with_items: "{{ yum_version.results }}"
|
||||
|
||||
- name: Ensure double uninstall of wildcard globs works
|
||||
block:
|
||||
- name: "Install lohit-*-fonts"
|
||||
yum:
|
||||
name: "lohit-*-fonts"
|
||||
state: present
|
||||
|
||||
- name: "Remove lohit-*-fonts (1st time)"
|
||||
yum:
|
||||
name: "lohit-*-fonts"
|
||||
state: absent
|
||||
register: remove_lohit_fonts_1
|
||||
|
||||
- name: "Verify lohit-*-fonts (1st time)"
|
||||
assert:
|
||||
that:
|
||||
- "remove_lohit_fonts_1 is changed"
|
||||
- "'msg' in remove_lohit_fonts_1"
|
||||
- "'results' in remove_lohit_fonts_1"
|
||||
|
||||
- name: "Remove lohit-*-fonts (2nd time)"
|
||||
yum:
|
||||
name: "lohit-*-fonts"
|
||||
state: absent
|
||||
register: remove_lohit_fonts_2
|
||||
|
||||
- name: "Verify lohit-*-fonts (2nd time)"
|
||||
assert:
|
||||
that:
|
||||
- "remove_lohit_fonts_2 is not changed"
|
||||
- "'msg' in remove_lohit_fonts_2"
|
||||
- "'results' in remove_lohit_fonts_2"
|
||||
- "'lohit-*-fonts is not installed' in remove_lohit_fonts_2['results']"
|
||||
|
||||
- block:
|
||||
- name: uninstall {{ package2 }}
|
||||
yum: name={{ package2 }} state=removed
|
||||
|
||||
- name: check {{ package2 }} with rpm
|
||||
shell: rpm -q {{ package2 }}
|
||||
ignore_errors: True
|
||||
register: rpm_package2_result
|
||||
|
||||
- name: verify {{ package2 }} is uninstalled
|
||||
assert:
|
||||
that:
|
||||
- "rpm_package2_result is failed"
|
||||
|
||||
- name: exclude {{ package2 }} (yum backend)
|
||||
lineinfile:
|
||||
dest: /etc/yum.conf
|
||||
regexp: (^exclude=)(.)*
|
||||
line: "exclude={{ package2 }}*"
|
||||
state: present
|
||||
when: ansible_pkg_mgr == 'yum'
|
||||
|
||||
- name: exclude {{ package2 }} (dnf backend)
|
||||
lineinfile:
|
||||
dest: /etc/dnf/dnf.conf
|
||||
regexp: (^excludepkgs=)(.)*
|
||||
line: "excludepkgs={{ package2 }}*"
|
||||
state: present
|
||||
when: ansible_pkg_mgr == 'dnf'
|
||||
|
||||
# begin test case where disable_excludes is supported
|
||||
- name: Try install {{ package2 }} without disable_excludes
|
||||
yum: name={{ package2 }} state=latest
|
||||
register: yum_package2_result
|
||||
ignore_errors: True
|
||||
|
||||
- name: verify {{ package2 }} did not install because it is in exclude list
|
||||
assert:
|
||||
that:
|
||||
- "yum_package2_result is failed"
|
||||
|
||||
- name: install {{ package2 }} with disable_excludes
|
||||
yum: name={{ package2 }} state=latest disable_excludes=all
|
||||
register: yum_package2_result_using_excludes
|
||||
|
||||
- name: verify {{ package2 }} did install using disable_excludes=all
|
||||
assert:
|
||||
that:
|
||||
- "yum_package2_result_using_excludes is success"
|
||||
- "yum_package2_result_using_excludes is changed"
|
||||
- "yum_package2_result_using_excludes is not failed"
|
||||
|
||||
- name: remove exclude {{ package2 }} (cleanup yum.conf)
|
||||
lineinfile:
|
||||
dest: /etc/yum.conf
|
||||
regexp: (^exclude={{ package2 }}*)
|
||||
line: "exclude="
|
||||
state: present
|
||||
when: ansible_pkg_mgr == 'yum'
|
||||
|
||||
- name: remove exclude {{ package2 }} (cleanup dnf.conf)
|
||||
lineinfile:
|
||||
dest: /etc/dnf/dnf.conf
|
||||
regexp: (^excludepkgs={{ package2 }}*)
|
||||
line: "excludepkgs="
|
||||
state: present
|
||||
when: ansible_pkg_mgr == 'dnf'
|
||||
|
||||
# Fedora < 26 has a bug in dnf where package excludes in dnf.conf aren't
|
||||
# actually honored and those releases are EOL'd so we have no expectation they
|
||||
# will ever be fixed
|
||||
when: not ((ansible_distribution == "Fedora") and (ansible_distribution_major_version|int < 26))
|
||||
|
||||
- name: Check that packages with Provides are handled correctly in state=absent
|
||||
block:
|
||||
- name: Install test packages
|
||||
yum:
|
||||
name:
|
||||
- https://ci-files.testing.ansible.com/test/integration/targets/yum/test-package-that-provides-toaster-1.3.3.7-1.el7.noarch.rpm
|
||||
- https://ci-files.testing.ansible.com/test/integration/targets/yum/toaster-1.2.3.4-1.el7.noarch.rpm
|
||||
disable_gpg_check: true
|
||||
register: install
|
||||
|
||||
- name: Remove toaster
|
||||
yum:
|
||||
name: toaster
|
||||
state: absent
|
||||
register: remove
|
||||
|
||||
- name: rpm -qa
|
||||
command: rpm -qa
|
||||
register: rpmqa
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- install is successful
|
||||
- install is changed
|
||||
- remove is successful
|
||||
- remove is changed
|
||||
- "'toaster-1.2.3.4' not in rpmqa.stdout"
|
||||
- "'test-package-that-provides-toaster' in rpmqa.stdout"
|
||||
always:
|
||||
- name: Remove test packages
|
||||
yum:
|
||||
name:
|
||||
- test-package-that-provides-toaster
|
||||
- toaster
|
||||
state: absent
|
||||
|
||||
- yum:
|
||||
list: "{{ package1 }}"
|
||||
register: list_out
|
||||
|
||||
- name: check that both yum and dnf return envra
|
||||
assert:
|
||||
that:
|
||||
- '"envra" in list_out["results"][0]'
|
||||
|
||||
- name: check that dnf returns nevra for backwards compat
|
||||
assert:
|
||||
that:
|
||||
- '"nevra" in list_out["results"][0]'
|
||||
when: ansible_pkg_mgr == 'dnf'
|
@ -1,152 +0,0 @@
|
||||
- name: install a group to test and yum-utils
|
||||
yum:
|
||||
name: "{{ pkgs }}"
|
||||
state: present
|
||||
vars:
|
||||
pkgs:
|
||||
- "@Custom Group"
|
||||
- yum-utils
|
||||
when: ansible_pkg_mgr == "yum"
|
||||
|
||||
- name: install a group to test and dnf-utils
|
||||
yum:
|
||||
name: "{{ pkgs }}"
|
||||
state: present
|
||||
vars:
|
||||
pkgs:
|
||||
- "@Custom Group"
|
||||
- dnf-utils
|
||||
when: ansible_pkg_mgr == "dnf"
|
||||
|
||||
- name: check mode remove the group
|
||||
yum:
|
||||
name: "@Custom Group"
|
||||
state: absent
|
||||
check_mode: yes
|
||||
register: yum_result
|
||||
|
||||
- name: verify changed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: remove the group
|
||||
yum:
|
||||
name: "@Custom Group"
|
||||
state: absent
|
||||
register: yum_result
|
||||
|
||||
- name: verify changed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.rc == 0"
|
||||
- "yum_result.changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: remove the group again
|
||||
yum:
|
||||
name: "@Custom Group"
|
||||
state: absent
|
||||
register: yum_result
|
||||
|
||||
- name: verify changed
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result.changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: check mode remove the group again
|
||||
yum:
|
||||
name: "@Custom Group"
|
||||
state: absent
|
||||
check_mode: yes
|
||||
register: yum_result
|
||||
|
||||
- name: verify changed
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result.changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: install a group and a package to test
|
||||
yum:
|
||||
name: "@Custom Group,sos"
|
||||
state: present
|
||||
register: yum_output
|
||||
|
||||
- name: check mode remove the group along with the package
|
||||
yum:
|
||||
name: "@Custom Group,sos"
|
||||
state: absent
|
||||
register: yum_result
|
||||
check_mode: yes
|
||||
|
||||
- name: verify changed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: remove the group along with the package
|
||||
yum:
|
||||
name: "@Custom Group,sos"
|
||||
state: absent
|
||||
register: yum_result
|
||||
|
||||
- name: verify changed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: check mode remove the group along with the package
|
||||
yum:
|
||||
name: "@Custom Group,sos"
|
||||
state: absent
|
||||
register: yum_result
|
||||
check_mode: yes
|
||||
|
||||
- name: verify not changed
|
||||
assert:
|
||||
that:
|
||||
- "not yum_result.changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'results' in yum_result"
|
@ -1,132 +0,0 @@
|
||||
# make a installroot
|
||||
- name: Create installroot
|
||||
command: mktemp -d "{{ remote_tmp_dir }}/ansible.test.XXXXXX"
|
||||
register: yumroot
|
||||
|
||||
#- name: Populate directory
|
||||
# file:
|
||||
# path: "/{{ yumroot.stdout }}/etc/"
|
||||
# state: directory
|
||||
# mode: 0755
|
||||
#
|
||||
#- name: Populate directory2
|
||||
# copy:
|
||||
# content: "[main]\ndistropkgver={{ ansible_distribution_version }}\n"
|
||||
# dest: "/{{ yumroot.stdout }}/etc/yum.conf"
|
||||
|
||||
- name: Make a necessary directory
|
||||
file:
|
||||
path: "{{ yumroot.stdout }}/etc/yum/vars/"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: get yum releasever
|
||||
command: "{{ ansible_python_interpreter }} -c 'import yum; yb = yum.YumBase(); print(yb.conf.yumvar[\"releasever\"])'"
|
||||
register: releasever
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Populate directory
|
||||
copy:
|
||||
content: "{{ releasever.stdout_lines[-1] }}\n"
|
||||
dest: "/{{ yumroot.stdout }}/etc/yum/vars/releasever"
|
||||
when: releasever is successful
|
||||
|
||||
# This will drag in > 200 MB.
|
||||
- name: attempt installroot
|
||||
yum: name=zlib installroot="{{ yumroot.stdout }}/" disable_gpg_check=yes
|
||||
register: yum_result
|
||||
|
||||
- name: check sos with rpm in installroot
|
||||
shell: rpm -q zlib --root="{{ yumroot.stdout }}/"
|
||||
failed_when: False
|
||||
register: rpm_result
|
||||
|
||||
- name: verify installation of sos
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.rc == 0"
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.rc == 0"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: cleanup installroot
|
||||
file:
|
||||
path: "{{ yumroot.stdout }}/"
|
||||
state: absent
|
||||
|
||||
# Test for releasever working correctly
|
||||
#
|
||||
# Bugfix: https://github.com/ansible/ansible/issues/67050
|
||||
#
|
||||
# This test case is based on a reproducer originally reported on Reddit:
|
||||
# https://www.reddit.com/r/ansible/comments/g2ps32/ansible_yum_module_throws_up_an_error_when/
|
||||
#
|
||||
# NOTE: For the Ansible upstream CI we can only run this for RHEL7 because the
|
||||
# containerized runtimes in shippable don't allow the nested mounting of
|
||||
# buildah container volumes.
|
||||
- name: perform yuminstallroot in a buildah mount with releasever
|
||||
when:
|
||||
- ansible_facts["distribution_major_version"] == "7"
|
||||
- ansible_facts["distribution"] == "RedHat"
|
||||
block:
|
||||
- name: install required packages for buildah test
|
||||
yum:
|
||||
state: present
|
||||
name:
|
||||
- buildah
|
||||
- name: create buildah container from scratch
|
||||
command: "buildah --name yum_installroot_releasever_test from scratch"
|
||||
- name: mount the buildah container
|
||||
command: "buildah mount yum_installroot_releasever_test"
|
||||
register: buildah_mount
|
||||
- name: figure out yum value of $releasever
|
||||
shell: python -c 'import yum; yb = yum.YumBase(); print(yb.conf.yumvar["releasever"])' | tail -1
|
||||
register: buildah_host_releasever
|
||||
- name: test yum install of python using releasever
|
||||
yum:
|
||||
name: 'python'
|
||||
state: present
|
||||
installroot: "{{ buildah_mount.stdout }}"
|
||||
releasever: "{{ buildah_host_releasever.stdout }}"
|
||||
register: yum_result
|
||||
- name: verify installation of python
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.rc == 0"
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.rc == 0"
|
||||
- name: remove python before another test
|
||||
yum:
|
||||
name: 'python'
|
||||
state: absent
|
||||
installroot: "{{ buildah_mount.stdout }}"
|
||||
releasever: "{{ buildah_host_releasever.stdout }}"
|
||||
- name: test yum install of python using releasever with latest
|
||||
yum:
|
||||
name: 'python'
|
||||
state: latest
|
||||
installroot: "{{ buildah_mount.stdout }}"
|
||||
releasever: "{{ buildah_host_releasever.stdout }}"
|
||||
register: yum_result
|
||||
- name: verify installation of python
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.rc == 0"
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.rc == 0"
|
||||
always:
|
||||
- name: remove buildah container
|
||||
command: "buildah rm yum_installroot_releasever_test"
|
||||
ignore_errors: yes
|
||||
- name: remove buildah from CI system
|
||||
yum:
|
||||
state: absent
|
||||
name:
|
||||
- buildah
|
@ -1 +0,0 @@
|
||||
multiarch_repo_baseurl: https://ci-files.testing.ansible.com/test/integration/targets/yum/multiarch-test-repo/RPMS/
|
@ -1,221 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
|
||||
from ansible.modules.yum import YumModule
|
||||
|
||||
|
||||
yum_plugin_load_error = """
|
||||
Plugin "product-id" can't be imported
|
||||
Plugin "search-disabled-repos" can't be imported
|
||||
Plugin "subscription-manager" can't be imported
|
||||
Plugin "product-id" can't be imported
|
||||
Plugin "search-disabled-repos" can't be imported
|
||||
Plugin "subscription-manager" can't be imported
|
||||
"""
|
||||
|
||||
# from https://github.com/ansible/ansible/issues/20608#issuecomment-276106505
|
||||
wrapped_output_1 = """
|
||||
Загружены модули: fastestmirror
|
||||
Loading mirror speeds from cached hostfile
|
||||
* base: mirror.h1host.ru
|
||||
* extras: mirror.h1host.ru
|
||||
* updates: mirror.h1host.ru
|
||||
|
||||
vms-agent.x86_64 0.0-9 dev
|
||||
"""
|
||||
|
||||
# from https://github.com/ansible/ansible/issues/20608#issuecomment-276971275
|
||||
wrapped_output_2 = """
|
||||
Загружены модули: fastestmirror
|
||||
Loading mirror speeds from cached hostfile
|
||||
* base: mirror.corbina.net
|
||||
* extras: mirror.corbina.net
|
||||
* updates: mirror.corbina.net
|
||||
|
||||
empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty.x86_64
|
||||
0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1-0
|
||||
addons
|
||||
libtiff.x86_64 4.0.3-27.el7_3 updates
|
||||
"""
|
||||
|
||||
# From https://github.com/ansible/ansible/issues/20608#issuecomment-276698431
|
||||
wrapped_output_3 = """
|
||||
Loaded plugins: fastestmirror, langpacks
|
||||
Loading mirror speeds from cached hostfile
|
||||
|
||||
ceph.x86_64 1:11.2.0-0.el7 ceph
|
||||
ceph-base.x86_64 1:11.2.0-0.el7 ceph
|
||||
ceph-common.x86_64 1:11.2.0-0.el7 ceph
|
||||
ceph-mds.x86_64 1:11.2.0-0.el7 ceph
|
||||
ceph-mon.x86_64 1:11.2.0-0.el7 ceph
|
||||
ceph-osd.x86_64 1:11.2.0-0.el7 ceph
|
||||
ceph-selinux.x86_64 1:11.2.0-0.el7 ceph
|
||||
libcephfs1.x86_64 1:11.0.2-0.el7 ceph
|
||||
librados2.x86_64 1:11.2.0-0.el7 ceph
|
||||
libradosstriper1.x86_64 1:11.2.0-0.el7 ceph
|
||||
librbd1.x86_64 1:11.2.0-0.el7 ceph
|
||||
librgw2.x86_64 1:11.2.0-0.el7 ceph
|
||||
python-cephfs.x86_64 1:11.2.0-0.el7 ceph
|
||||
python-rados.x86_64 1:11.2.0-0.el7 ceph
|
||||
python-rbd.x86_64 1:11.2.0-0.el7 ceph
|
||||
"""
|
||||
|
||||
# from https://github.com/ansible/ansible-modules-core/issues/4318#issuecomment-251416661
|
||||
wrapped_output_4 = """
|
||||
ipxe-roms-qemu.noarch 20160127-1.git6366fa7a.el7
|
||||
rhelosp-9.0-director-puddle
|
||||
quota.x86_64 1:4.01-11.el7_2.1 rhelosp-rhel-7.2-z
|
||||
quota-nls.noarch 1:4.01-11.el7_2.1 rhelosp-rhel-7.2-z
|
||||
rdma.noarch 7.2_4.1_rc6-2.el7 rhelosp-rhel-7.2-z
|
||||
screen.x86_64 4.1.0-0.23.20120314git3c2946.el7_2
|
||||
rhelosp-rhel-7.2-z
|
||||
sos.noarch 3.2-36.el7ost.2 rhelosp-9.0-puddle
|
||||
sssd-client.x86_64 1.13.0-40.el7_2.12 rhelosp-rhel-7.2-z
|
||||
"""
|
||||
|
||||
|
||||
# A 'normal-ish' yum check-update output, without any wrapped lines
|
||||
unwrapped_output_rhel7 = """
|
||||
|
||||
Loaded plugins: etckeeper, product-id, search-disabled-repos, subscription-
|
||||
: manager
|
||||
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
|
||||
|
||||
NetworkManager-openvpn.x86_64 1:1.2.6-1.el7 epel
|
||||
NetworkManager-openvpn-gnome.x86_64 1:1.2.6-1.el7 epel
|
||||
cabal-install.x86_64 1.16.1.0-2.el7 epel
|
||||
cgit.x86_64 1.1-1.el7 epel
|
||||
python34-libs.x86_64 3.4.5-3.el7 epel
|
||||
python34-test.x86_64 3.4.5-3.el7 epel
|
||||
python34-tkinter.x86_64 3.4.5-3.el7 epel
|
||||
python34-tools.x86_64 3.4.5-3.el7 epel
|
||||
qgit.x86_64 2.6-4.el7 epel
|
||||
rdiff-backup.x86_64 1.2.8-12.el7 epel
|
||||
stoken-libs.x86_64 0.91-1.el7 epel
|
||||
xlockmore.x86_64 5.49-2.el7 epel
|
||||
"""
|
||||
|
||||
# Some wrapped obsoletes for prepending to output for testing both
|
||||
wrapped_output_rhel7_obsoletes_postfix = """
|
||||
Obsoleting Packages
|
||||
ddashboard.x86_64 0.2.0.1-1.el7_3 mhlavink-developerdashboard
|
||||
developerdashboard.x86_64 0.1.12.2-1.el7_2 @mhlavink-developerdashboard
|
||||
python-bugzilla.noarch 1.2.2-3.el7_2.1 mhlavink-developerdashboard
|
||||
python-bugzilla-develdashboardfixes.noarch
|
||||
1.2.2-3.el7 @mhlavink-developerdashboard
|
||||
python2-futures.noarch 3.0.5-1.el7 epel
|
||||
python-futures.noarch 3.0.3-1.el7 @epel
|
||||
python2-pip.noarch 8.1.2-5.el7 epel
|
||||
python-pip.noarch 7.1.0-1.el7 @epel
|
||||
python2-pyxdg.noarch 0.25-6.el7 epel
|
||||
pyxdg.noarch 0.25-5.el7 @epel
|
||||
python2-simplejson.x86_64 3.10.0-1.el7 epel
|
||||
python-simplejson.x86_64 3.3.3-1.el7 @epel
|
||||
Security: kernel-3.10.0-327.28.2.el7.x86_64 is an installed security update
|
||||
Security: kernel-3.10.0-327.22.2.el7.x86_64 is the currently running version
|
||||
"""
|
||||
|
||||
wrapped_output_multiple_empty_lines = """
|
||||
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
|
||||
|
||||
This system is not registered with an entitlement server. You can use subscription-manager to register.
|
||||
|
||||
|
||||
screen.x86_64 4.1.0-0.23.20120314git3c2946.el7_2
|
||||
rhelosp-rhel-7.2-z
|
||||
sos.noarch 3.2-36.el7ost.2 rhelosp-9.0-puddle
|
||||
"""
|
||||
|
||||
longname = """
|
||||
Loaded plugins: fastestmirror, priorities, rhnplugin
|
||||
This system is receiving updates from RHN Classic or Red Hat Satellite.
|
||||
Loading mirror speeds from cached hostfile
|
||||
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxx.noarch
|
||||
1.16-1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
glibc.x86_64 2.17-157.el7_3.1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"""
|
||||
|
||||
|
||||
unwrapped_output_rhel7_obsoletes = unwrapped_output_rhel7 + wrapped_output_rhel7_obsoletes_postfix
|
||||
unwrapped_output_rhel7_expected_new_obsoletes_pkgs = [
|
||||
"ddashboard", "python-bugzilla", "python2-futures", "python2-pip",
|
||||
"python2-pyxdg", "python2-simplejson"
|
||||
]
|
||||
unwrapped_output_rhel7_expected_old_obsoletes_pkgs = [
|
||||
"developerdashboard", "python-bugzilla-develdashboardfixes",
|
||||
"python-futures", "python-pip", "pyxdg", "python-simplejson"
|
||||
]
|
||||
unwrapped_output_rhel7_expected_updated_pkgs = [
|
||||
"NetworkManager-openvpn", "NetworkManager-openvpn-gnome", "cabal-install",
|
||||
"cgit", "python34-libs", "python34-test", "python34-tkinter",
|
||||
"python34-tools", "qgit", "rdiff-backup", "stoken-libs", "xlockmore"
|
||||
]
|
||||
|
||||
|
||||
class TestYumUpdateCheckParse(unittest.TestCase):
|
||||
def _assert_expected(self, expected_pkgs, result):
|
||||
|
||||
for expected_pkg in expected_pkgs:
|
||||
self.assertIn(expected_pkg, result)
|
||||
self.assertEqual(len(result), len(expected_pkgs))
|
||||
self.assertIsInstance(result, dict)
|
||||
|
||||
def test_empty_output(self):
|
||||
res, obs = YumModule.parse_check_update("")
|
||||
expected_pkgs = []
|
||||
self._assert_expected(expected_pkgs, res)
|
||||
|
||||
def test_longname(self):
|
||||
res, obs = YumModule.parse_check_update(longname)
|
||||
expected_pkgs = ['xxxxxxxxxxxxxxxxxxxxxxxxxx', 'glibc']
|
||||
self._assert_expected(expected_pkgs, res)
|
||||
|
||||
def test_plugin_load_error(self):
|
||||
res, obs = YumModule.parse_check_update(yum_plugin_load_error)
|
||||
expected_pkgs = []
|
||||
self._assert_expected(expected_pkgs, res)
|
||||
|
||||
def test_wrapped_output_1(self):
|
||||
res, obs = YumModule.parse_check_update(wrapped_output_1)
|
||||
expected_pkgs = ["vms-agent"]
|
||||
self._assert_expected(expected_pkgs, res)
|
||||
|
||||
def test_wrapped_output_2(self):
|
||||
res, obs = YumModule.parse_check_update(wrapped_output_2)
|
||||
expected_pkgs = ["empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty",
|
||||
"libtiff"]
|
||||
|
||||
self._assert_expected(expected_pkgs, res)
|
||||
|
||||
def test_wrapped_output_3(self):
|
||||
res, obs = YumModule.parse_check_update(wrapped_output_3)
|
||||
expected_pkgs = ["ceph", "ceph-base", "ceph-common", "ceph-mds",
|
||||
"ceph-mon", "ceph-osd", "ceph-selinux", "libcephfs1",
|
||||
"librados2", "libradosstriper1", "librbd1", "librgw2",
|
||||
"python-cephfs", "python-rados", "python-rbd"]
|
||||
self._assert_expected(expected_pkgs, res)
|
||||
|
||||
def test_wrapped_output_4(self):
|
||||
res, obs = YumModule.parse_check_update(wrapped_output_4)
|
||||
|
||||
expected_pkgs = ["ipxe-roms-qemu", "quota", "quota-nls", "rdma", "screen",
|
||||
"sos", "sssd-client"]
|
||||
self._assert_expected(expected_pkgs, res)
|
||||
|
||||
def test_wrapped_output_rhel7(self):
|
||||
res, obs = YumModule.parse_check_update(unwrapped_output_rhel7)
|
||||
self._assert_expected(unwrapped_output_rhel7_expected_updated_pkgs, res)
|
||||
|
||||
def test_wrapped_output_rhel7_obsoletes(self):
|
||||
res, obs = YumModule.parse_check_update(unwrapped_output_rhel7_obsoletes)
|
||||
self._assert_expected(
|
||||
unwrapped_output_rhel7_expected_updated_pkgs + unwrapped_output_rhel7_expected_new_obsoletes_pkgs,
|
||||
res
|
||||
)
|
||||
self._assert_expected(unwrapped_output_rhel7_expected_old_obsoletes_pkgs, obs)
|
||||
|
||||
def test_wrapped_output_multiple_empty_lines(self):
|
||||
res, obs = YumModule.parse_check_update(wrapped_output_multiple_empty_lines)
|
||||
self._assert_expected(['screen', 'sos'], res)
|
Loading…
Reference in New Issue