Merge "Fix compatibility with Ansible 2.14"
This commit is contained in:
commit
c8d2fbb089
@ -16,7 +16,6 @@ __metaclass__ = type
|
|||||||
|
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
from ansible.plugins.callback.default import CallbackModule as BASE
|
from ansible.plugins.callback.default import CallbackModule as BASE
|
||||||
from ansible.plugins.callback.default import COMPAT_OPTIONS
|
|
||||||
|
|
||||||
|
|
||||||
class CallbackModule(BASE):
|
class CallbackModule(BASE):
|
||||||
@ -24,16 +23,6 @@ class CallbackModule(BASE):
|
|||||||
super(CallbackModule, self).set_options(task_keys=task_keys,
|
super(CallbackModule, self).set_options(task_keys=task_keys,
|
||||||
var_options=var_options,
|
var_options=var_options,
|
||||||
direct=direct)
|
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):
|
def v2_runner_retry(self, result):
|
||||||
task_name = result.task_name or result._task
|
task_name = result.task_name or result._task
|
||||||
|
@ -88,7 +88,7 @@ class CallbackModule(DefaultCallback):
|
|||||||
line.append(host_str)
|
line.append(host_str)
|
||||||
color = C.COLOR_CHANGED
|
color = C.COLOR_CHANGED
|
||||||
else:
|
else:
|
||||||
if not self.display_ok_hosts:
|
if not self.get_option('display_ok_hosts'):
|
||||||
return (None, None)
|
return (None, None)
|
||||||
line.append(self._get_state('OK'))
|
line.append(self._get_state('OK'))
|
||||||
line.append(self._get_task_name(result))
|
line.append(self._get_task_name(result))
|
||||||
|
@ -130,13 +130,20 @@ class TripleoBase(StrategyBase):
|
|||||||
failures[role] = 1
|
failures[role] = 1
|
||||||
return failures
|
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):
|
def _get_task_errors_fatal(self, task, templar):
|
||||||
"""Return parsed any_errors_fatal from a task"""
|
"""Return parsed any_errors_fatal from a task"""
|
||||||
return task.get_validated_value('any_errors_fatal',
|
return task.get_validated_value(
|
||||||
task._valid_attrs['any_errors_fatal'],
|
'any_errors_fatal',
|
||||||
templar.template(
|
self._get_task_attr(task, 'any_errors_fatal'),
|
||||||
task.any_errors_fatal),
|
templar.template(task.any_errors_fatal),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
def process_includes(self, host_results, noop=False):
|
def process_includes(self, host_results, noop=False):
|
||||||
"""Handle includes
|
"""Handle includes
|
||||||
|
@ -19,7 +19,8 @@ import time
|
|||||||
|
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
from ansible.errors import AnsibleAssertionError
|
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.block import Block
|
||||||
from ansible.playbook.task import Task
|
from ansible.playbook.task import Task
|
||||||
from ansible.template import Templar
|
from ansible.template import Templar
|
||||||
@ -126,7 +127,7 @@ class StrategyModule(BASE.TripleoBase):
|
|||||||
lowest_cur_block = min(
|
lowest_cur_block = min(
|
||||||
(self._iterator.get_active_state(s).cur_block
|
(self._iterator.get_active_state(s).cur_block
|
||||||
for h, (s, t) in host_tasks_to_run
|
for h, (s, t) in host_tasks_to_run
|
||||||
if s.run_state != PlayIterator.ITERATING_COMPLETE))
|
if s.run_state != IteratingStates.COMPLETE))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
lowest_cur_block = None
|
lowest_cur_block = None
|
||||||
else:
|
else:
|
||||||
@ -140,10 +141,10 @@ class StrategyModule(BASE.TripleoBase):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# count up tasks based on state, we only care about:
|
# count up tasks based on state, we only care about:
|
||||||
# PlayIterator.ITERATING_SETUP
|
# IteratingStates.SETUP
|
||||||
# PlayIterator.ITERATING_TASKS
|
# IteratingStates.TASKS
|
||||||
# PlayIterator.ITERATING_RESCUE
|
# IteratingStates.RESCUE
|
||||||
# PlayIterator.ITERATING_ALWAYS
|
# IteratingStates.ALWAYS
|
||||||
if not task_counts.get(s.run_state):
|
if not task_counts.get(s.run_state):
|
||||||
task_counts[s.run_state] = 1
|
task_counts[s.run_state] = 1
|
||||||
else:
|
else:
|
||||||
@ -153,10 +154,10 @@ class StrategyModule(BASE.TripleoBase):
|
|||||||
# to execute them in a specific order. If there are tasks
|
# to execute them in a specific order. If there are tasks
|
||||||
# in that state, we run all those tasks and then noop the
|
# in that state, we run all those tasks and then noop the
|
||||||
# rest of the hosts with tasks not currently in that state
|
# rest of the hosts with tasks not currently in that state
|
||||||
for state_type in [PlayIterator.ITERATING_SETUP,
|
for state_type in [IteratingStates.SETUP,
|
||||||
PlayIterator.ITERATING_TASKS,
|
IteratingStates.TASKS,
|
||||||
PlayIterator.ITERATING_RESCUE,
|
IteratingStates.RESCUE,
|
||||||
PlayIterator.ITERATING_ALWAYS]:
|
IteratingStates.ALWAYS]:
|
||||||
if state_type in task_counts:
|
if state_type in task_counts:
|
||||||
return self._advance_hosts(hosts,
|
return self._advance_hosts(hosts,
|
||||||
host_tasks,
|
host_tasks,
|
||||||
@ -261,15 +262,15 @@ class StrategyModule(BASE.TripleoBase):
|
|||||||
def _process_failures(self):
|
def _process_failures(self):
|
||||||
"""Handle failures"""
|
"""Handle failures"""
|
||||||
self._debug('_process_failures...')
|
self._debug('_process_failures...')
|
||||||
non_fail_states = frozenset([self._iterator.ITERATING_RESCUE,
|
non_fail_states = frozenset([IteratingStates.RESCUE,
|
||||||
self._iterator.ITERATING_ALWAYS])
|
IteratingStates.ALWAYS])
|
||||||
result = self._tqm.RUN_OK
|
result = self._tqm.RUN_OK
|
||||||
for host in self._hosts_left:
|
for host in self._hosts_left:
|
||||||
(s, _) = self._iterator.get_next_task_for_host(host, peek=True)
|
(s, _) = self._iterator.get_next_task_for_host(host, peek=True)
|
||||||
s = self._iterator.get_active_state(s)
|
s = self._iterator.get_active_state(s)
|
||||||
if ((s.run_state not in non_fail_states)
|
if ((s.run_state not in non_fail_states)
|
||||||
or (s.run_state == self._iterator.ITERATING_RESCUE
|
or (s.run_state == IteratingStates.RESCUE
|
||||||
and s.fail_state & self._iterator.FAILED_RESCUE != 0)):
|
and s.fail_state & FailedStates.RESCUE != 0)):
|
||||||
self._tqm._failed_hosts[host.name] = True
|
self._tqm._failed_hosts[host.name] = True
|
||||||
result |= self._tqm.RUN_FAILED_BREAK_PLAY
|
result |= self._tqm.RUN_FAILED_BREAK_PLAY
|
||||||
return result
|
return result
|
||||||
|
@ -39,8 +39,6 @@
|
|||||||
|
|
||||||
- name: Remove previous fernet keys
|
- name: Remove previous fernet keys
|
||||||
shell: rm -rf /var/lib/config-data/puppet-generated/keystone/etc/keystone/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
|
- name: Persist fernet keys to repository
|
||||||
copy:
|
copy:
|
||||||
@ -71,8 +69,6 @@
|
|||||||
block:
|
block:
|
||||||
- name: Remove previous fernet keys
|
- name: Remove previous fernet keys
|
||||||
shell: rm -rf /etc/keystone/fernet-keys/*
|
shell: rm -rf /etc/keystone/fernet-keys/*
|
||||||
args:
|
|
||||||
warn: false
|
|
||||||
|
|
||||||
- name: Persist fernet keys to repository
|
- name: Persist fernet keys to repository
|
||||||
copy:
|
copy:
|
||||||
|
@ -85,7 +85,5 @@
|
|||||||
rm -rf /tmp/rear.* || true
|
rm -rf /tmp/rear.* || true
|
||||||
rm -rf /var/lib/rear/output/*
|
rm -rf /var/lib/rear/output/*
|
||||||
failed_when: false
|
failed_when: false
|
||||||
args:
|
|
||||||
warn: false
|
|
||||||
tags:
|
tags:
|
||||||
- bar_create_recover_image
|
- bar_create_recover_image
|
||||||
|
@ -40,8 +40,6 @@
|
|||||||
block:
|
block:
|
||||||
- name: Check release version package is installed
|
- name: Check release version package is installed
|
||||||
command: "rpm -q --whatprovides {{ tripleo_bootstrap_release_version_package | join(' ') }}"
|
command: "rpm -q --whatprovides {{ tripleo_bootstrap_release_version_package | join(' ') }}"
|
||||||
args:
|
|
||||||
warn: false
|
|
||||||
register: rpm_query_result
|
register: rpm_query_result
|
||||||
failed_when: false
|
failed_when: false
|
||||||
- name: Deploy release version package
|
- name: Deploy release version package
|
||||||
@ -79,8 +77,6 @@
|
|||||||
block:
|
block:
|
||||||
- name: Check required legacy network packages for bootstrap TripleO is installed
|
- name: Check required legacy network packages for bootstrap TripleO is installed
|
||||||
command: "rpm -q --whatprovides {{ tripleo_bootstrap_legacy_network_packages | join(' ') }}"
|
command: "rpm -q --whatprovides {{ tripleo_bootstrap_legacy_network_packages | join(' ') }}"
|
||||||
args:
|
|
||||||
warn: false
|
|
||||||
register: rpm_query_result
|
register: rpm_query_result
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
|
@ -38,8 +38,6 @@
|
|||||||
|
|
||||||
- name: Check required packages to bootstrap TripleO is installed
|
- name: Check required packages to bootstrap TripleO is installed
|
||||||
command: "rpm -q --whatprovides {{ tripleo_bootstrap_packages_bootstrap | join(' ') }}"
|
command: "rpm -q --whatprovides {{ tripleo_bootstrap_packages_bootstrap | join(' ') }}"
|
||||||
args:
|
|
||||||
warn: false
|
|
||||||
register: rpm_query_result
|
register: rpm_query_result
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
become: true
|
become: true
|
||||||
shell: >-
|
shell: >-
|
||||||
ln -f -s /usr/share/openstack-puppet/modules/* /etc/puppet/modules/
|
ln -f -s /usr/share/openstack-puppet/modules/* /etc/puppet/modules/
|
||||||
args:
|
|
||||||
warn: false
|
|
||||||
register: result
|
register: result
|
||||||
failed_when: false
|
failed_when: false
|
||||||
tags:
|
tags:
|
||||||
|
@ -203,8 +203,6 @@
|
|||||||
--nopostun \
|
--nopostun \
|
||||||
--notriggers \
|
--notriggers \
|
||||||
--nodeps $(rpm -qa 'openvswitch{{ package_suffix|default('') }}*' | grep -v 'selinux')
|
--nodeps $(rpm -qa 'openvswitch{{ package_suffix|default('') }}*' | grep -v 'selinux')
|
||||||
args:
|
|
||||||
warn: false
|
|
||||||
when:
|
when:
|
||||||
- new_ovs_version != current_ovs_version
|
- new_ovs_version != current_ovs_version
|
||||||
|
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
- name: Check tuned package is installed
|
- name: Check tuned package is installed
|
||||||
command: "rpm -q --whatprovides {{ tuned_system_packages }}"
|
command: "rpm -q --whatprovides {{ tuned_system_packages }}"
|
||||||
args:
|
|
||||||
warn: false
|
|
||||||
register: rpm_query_result
|
register: rpm_query_result
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user