From df1001577f68a319a2594de0bb993ec4e91c2068 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 3 May 2018 18:29:47 -0400 Subject: [PATCH] rebase base playbook base (#39533) * rebase base playbook base fixes issues with loop control allowing generic attributes it shouldn't --- lib/ansible/playbook/base.py | 69 +++++++++++++++------------- lib/ansible/playbook/loop_control.py | 5 +- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/lib/ansible/playbook/base.py b/lib/ansible/playbook/base.py index 74abae4b0bf..16669d83b4e 100644 --- a/lib/ansible/playbook/base.py +++ b/lib/ansible/playbook/base.py @@ -140,39 +140,7 @@ class BaseMeta(type): return super(BaseMeta, cls).__new__(cls, name, parents, dct) -class Base(with_metaclass(BaseMeta, object)): - - _name = FieldAttribute(isa='string', default='', always_post_validate=True, inherit=False) - - # connection/transport - _connection = FieldAttribute(isa='string') - _port = FieldAttribute(isa='int') - _remote_user = FieldAttribute(isa='string') - - # variables - _vars = FieldAttribute(isa='dict', priority=100, inherit=False) - - # module default params - _module_defaults = FieldAttribute(isa='list', extend=True, prepend=True) - - # flags and misc. settings - _environment = FieldAttribute(isa='list', extend=True, prepend=True) - _no_log = FieldAttribute(isa='bool') - _always_run = FieldAttribute(isa='bool') - _run_once = FieldAttribute(isa='bool') - _ignore_errors = FieldAttribute(isa='bool') - _check_mode = FieldAttribute(isa='bool') - _diff = FieldAttribute(isa='bool') - _any_errors_fatal = FieldAttribute(isa='bool') - - # explicitly invoke a debugger on tasks - _debugger = FieldAttribute(isa='string') - - # param names which have been deprecated/removed - DEPRECATED_ATTRIBUTES = [ - 'sudo', 'sudo_user', 'sudo_pass', 'sudo_exe', 'sudo_flags', - 'su', 'su_user', 'su_pass', 'su_exe', 'su_flags', - ] +class FieldAttributeBase(with_metaclass(BaseMeta, object)): def __init__(self): @@ -590,3 +558,38 @@ class Base(with_metaclass(BaseMeta, object)): setattr(self, '_uuid', data.get('uuid')) self._finalized = data.get('finalized', False) self._squashed = data.get('squashed', False) + + +class Base(FieldAttributeBase): + + _name = FieldAttribute(isa='string', default='', always_post_validate=True, inherit=False) + + # connection/transport + _connection = FieldAttribute(isa='string') + _port = FieldAttribute(isa='int') + _remote_user = FieldAttribute(isa='string') + + # variables + _vars = FieldAttribute(isa='dict', priority=100, inherit=False) + + # module default params + _module_defaults = FieldAttribute(isa='list', extend=True, prepend=True) + + # flags and misc. settings + _environment = FieldAttribute(isa='list', extend=True, prepend=True) + _no_log = FieldAttribute(isa='bool') + _always_run = FieldAttribute(isa='bool') + _run_once = FieldAttribute(isa='bool') + _ignore_errors = FieldAttribute(isa='bool') + _check_mode = FieldAttribute(isa='bool') + _diff = FieldAttribute(isa='bool') + _any_errors_fatal = FieldAttribute(isa='bool') + + # explicitly invoke a debugger on tasks + _debugger = FieldAttribute(isa='string') + + # param names which have been deprecated/removed + DEPRECATED_ATTRIBUTES = [ + 'sudo', 'sudo_user', 'sudo_pass', 'sudo_exe', 'sudo_flags', + 'su', 'su_user', 'su_pass', 'su_exe', 'su_flags', + ] diff --git a/lib/ansible/playbook/loop_control.py b/lib/ansible/playbook/loop_control.py index 59594b31f94..366d9cdaa4f 100644 --- a/lib/ansible/playbook/loop_control.py +++ b/lib/ansible/playbook/loop_control.py @@ -20,11 +20,10 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type from ansible.playbook.attribute import FieldAttribute -from ansible.playbook.base import Base +from ansible.playbook.base import FieldAttributeBase -# FIXME: loopcontrol should not inherit attributes from base, just uses it for load -class LoopControl(Base): +class LoopControl(FieldAttributeBase): _loop_var = FieldAttribute(isa='str', default='item') _index_var = FieldAttribute(isa='str')