Merge "Fix compatibility with Ansible 2.14"

This commit is contained in:
Zuul 2022-11-16 08:15:11 +00:00 committed by Gerrit Code Review
commit c8d2fbb089
11 changed files with 28 additions and 49 deletions

View File

@ -16,7 +16,6 @@ __metaclass__ = type
from ansible import constants as C
from ansible.plugins.callback.default import CallbackModule as BASE
from ansible.plugins.callback.default import COMPAT_OPTIONS
class CallbackModule(BASE):
@ -24,16 +23,6 @@ class CallbackModule(BASE):
super(CallbackModule, self).set_options(task_keys=task_keys,
var_options=var_options,
direct=direct)
# NOTE(mwhahaha): work around for bug in ansible's default callback
# where it sets the attr on the object but not in the plugin options
# for the compatibility options. Need to submit this upstream.
for option, constant in COMPAT_OPTIONS:
try:
value = self.get_option(option)
except (AttributeError, KeyError):
value = constant
if option not in self._plugin_options:
self._plugin_options[option] = value
def v2_runner_retry(self, result):
task_name = result.task_name or result._task

View File

@ -88,7 +88,7 @@ class CallbackModule(DefaultCallback):
line.append(host_str)
color = C.COLOR_CHANGED
else:
if not self.display_ok_hosts:
if not self.get_option('display_ok_hosts'):
return (None, None)
line.append(self._get_state('OK'))
line.append(self._get_task_name(result))

View File

@ -130,12 +130,19 @@ class TripleoBase(StrategyBase):
failures[role] = 1
return failures
def _get_task_attr(self, task, name):
# Ansible < 2.14 replaced _valid_attrs by FieldAttributes
# https://github.com/ansible/ansible/pull/73908
if hasattr(task, 'fattributes'):
return task.fattributes.get(name)
return task._valid_attrs[name]
def _get_task_errors_fatal(self, task, templar):
"""Return parsed any_errors_fatal from a task"""
return task.get_validated_value('any_errors_fatal',
task._valid_attrs['any_errors_fatal'],
templar.template(
task.any_errors_fatal),
return task.get_validated_value(
'any_errors_fatal',
self._get_task_attr(task, 'any_errors_fatal'),
templar.template(task.any_errors_fatal),
None)
def process_includes(self, host_results, noop=False):

View File

@ -19,7 +19,8 @@ import time
from ansible import constants as C
from ansible.errors import AnsibleAssertionError
from ansible.executor.play_iterator import PlayIterator
from ansible.executor.play_iterator import FailedStates
from ansible.executor.play_iterator import IteratingStates
from ansible.playbook.block import Block
from ansible.playbook.task import Task
from ansible.template import Templar
@ -126,7 +127,7 @@ class StrategyModule(BASE.TripleoBase):
lowest_cur_block = min(
(self._iterator.get_active_state(s).cur_block
for h, (s, t) in host_tasks_to_run
if s.run_state != PlayIterator.ITERATING_COMPLETE))
if s.run_state != IteratingStates.COMPLETE))
except ValueError:
lowest_cur_block = None
else:
@ -140,10 +141,10 @@ class StrategyModule(BASE.TripleoBase):
continue
# count up tasks based on state, we only care about:
# PlayIterator.ITERATING_SETUP
# PlayIterator.ITERATING_TASKS
# PlayIterator.ITERATING_RESCUE
# PlayIterator.ITERATING_ALWAYS
# IteratingStates.SETUP
# IteratingStates.TASKS
# IteratingStates.RESCUE
# IteratingStates.ALWAYS
if not task_counts.get(s.run_state):
task_counts[s.run_state] = 1
else:
@ -153,10 +154,10 @@ class StrategyModule(BASE.TripleoBase):
# to execute them in a specific order. If there are tasks
# in that state, we run all those tasks and then noop the
# rest of the hosts with tasks not currently in that state
for state_type in [PlayIterator.ITERATING_SETUP,
PlayIterator.ITERATING_TASKS,
PlayIterator.ITERATING_RESCUE,
PlayIterator.ITERATING_ALWAYS]:
for state_type in [IteratingStates.SETUP,
IteratingStates.TASKS,
IteratingStates.RESCUE,
IteratingStates.ALWAYS]:
if state_type in task_counts:
return self._advance_hosts(hosts,
host_tasks,
@ -261,15 +262,15 @@ class StrategyModule(BASE.TripleoBase):
def _process_failures(self):
"""Handle failures"""
self._debug('_process_failures...')
non_fail_states = frozenset([self._iterator.ITERATING_RESCUE,
self._iterator.ITERATING_ALWAYS])
non_fail_states = frozenset([IteratingStates.RESCUE,
IteratingStates.ALWAYS])
result = self._tqm.RUN_OK
for host in self._hosts_left:
(s, _) = self._iterator.get_next_task_for_host(host, peek=True)
s = self._iterator.get_active_state(s)
if ((s.run_state not in non_fail_states)
or (s.run_state == self._iterator.ITERATING_RESCUE
and s.fail_state & self._iterator.FAILED_RESCUE != 0)):
or (s.run_state == IteratingStates.RESCUE
and s.fail_state & FailedStates.RESCUE != 0)):
self._tqm._failed_hosts[host.name] = True
result |= self._tqm.RUN_FAILED_BREAK_PLAY
return result

View File

@ -39,8 +39,6 @@
- name: Remove previous fernet keys
shell: rm -rf /var/lib/config-data/puppet-generated/keystone/etc/keystone/fernet-keys/*
args:
warn: false
- name: Persist fernet keys to repository
copy:
@ -71,8 +69,6 @@
block:
- name: Remove previous fernet keys
shell: rm -rf /etc/keystone/fernet-keys/*
args:
warn: false
- name: Persist fernet keys to repository
copy:

View File

@ -85,7 +85,5 @@
rm -rf /tmp/rear.* || true
rm -rf /var/lib/rear/output/*
failed_when: false
args:
warn: false
tags:
- bar_create_recover_image

View File

@ -40,8 +40,6 @@
block:
- name: Check release version package is installed
command: "rpm -q --whatprovides {{ tripleo_bootstrap_release_version_package | join(' ') }}"
args:
warn: false
register: rpm_query_result
failed_when: false
- name: Deploy release version package
@ -79,8 +77,6 @@
block:
- name: Check required legacy network packages for bootstrap TripleO is installed
command: "rpm -q --whatprovides {{ tripleo_bootstrap_legacy_network_packages | join(' ') }}"
args:
warn: false
register: rpm_query_result
failed_when: false

View File

@ -38,8 +38,6 @@
- name: Check required packages to bootstrap TripleO is installed
command: "rpm -q --whatprovides {{ tripleo_bootstrap_packages_bootstrap | join(' ') }}"
args:
warn: false
register: rpm_query_result
failed_when: false

View File

@ -18,8 +18,6 @@
become: true
shell: >-
ln -f -s /usr/share/openstack-puppet/modules/* /etc/puppet/modules/
args:
warn: false
register: result
failed_when: false
tags:

View File

@ -203,8 +203,6 @@
--nopostun \
--notriggers \
--nodeps $(rpm -qa 'openvswitch{{ package_suffix|default('') }}*' | grep -v 'selinux')
args:
warn: false
when:
- new_ovs_version != current_ovs_version

View File

@ -16,8 +16,6 @@
- name: Check tuned package is installed
command: "rpm -q --whatprovides {{ tuned_system_packages }}"
args:
warn: false
register: rpm_query_result
failed_when: false