Server IP : 85.214.239.14 / Your IP : 52.14.26.141 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/self/root/proc/2/root/proc/3/cwd/usr/lib/python3/dist-packages/ansible/vars/ |
Upload File : |
# (c) 2017 Ansible By Red Hat # # 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/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type from ansible.playbook import Play from ansible.playbook.block import Block from ansible.playbook.role import Role from ansible.playbook.task import Task from ansible.utils.display import Display display = Display() def get_reserved_names(include_private=True): ''' this function returns the list of reserved names associated with play objects''' public = set() private = set() result = set() # FIXME: find a way to 'not hardcode', possibly need role deps/includes class_list = [Play, Role, Block, Task] for aclass in class_list: # build ordered list to loop over and dict with attributes for name, attr in aclass.fattributes.items(): if attr.private: private.add(name) else: public.add(name) # local_action is implicit with action if 'action' in public: public.add('local_action') # loop implies with_ # FIXME: remove after with_ is not only deprecated but removed if 'loop' in private or 'loop' in public: public.add('with_') if include_private: result = public.union(private) else: result = public return result def warn_if_reserved(myvars, additional=None): ''' this function warns if any variable passed conflicts with internally reserved names ''' if additional is None: reserved = _RESERVED_NAMES else: reserved = _RESERVED_NAMES.union(additional) varnames = set(myvars) varnames.discard('vars') # we add this one internally, so safe to ignore for varname in varnames.intersection(reserved): display.warning('Found variable using reserved name: %s' % varname) def is_reserved_name(name): return name in _RESERVED_NAMES _RESERVED_NAMES = frozenset(get_reserved_names())