From 3ca654ad9ade1ce2745f4b3496d3a1683ace2ce5 Mon Sep 17 00:00:00 2001 From: Strahinja Kustudic Date: Sun, 5 Oct 2014 19:54:31 +0200 Subject: [PATCH 01/12] Added an example for paretheses --- docsite/rst/playbooks_conditionals.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docsite/rst/playbooks_conditionals.rst b/docsite/rst/playbooks_conditionals.rst index a00ec916c41..cdaf54f5ea4 100644 --- a/docsite/rst/playbooks_conditionals.rst +++ b/docsite/rst/playbooks_conditionals.rst @@ -26,6 +26,14 @@ It's actually pretty simple:: command: /sbin/shutdown -t now when: ansible_os_family == "Debian" +You can also use parentheses to group conditions:: + + tasks: + - name: "shutdown CentOS 6 and 7 systems" + command: /sbin/shutdown -t now + when: ansible_distribution == "CentOS" and + (ansible_distribution_major_version == "6" or ansible_distribution_major_version == "7") + A number of Jinja2 "filters" can also be used in when statements, some of which are unique and provided by Ansible. Suppose we want to ignore the error of one statement and then decide to do something conditionally based on success or failure:: From c4144b1391b7df465160e8d5f365bbd163761b37 Mon Sep 17 00:00:00 2001 From: David Mahler Date: Sun, 22 Feb 2015 19:28:16 +0000 Subject: [PATCH 02/12] Some grammatical updates --- docsite/rst/intro.rst | 2 +- docsite/rst/intro_getting_started.rst | 33 +++++++++++++-------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/docsite/rst/intro.rst b/docsite/rst/intro.rst index 9b30a18bbb7..7976462383c 100644 --- a/docsite/rst/intro.rst +++ b/docsite/rst/intro.rst @@ -1,7 +1,7 @@ Introduction ============ -Before we dive into the really fun parts -- playbooks, configuration management, deployment, and orchestration, we'll learn how to get Ansible installed and some basic concepts. We'll go over how to execute ad-hoc commands in parallel across your nodes using /usr/bin/ansible. We'll also see what sort of modules are available in Ansible's core (though you can also write your own, which we'll also show later). +Before we dive into the really fun parts -- playbooks, configuration management, deployment, and orchestration, we'll learn how to get Ansible installed and cover some basic concepts. We'll also go over how to execute ad-hoc commands in parallel across your nodes using /usr/bin/ansible. Additionally, we'll see what sort of modules are available in Ansible's core (though you can also write your own, which is also covered later). .. toctree:: :maxdepth: 1 diff --git a/docsite/rst/intro_getting_started.rst b/docsite/rst/intro_getting_started.rst index 67136036479..c1cd5571e6d 100644 --- a/docsite/rst/intro_getting_started.rst +++ b/docsite/rst/intro_getting_started.rst @@ -11,10 +11,10 @@ Foreword Now that you've read :doc:`intro_installation` and installed Ansible, it's time to dig in and get started with some commands. -What we are showing first are not the powerful configuration/deployment/orchestration of Ansible, called playbooks. -Playbooks are covered in a separate section. +What we are showing first are not the powerful configuration/deployment/orchestration features of Ansible. +These features are handled by playbooks which are covered in a separate section. -This section is about how to get going initially. Once you have these concepts down, read :doc:`intro_adhoc` for some more +This section is about how to initially get going. Once you have these concepts down, read :doc:`intro_adhoc` for some more detail, and then you'll be ready to dive into playbooks and explore the most interesting parts! .. _remote_connection_information: @@ -22,21 +22,20 @@ detail, and then you'll be ready to dive into playbooks and explore the most int Remote Connection Information ````````````````````````````` -Before we get started, it's important to understand how Ansible is communicating with remote +Before we get started, it's important to understand how Ansible communicates with remote machines over SSH. By default, Ansible 1.3 and later will try to use native -OpenSSH for remote communication when possible. This enables both ControlPersist (a performance feature), Kerberos, and options in ~/.ssh/config such as Jump Host setup. When using Enterprise Linux 6 operating systems as the control machine (Red Hat Enterprise Linux and derivatives such as CentOS), however, the version of OpenSSH may be too old to support ControlPersist. On these operating systems, Ansible will fallback into using a high-quality Python implementation of +OpenSSH for remote communication when possible. This enables ControlPersist (a performance feature), Kerberos, and options in ~/.ssh/config such as Jump Host setup. However, when using Enterprise Linux 6 operating systems as the control machine (Red Hat Enterprise Linux and derivatives such as CentOS), the version of OpenSSH may be too old to support ControlPersist. On these operating systems, Ansible will fallback into using a high-quality Python implementation of OpenSSH called 'paramiko'. If you wish to use features like Kerberized SSH and more, consider using Fedora, OS X, or Ubuntu as your control machine until a newer version of OpenSSH is available for your platform -- or engage 'accelerated mode' in Ansible. See :doc:`playbooks_acceleration`. -In Ansible 1.2 and before, the default was strictly paramiko and native SSH had to be explicitly selected with -c ssh or set in the configuration file. +In releases up to and including Ansible 1.2, the default was strictly paramiko. Native SSH had to be explicitly selected with the -c ssh option or set in the configuration file. -Occasionally you'll encounter a device that doesn't do SFTP. This is rare, but if talking with some remote devices that don't support SFTP, you can switch to SCP mode in :doc:`intro_configuration`. +Occasionally you'll encounter a device that doesn't support SFTP. This is rare, but should it occur, you can switch to SCP mode in :doc:`intro_configuration`. -When speaking with remote machines, Ansible will by default assume you are using SSH keys -- which we encourage -- but passwords are fine too. To enable password auth, supply the option ``--ask-pass`` where needed. If using sudo features and when sudo requires a password, also supply ``--ask-sudo-pass`` as appropriate. +When speaking with remote machines, Ansible by default assumes you are using SSH keys. SSH keys are encouraged but password authentication can also be used where needed by supplying the option ``--ask-pass``. If using sudo features and when sudo requires a password, also supply ``--ask-sudo-pass``. -While it may be common sense, it is worth sharing: Any management system benefits from being run near the machines being managed. If running in a cloud, consider running Ansible from a machine inside that cloud. It will work better than on the open -internet in most cases. +While it may be common sense, it is worth sharing: Any management system benefits from being run near the machines being managed. If you are running Ansible in a cloud, consider running it from a machine inside that cloud. In most cases this will work better than on the open Internet. As an advanced topic, Ansible doesn't just have to connect remotely over SSH. The transports are pluggable, and there are options for managing things locally, as well as managing chroot, lxc, and jail containers. A mode called 'ansible-pull' can also invert the system and have systems 'phone home' via scheduled git checkouts to pull configuration directives from a central repository. @@ -47,8 +46,8 @@ Your first commands Now that you've installed Ansible, it's time to get started with some basics. -Edit (or create) /etc/ansible/hosts and put one or more remote systems in it, for -which you have your SSH key in ``authorized_keys``:: +Edit (or create) /etc/ansible/hosts and put one or more remote systems in it. Your +public SSH key should be located in ``authorized_keys`` on those systems:: 192.168.1.50 aserver.example.org @@ -95,9 +94,9 @@ Now run a live command on all of your nodes: $ ansible all -a "/bin/echo hello" -Congratulations. You've just contacted your nodes with Ansible. It's -soon going to be time to read some of the more real-world :doc:`intro_adhoc`, and explore -what you can do with different modules, as well as the Ansible +Congratulations! You've just contacted your nodes with Ansible. It's +soon going to be time to: read about some more real-world cases in :doc:`intro_adhoc`, +explore what you can do with different modules, and to learn about the Ansible :doc:`playbooks` language. Ansible is not just about running commands, it also has powerful configuration management and deployment features. There's more to explore, but you already have a fully working infrastructure! @@ -111,7 +110,7 @@ Ansible 1.2.1 and later have host key checking enabled by default. If a host is reinstalled and has a different key in 'known_hosts', this will result in an error message until corrected. If a host is not initially in 'known_hosts' this will result in prompting for confirmation of the key, which results in an interactive experience if using Ansible, from say, cron. You might not want this. -If you wish to disable this behavior and understand the implications, you can do so by editing /etc/ansible/ansible.cfg or ~/.ansible.cfg:: +If you understand the implications and wish to disable this behavior, you can do so by editing /etc/ansible/ansible.cfg or ~/.ansible.cfg:: [defaults] host_key_checking = False @@ -126,7 +125,7 @@ Also note that host key checking in paramiko mode is reasonably slow, therefore .. _a_note_about_logging: -Ansible will log some information about module arguments on the remote system in the remote syslog, unless a task or play is marked with a "no_log: True" attribute, explained later. +Ansible will log some information about module arguments on the remote system in the remote syslog, unless a task or play is marked with a "no_log: True" attribute. This is explained later. To enable basic logging on the control machine see :doc:`intro_configuration` document and set the 'log_path' configuration file setting. Enterprise users may also be interested in :doc:`tower`. Tower provides a very robust database logging feature where it is possible to drill down and see history based on hosts, projects, and particular inventories over time -- explorable both graphically and through a REST API. From b193d327b616da2774ce4293aa52539fbd61b6ef Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Mon, 13 Apr 2015 12:17:07 -0400 Subject: [PATCH 03/12] Fix re import failure in templates module when running unit tests. --- v2/ansible/template/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/v2/ansible/template/__init__.py b/v2/ansible/template/__init__.py index 0345a750081..4e15e83424c 100644 --- a/v2/ansible/template/__init__.py +++ b/v2/ansible/template/__init__.py @@ -19,6 +19,8 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type +import re + from jinja2 import Environment from jinja2.exceptions import TemplateSyntaxError, UndefinedError from jinja2.utils import concat as j2_concat From 6747f825476e7e82c315fbbef29794bc8d0026e6 Mon Sep 17 00:00:00 2001 From: ian Date: Mon, 13 Apr 2015 12:35:20 -0400 Subject: [PATCH 04/12] Change exceptions to python3 syntax. --- v2/ansible/playbook/base.py | 4 ++-- v2/ansible/plugins/__init__.py | 2 +- v2/ansible/plugins/action/__init__.py | 4 ++-- v2/ansible/plugins/action/copy.py | 6 +++--- v2/ansible/plugins/action/pause.py | 2 +- v2/ansible/plugins/action/template.py | 2 +- v2/ansible/plugins/connections/accelerate.py | 2 +- v2/ansible/plugins/connections/paramiko_ssh.py | 8 ++++---- v2/ansible/plugins/connections/winrm.py | 2 +- v2/ansible/plugins/lookup/csvfile.py | 4 ++-- v2/ansible/plugins/lookup/dnstxt.py | 2 +- v2/ansible/plugins/lookup/first_found.py | 2 +- v2/ansible/plugins/lookup/password.py | 4 ++-- v2/ansible/plugins/lookup/url.py | 4 ++-- v2/ansible/plugins/strategies/__init__.py | 2 +- v2/ansible/plugins/strategies/free.py | 2 +- v2/ansible/template/safe_eval.py | 4 ++-- v2/ansible/utils/hashing.py | 2 +- v2/ansible/utils/vault.py | 4 ++-- v2/ansible/vars/__init__.py | 2 +- v2/samples/multi.py | 4 ++-- v2/samples/multi_queues.py | 8 ++++---- 22 files changed, 38 insertions(+), 38 deletions(-) diff --git a/v2/ansible/playbook/base.py b/v2/ansible/playbook/base.py index e834d3b7296..c6a9d9a0513 100644 --- a/v2/ansible/playbook/base.py +++ b/v2/ansible/playbook/base.py @@ -270,9 +270,9 @@ class Base: # and assign the massaged value back to the attribute field setattr(self, name, value) - except (TypeError, ValueError), e: + except (TypeError, ValueError) as e: raise AnsibleParserError("the field '%s' has an invalid value (%s), and could not be converted to an %s. Error was: %s" % (name, value, attribute.isa, e), obj=self.get_ds()) - except UndefinedError, e: + except UndefinedError as e: if fail_on_undefined: raise AnsibleParserError("the field '%s' has an invalid value, which appears to include a variable that is undefined. The error was: %s" % (name,e), obj=self.get_ds()) diff --git a/v2/ansible/plugins/__init__.py b/v2/ansible/plugins/__init__.py index a55059f1b7b..d16eecd3c39 100644 --- a/v2/ansible/plugins/__init__.py +++ b/v2/ansible/plugins/__init__.py @@ -180,7 +180,7 @@ class PluginLoader: if os.path.isdir(path): try: full_paths = (os.path.join(path, f) for f in os.listdir(path)) - except OSError,e: + except OSError as e: d = Display() d.warning("Error accessing plugin paths: %s" % str(e)) for full_path in (f for f in full_paths if os.path.isfile(f)): diff --git a/v2/ansible/plugins/action/__init__.py b/v2/ansible/plugins/action/__init__.py index 2f56c4df582..0e98bbc5b75 100644 --- a/v2/ansible/plugins/action/__init__.py +++ b/v2/ansible/plugins/action/__init__.py @@ -122,7 +122,7 @@ class ActionBase: # FIXME: modified from original, needs testing? Since this is now inside # the action plugin, it should make it just this simple return getattr(self, 'TRANSFERS_FILES', False) - + def _late_needs_tmp_path(self, tmp, module_style): ''' Determines if a temp path is required after some early actions have already taken place. @@ -223,7 +223,7 @@ class ActionBase: #else: # data = data.encode('utf-8') afo.write(data) - except Exception, e: + except Exception as e: #raise AnsibleError("failure encoding into utf-8: %s" % str(e)) raise AnsibleError("failure writing module data to temporary file for transfer: %s" % str(e)) diff --git a/v2/ansible/plugins/action/copy.py b/v2/ansible/plugins/action/copy.py index ece8b5b11b0..6db130ad7f3 100644 --- a/v2/ansible/plugins/action/copy.py +++ b/v2/ansible/plugins/action/copy.py @@ -70,7 +70,7 @@ class ActionModule(ActionBase): else: content_tempfile = self._create_content_tempfile(content) source = content_tempfile - except Exception, err: + except Exception as err: return dict(failed=True, msg="could not write content temp file: %s" % err) ############################################################################################### @@ -270,7 +270,7 @@ class ActionModule(ActionBase): if module_return.get('changed') == True: changed = True - # the file module returns the file path as 'path', but + # the file module returns the file path as 'path', but # the copy module uses 'dest', so add it if it's not there if 'path' in module_return and 'dest' not in module_return: module_return['dest'] = module_return['path'] @@ -297,7 +297,7 @@ class ActionModule(ActionBase): content = to_bytes(content) try: f.write(content) - except Exception, err: + except Exception as err: os.remove(content_tempfile) raise Exception(err) finally: diff --git a/v2/ansible/plugins/action/pause.py b/v2/ansible/plugins/action/pause.py index 9c6075e1011..c56e6654b1b 100644 --- a/v2/ansible/plugins/action/pause.py +++ b/v2/ansible/plugins/action/pause.py @@ -68,7 +68,7 @@ class ActionModule(ActionBase): seconds = int(self._task.args['seconds']) duration_unit = 'seconds' - except ValueError, e: + except ValueError as e: return dict(failed=True, msg="non-integer value given for prompt duration:\n%s" % str(e)) # Is 'prompt' a key in 'args'? diff --git a/v2/ansible/plugins/action/template.py b/v2/ansible/plugins/action/template.py index 76b2e78a737..f82cbb37667 100644 --- a/v2/ansible/plugins/action/template.py +++ b/v2/ansible/plugins/action/template.py @@ -102,7 +102,7 @@ class ActionModule(ActionBase): with open(source, 'r') as f: template_data = f.read() resultant = templar.template(template_data, preserve_trailing_newlines=True) - except Exception, e: + except Exception as e: return dict(failed=True, msg=type(e).__name__ + ": " + str(e)) local_checksum = checksum_s(resultant) diff --git a/v2/ansible/plugins/connections/accelerate.py b/v2/ansible/plugins/connections/accelerate.py index a31124e119f..13012aa9299 100644 --- a/v2/ansible/plugins/connections/accelerate.py +++ b/v2/ansible/plugins/connections/accelerate.py @@ -140,7 +140,7 @@ class Connection(object): # shutdown, so we'll reconnect. wrong_user = True - except AnsibleError, e: + except AnsibleError as e: if allow_ssh: if "WRONG_USER" in e: vvv("Switching users, waiting for the daemon on %s to shutdown completely..." % self.host) diff --git a/v2/ansible/plugins/connections/paramiko_ssh.py b/v2/ansible/plugins/connections/paramiko_ssh.py index 4bb06e01c36..81470f657c8 100644 --- a/v2/ansible/plugins/connections/paramiko_ssh.py +++ b/v2/ansible/plugins/connections/paramiko_ssh.py @@ -170,7 +170,7 @@ class Connection(object): key_filename=key_filename, password=self.password, timeout=self.runner.timeout, port=self.port) - except Exception, e: + except Exception as e: msg = str(e) if "PID check failed" in msg: @@ -197,7 +197,7 @@ class Connection(object): self.ssh.get_transport().set_keepalive(5) chan = self.ssh.get_transport().open_session() - except Exception, e: + except Exception as e: msg = "Failed to open session" if len(str(e)) > 0: @@ -284,7 +284,7 @@ class Connection(object): try: self.sftp = self.ssh.open_sftp() - except Exception, e: + except Exception as e: raise errors.AnsibleError("failed to open a SFTP connection (%s)" % e) try: @@ -308,7 +308,7 @@ class Connection(object): try: self.sftp = self._connect_sftp() - except Exception, e: + except Exception as e: raise errors.AnsibleError("failed to open a SFTP connection (%s)", e) try: diff --git a/v2/ansible/plugins/connections/winrm.py b/v2/ansible/plugins/connections/winrm.py index d6e51710b5f..57d26ce6188 100644 --- a/v2/ansible/plugins/connections/winrm.py +++ b/v2/ansible/plugins/connections/winrm.py @@ -147,7 +147,7 @@ class Connection(object): cmd_parts = powershell._encode_script(script, as_list=True) try: result = self._winrm_exec(cmd_parts[0], cmd_parts[1:], from_exec=True) - except Exception, e: + except Exception as e: traceback.print_exc() raise errors.AnsibleError("failed to exec cmd %s" % cmd) return (result.status_code, '', result.std_out.encode('utf-8'), result.std_err.encode('utf-8')) diff --git a/v2/ansible/plugins/lookup/csvfile.py b/v2/ansible/plugins/lookup/csvfile.py index 87757399ce5..e5fb9a45121 100644 --- a/v2/ansible/plugins/lookup/csvfile.py +++ b/v2/ansible/plugins/lookup/csvfile.py @@ -33,7 +33,7 @@ class LookupModule(LookupBase): for row in creader: if row[0] == key: return row[int(col)] - except Exception, e: + except Exception as e: raise AnsibleError("csvfile: %s" % str(e)) return dflt @@ -61,7 +61,7 @@ class LookupModule(LookupBase): name, value = param.split('=') assert(name in paramvals) paramvals[name] = value - except (ValueError, AssertionError), e: + except (ValueError, AssertionError) as e: raise AnsibleError(e) if paramvals['delimiter'] == 'TAB': diff --git a/v2/ansible/plugins/lookup/dnstxt.py b/v2/ansible/plugins/lookup/dnstxt.py index 7100f8d96df..75222927c79 100644 --- a/v2/ansible/plugins/lookup/dnstxt.py +++ b/v2/ansible/plugins/lookup/dnstxt.py @@ -59,7 +59,7 @@ class LookupModule(LookupBase): string = 'NXDOMAIN' except dns.resolver.Timeout: string = '' - except dns.exception.DNSException, e: + except dns.exception.DNSException as e: raise AnsibleError("dns.resolver unhandled exception", e) ret.append(''.join(string)) diff --git a/v2/ansible/plugins/lookup/first_found.py b/v2/ansible/plugins/lookup/first_found.py index 0ed26880150..b1d655b8114 100644 --- a/v2/ansible/plugins/lookup/first_found.py +++ b/v2/ansible/plugins/lookup/first_found.py @@ -177,7 +177,7 @@ class LookupModule(LookupBase): for fn in total_search: try: fn = templar.template(fn) - except (AnsibleUndefinedVariable, UndefinedError), e: + except (AnsibleUndefinedVariable, UndefinedError) as e: continue if os.path.isabs(fn) and os.path.exists(fn): diff --git a/v2/ansible/plugins/lookup/password.py b/v2/ansible/plugins/lookup/password.py index 6e13410e1ab..7e812a38c5f 100644 --- a/v2/ansible/plugins/lookup/password.py +++ b/v2/ansible/plugins/lookup/password.py @@ -85,7 +85,7 @@ class LookupModule(LookupBase): paramvals['chars'] = use_chars else: paramvals[name] = value - except (ValueError, AssertionError), e: + except (ValueError, AssertionError) as e: raise AnsibleError(e) length = paramvals['length'] @@ -99,7 +99,7 @@ class LookupModule(LookupBase): if not os.path.isdir(pathdir): try: os.makedirs(pathdir, mode=0700) - except OSError, e: + except OSError as e: raise AnsibleError("cannot create the path for the password lookup: %s (error was %s)" % (pathdir, str(e))) chars = "".join([getattr(string,c,c) for c in use_chars]).replace('"','').replace("'",'') diff --git a/v2/ansible/plugins/lookup/url.py b/v2/ansible/plugins/lookup/url.py index c907bfbce39..1b9c5c0d808 100644 --- a/v2/ansible/plugins/lookup/url.py +++ b/v2/ansible/plugins/lookup/url.py @@ -31,10 +31,10 @@ class LookupModule(LookupBase): try: r = urllib2.Request(term) response = urllib2.urlopen(r) - except URLError, e: + except URLError as e: utils.warnings("Failed lookup url for %s : %s" % (term, str(e))) continue - except HTTPError, e: + except HTTPError as e: utils.warnings("Recieved HTTP error for %s : %s" % (term, str(e))) continue diff --git a/v2/ansible/plugins/strategies/__init__.py b/v2/ansible/plugins/strategies/__init__.py index afbc373f4f3..c5b3dd0f066 100644 --- a/v2/ansible/plugins/strategies/__init__.py +++ b/v2/ansible/plugins/strategies/__init__.py @@ -109,7 +109,7 @@ class StrategyBase: self._pending_results += 1 main_q.put((host, task, self._loader.get_basedir(), task_vars, connection_info, module_loader), block=False) - except (EOFError, IOError, AssertionError), e: + except (EOFError, IOError, AssertionError) as e: # most likely an abort debug("got an error while queuing: %s" % e) return diff --git a/v2/ansible/plugins/strategies/free.py b/v2/ansible/plugins/strategies/free.py index 4fd8a132018..d0506d37dda 100644 --- a/v2/ansible/plugins/strategies/free.py +++ b/v2/ansible/plugins/strategies/free.py @@ -139,7 +139,7 @@ class StrategyModule(StrategyBase): try: results = self._wait_on_pending_results(iterator) host_results.extend(results) - except Exception, e: + except Exception as e: # FIXME: ctrl+c can cause some failures here, so catch them # with the appropriate error type print("wtf: %s" % e) diff --git a/v2/ansible/template/safe_eval.py b/v2/ansible/template/safe_eval.py index ba377054d7a..c52ef398d76 100644 --- a/v2/ansible/template/safe_eval.py +++ b/v2/ansible/template/safe_eval.py @@ -105,13 +105,13 @@ def safe_eval(expr, locals={}, include_exceptions=False): return (result, None) else: return result - except SyntaxError, e: + except SyntaxError as e: # special handling for syntax errors, we just return # the expression string back as-is if include_exceptions: return (expr, None) return expr - except Exception, e: + except Exception as e: if include_exceptions: return (expr, e) return expr diff --git a/v2/ansible/utils/hashing.py b/v2/ansible/utils/hashing.py index 0b2edd434bc..2c7dd534fcb 100644 --- a/v2/ansible/utils/hashing.py +++ b/v2/ansible/utils/hashing.py @@ -64,7 +64,7 @@ def secure_hash(filename, hash_func=sha1): digest.update(block) block = infile.read(blocksize) infile.close() - except IOError, e: + except IOError as e: raise errors.AnsibleError("error while accessing the file %s, error was: %s" % (filename, e)) return digest.hexdigest() diff --git a/v2/ansible/utils/vault.py b/v2/ansible/utils/vault.py index 04634aa377b..5c704afac59 100644 --- a/v2/ansible/utils/vault.py +++ b/v2/ansible/utils/vault.py @@ -40,7 +40,7 @@ def read_vault_file(vault_password_file): try: # STDERR not captured to make it easier for users to prompt for input in their scripts p = subprocess.Popen(this_path, stdout=subprocess.PIPE) - except OSError, e: + except OSError as e: raise AnsibleError("Problem running vault password script %s (%s). If this is not a script, remove the executable bit from the file." % (' '.join(this_path), e)) stdout, stderr = p.communicate() vault_pass = stdout.strip('\r\n') @@ -49,7 +49,7 @@ def read_vault_file(vault_password_file): f = open(this_path, "rb") vault_pass=f.read().strip() f.close() - except (OSError, IOError), e: + except (OSError, IOError) as e: raise AnsibleError("Could not read vault password file %s: %s" % (this_path, e)) return vault_pass diff --git a/v2/ansible/vars/__init__.py b/v2/ansible/vars/__init__.py index eb75d9c9929..183116ea2d8 100644 --- a/v2/ansible/vars/__init__.py +++ b/v2/ansible/vars/__init__.py @@ -243,7 +243,7 @@ class VariableManager: try: names = loader.list_directory(path) - except os.error, err: + except os.error as err: raise AnsibleError("This folder cannot be listed: %s: %s." % (path, err.strerror)) # evaluate files in a stable order rather than whatever diff --git a/v2/samples/multi.py b/v2/samples/multi.py index ca4c8b68f74..dce61430594 100644 --- a/v2/samples/multi.py +++ b/v2/samples/multi.py @@ -59,10 +59,10 @@ def results(pipe, workers): time.sleep(0.01) continue pipe.send(result) - except (IOError, EOFError, KeyboardInterrupt), e: + except (IOError, EOFError, KeyboardInterrupt) as e: debug("got a breaking error: %s" % e) break - except Exception, e: + except Exception as e: debug("EXCEPTION DURING RESULTS PROCESSING: %s" % e) traceback.print_exc() break diff --git a/v2/samples/multi_queues.py b/v2/samples/multi_queues.py index 8eb80366076..9e8f22b9a94 100644 --- a/v2/samples/multi_queues.py +++ b/v2/samples/multi_queues.py @@ -55,10 +55,10 @@ def results(final_q, workers): time.sleep(0.01) continue final_q.put(result, block=False) - except (IOError, EOFError, KeyboardInterrupt), e: + except (IOError, EOFError, KeyboardInterrupt) as e: debug("got a breaking error: %s" % e) break - except Exception, e: + except Exception as e: debug("EXCEPTION DURING RESULTS PROCESSING: %s" % e) traceback.print_exc() break @@ -77,10 +77,10 @@ def worker(main_q, res_q, loader): time.sleep(0.01) except Queue.Empty: pass - except (IOError, EOFError, KeyboardInterrupt), e: + except (IOError, EOFError, KeyboardInterrupt) as e: debug("got a breaking error: %s" % e) break - except Exception, e: + except Exception as e: debug("EXCEPTION DURING WORKER PROCESSING: %s" % e) traceback.print_exc() break From b407dd8b58258379b824721c193ca005deeb3a19 Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Mon, 13 Apr 2015 13:34:48 -0400 Subject: [PATCH 05/12] Add setup.py for v2 to allow for pip editable installs. --- v2/setup.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 v2/setup.py diff --git a/v2/setup.py b/v2/setup.py new file mode 100644 index 00000000000..a9a51879818 --- /dev/null +++ b/v2/setup.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +import sys + +from ansible import __version__ +try: + from setuptools import setup, find_packages +except ImportError: + print("Ansible now needs setuptools in order to build. Install it using" + " your package manager (usually python-setuptools) or via pip (pip" + " install setuptools).") + sys.exit(1) + +setup(name='ansible', + version=__version__, + description='Radically simple IT automation', + author='Michael DeHaan', + author_email='michael@ansible.com', + url='http://ansible.com/', + license='GPLv3', + install_requires=['paramiko', 'jinja2', "PyYAML", 'setuptools', 'pycrypto >= 2.6'], + # package_dir={ '': 'lib' }, + # packages=find_packages('lib'), + package_data={ + '': ['module_utils/*.ps1', 'modules/core/windows/*.ps1', 'modules/extras/windows/*.ps1'], + }, + scripts=[ + 'bin/ansible', + 'bin/ansible-playbook', + # 'bin/ansible-pull', + # 'bin/ansible-doc', + # 'bin/ansible-galaxy', + # 'bin/ansible-vault', + ], + data_files=[], +) From 87dde862bd5b93900a3f1db1d99962f89e160705 Mon Sep 17 00:00:00 2001 From: eroldan Date: Mon, 13 Apr 2015 16:21:08 -0300 Subject: [PATCH 06/12] Fixed wrong example of 'environment' for setting PATH --- docsite/rst/faq.rst | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docsite/rst/faq.rst b/docsite/rst/faq.rst index 1b499c54740..ba3ae1264ff 100644 --- a/docsite/rst/faq.rst +++ b/docsite/rst/faq.rst @@ -3,15 +3,17 @@ Frequently Asked Questions Here are some commonly-asked questions and their answers. -.. _users_and_ports: +.. _set_environment: -If you are looking to set environment variables remotely for your project (in a task, not locally for Ansible) -The keyword is simply `environment` +How can I set the PATH or any other environment variable for a task or entire playbook? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +Setting environment variables can be done with the `environment` keyword. It can be used at task or playbook level:: + + environment: + PATH: {{ ansible_env.PATH }}:/thingy/bin + SOME: value -``` - environment: - PATH:$PATH:/thingy/bin -``` How do I handle different machines needing different user accounts or ports to log in with? From 1bdf0bb0d67849d96aa1b29713af6643e35d148f Mon Sep 17 00:00:00 2001 From: ian Date: Mon, 13 Apr 2015 15:37:25 -0400 Subject: [PATCH 07/12] Several more changes to suport python3 syntax. --- v2/ansible/plugins/action/__init__.py | 2 +- v2/ansible/plugins/lookup/password.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/v2/ansible/plugins/action/__init__.py b/v2/ansible/plugins/action/__init__.py index 0e98bbc5b75..be83539def6 100644 --- a/v2/ansible/plugins/action/__init__.py +++ b/v2/ansible/plugins/action/__init__.py @@ -19,7 +19,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import StringIO +from six.moves import StringIO import json import os import random diff --git a/v2/ansible/plugins/lookup/password.py b/v2/ansible/plugins/lookup/password.py index 7e812a38c5f..74017eff619 100644 --- a/v2/ansible/plugins/lookup/password.py +++ b/v2/ansible/plugins/lookup/password.py @@ -98,7 +98,7 @@ class LookupModule(LookupBase): pathdir = os.path.dirname(path) if not os.path.isdir(pathdir): try: - os.makedirs(pathdir, mode=0700) + os.makedirs(pathdir, mode=0o700) except OSError as e: raise AnsibleError("cannot create the path for the password lookup: %s (error was %s)" % (pathdir, str(e))) @@ -111,7 +111,7 @@ class LookupModule(LookupBase): else: content = password with open(path, 'w') as f: - os.chmod(path, 0600) + os.chmod(path, 0o600) f.write(content + '\n') else: content = open(path).read().rstrip() @@ -129,12 +129,12 @@ class LookupModule(LookupBase): salt = self.random_salt() content = '%s salt=%s' % (password, salt) with open(path, 'w') as f: - os.chmod(path, 0600) + os.chmod(path, 0o600) f.write(content + '\n') # crypt not requested, remove salt if present elif (encrypt is None and salt): with open(path, 'w') as f: - os.chmod(path, 0600) + os.chmod(path, 0o600) f.write(password + '\n') if encrypt: From 3a8088fe3009e2ef29a33517c6a787c27098041c Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 13 Apr 2015 12:57:17 -0700 Subject: [PATCH 08/12] _available_vars in v1 == _available_variables in v2 --- v2/ansible/template/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/ansible/template/__init__.py b/v2/ansible/template/__init__.py index 4e15e83424c..6c41ad3cf40 100644 --- a/v2/ansible/template/__init__.py +++ b/v2/ansible/template/__init__.py @@ -143,8 +143,8 @@ class Templar: only_one = SINGLE_VAR.match(variable) if only_one: var_name = only_one.group(1) - if var_name in self._available_vars: - resolved_val = self._available_vars[var_name] + if var_name in self._available_variables: + resolved_val = self._available_variables[var_name] if isinstance(resolved_val, NON_TEMPLATED_TYPES): return resolved_val From 3bb7b0eef309dbac7ca97ae7fa54213950e86ac8 Mon Sep 17 00:00:00 2001 From: ian Date: Mon, 13 Apr 2015 16:03:02 -0400 Subject: [PATCH 09/12] Import StringIO from six in a couple more places. --- v2/ansible/executor/module_common.py | 2 +- v2/test/parsing/yaml/test_loader.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/ansible/executor/module_common.py b/v2/ansible/executor/module_common.py index 23890d64e61..535fbd45e33 100644 --- a/v2/ansible/executor/module_common.py +++ b/v2/ansible/executor/module_common.py @@ -21,7 +21,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type # from python and deps -from cStringIO import StringIO +from six.moves import StringIO import json import os import shlex diff --git a/v2/test/parsing/yaml/test_loader.py b/v2/test/parsing/yaml/test_loader.py index 9a4746b99df..d393d72a005 100644 --- a/v2/test/parsing/yaml/test_loader.py +++ b/v2/test/parsing/yaml/test_loader.py @@ -20,7 +20,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from StringIO import StringIO +from six.moves import StringIO from collections import Sequence, Set, Mapping from ansible.compat.tests import unittest From 3d2a056ad4e748eb22d51ce73f94d3cb53092776 Mon Sep 17 00:00:00 2001 From: Amandine Lee Date: Mon, 13 Apr 2015 13:28:01 -0700 Subject: [PATCH 10/12] Import futures including print --- v2/ansible/executor/playbook_executor.py | 2 +- v2/ansible/inventory/__init__.py | 3 +++ v2/ansible/inventory/dir.py | 2 ++ v2/ansible/inventory/expand_hosts.py | 3 +++ v2/ansible/inventory/group.py | 2 ++ v2/ansible/inventory/ini.py | 2 ++ v2/ansible/inventory/script.py | 2 ++ v2/ansible/inventory/vars_plugins/noop.py | 2 ++ v2/ansible/parsing/utils/jsonify.py | 21 ++++++++++++++++++- v2/ansible/playbook/helpers.py | 2 ++ v2/ansible/playbook/play.py | 2 +- v2/ansible/plugins/action/assemble.py | 2 ++ v2/ansible/plugins/action/assert.py | 2 ++ v2/ansible/plugins/action/async.py | 2 ++ v2/ansible/plugins/action/debug.py | 2 ++ v2/ansible/plugins/action/fail.py | 2 ++ v2/ansible/plugins/action/fetch.py | 2 ++ v2/ansible/plugins/action/group_by.py | 2 ++ v2/ansible/plugins/action/include_vars.py | 2 ++ v2/ansible/plugins/action/normal.py | 2 ++ v2/ansible/plugins/action/pause.py | 2 ++ v2/ansible/plugins/action/raw.py | 2 ++ v2/ansible/plugins/action/script.py | 2 ++ v2/ansible/plugins/action/set_fact.py | 2 ++ v2/ansible/plugins/action/synchronize.py | 2 ++ v2/ansible/plugins/action/template.py | 2 ++ v2/ansible/plugins/action/unarchive.py | 2 ++ v2/ansible/plugins/cache/__init__.py | 2 ++ v2/ansible/plugins/cache/base.py | 2 ++ v2/ansible/plugins/cache/memcached.py | 2 ++ v2/ansible/plugins/cache/memory.py | 2 ++ v2/ansible/plugins/cache/redis.py | 4 ++-- v2/ansible/plugins/connections/accelerate.py | 2 ++ v2/ansible/plugins/connections/chroot.py | 2 ++ v2/ansible/plugins/connections/funcd.py | 3 +++ v2/ansible/plugins/connections/jail.py | 2 ++ v2/ansible/plugins/connections/libvirt_lxc.py | 2 ++ v2/ansible/plugins/connections/local.py | 2 ++ .../plugins/connections/paramiko_ssh.py | 3 ++- v2/ansible/plugins/connections/ssh.py | 2 ++ v2/ansible/plugins/connections/winrm.py | 4 ++-- v2/ansible/plugins/inventory/directory.py | 2 +- v2/ansible/plugins/lookup/cartesian.py | 2 ++ v2/ansible/plugins/lookup/csvfile.py | 2 ++ v2/ansible/plugins/lookup/dict.py | 2 ++ v2/ansible/plugins/lookup/dnstxt.py | 2 ++ v2/ansible/plugins/lookup/env.py | 2 ++ v2/ansible/plugins/lookup/etcd.py | 2 ++ v2/ansible/plugins/lookup/file.py | 2 ++ v2/ansible/plugins/lookup/fileglob.py | 2 ++ v2/ansible/plugins/lookup/first_found.py | 2 ++ v2/ansible/plugins/lookup/flattened.py | 3 ++- v2/ansible/plugins/lookup/indexed_items.py | 2 ++ .../plugins/lookup/inventory_hostnames.py | 3 +++ v2/ansible/plugins/lookup/items.py | 2 ++ v2/ansible/plugins/lookup/lines.py | 4 +++- v2/ansible/plugins/lookup/nested.py | 2 ++ v2/ansible/plugins/lookup/password.py | 2 ++ v2/ansible/plugins/lookup/pipe.py | 2 ++ v2/ansible/plugins/lookup/random_choice.py | 2 ++ v2/ansible/plugins/lookup/redis_kv.py | 2 ++ v2/ansible/plugins/lookup/sequence.py | 2 ++ v2/ansible/plugins/lookup/subelements.py | 2 ++ v2/ansible/plugins/lookup/template.py | 2 ++ v2/ansible/plugins/lookup/together.py | 2 ++ v2/ansible/plugins/lookup/url.py | 2 ++ v2/ansible/plugins/shell/csh.py | 2 ++ v2/ansible/plugins/shell/fish.py | 2 ++ v2/ansible/plugins/shell/powershell.py | 2 ++ v2/ansible/plugins/shell/sh.py | 2 ++ v2/ansible/template/safe_eval.py | 2 ++ v2/ansible/utils/color.py | 2 ++ v2/ansible/utils/debug.py | 3 +++ v2/ansible/utils/display.py | 2 ++ v2/ansible/utils/encrypt.py | 3 +++ v2/ansible/utils/path.py | 2 ++ 76 files changed, 174 insertions(+), 11 deletions(-) diff --git a/v2/ansible/executor/playbook_executor.py b/v2/ansible/executor/playbook_executor.py index 8af19ed378f..6f0bf31f337 100644 --- a/v2/ansible/executor/playbook_executor.py +++ b/v2/ansible/executor/playbook_executor.py @@ -16,7 +16,7 @@ # along with Ansible. If not, see . # Make coding more python3-ish -from __future__ import (absolute_import, division) +from __future__ import (absolute_import, division, print_function) __metaclass__ = type import signal diff --git a/v2/ansible/inventory/__init__.py b/v2/ansible/inventory/__init__.py index c8e3cddebaa..063398f17f9 100644 --- a/v2/ansible/inventory/__init__.py +++ b/v2/ansible/inventory/__init__.py @@ -16,6 +16,9 @@ # along with Ansible. If not, see . ############################################# +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import fnmatch import os import sys diff --git a/v2/ansible/inventory/dir.py b/v2/ansible/inventory/dir.py index 52f7af8b53f..73c882f288f 100644 --- a/v2/ansible/inventory/dir.py +++ b/v2/ansible/inventory/dir.py @@ -17,6 +17,8 @@ # along with Ansible. If not, see . ############################################# +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os diff --git a/v2/ansible/inventory/expand_hosts.py b/v2/ansible/inventory/expand_hosts.py index f1297409355..b5a957c53fe 100644 --- a/v2/ansible/inventory/expand_hosts.py +++ b/v2/ansible/inventory/expand_hosts.py @@ -30,6 +30,9 @@ expanded into 001, 002 ...009, 010. Note that when beg is specified with left zero padding, then the length of end must be the same as that of beg, else an exception is raised. ''' +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import string from ansible import errors diff --git a/v2/ansible/inventory/group.py b/v2/ansible/inventory/group.py index 87d6f64dfc6..6525e69b466 100644 --- a/v2/ansible/inventory/group.py +++ b/v2/ansible/inventory/group.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.utils.debug import debug diff --git a/v2/ansible/inventory/ini.py b/v2/ansible/inventory/ini.py index 4236140ac88..e004ee8bb75 100644 --- a/v2/ansible/inventory/ini.py +++ b/v2/ansible/inventory/ini.py @@ -16,6 +16,8 @@ # along with Ansible. If not, see . ############################################# +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import ast import shlex diff --git a/v2/ansible/inventory/script.py b/v2/ansible/inventory/script.py index 13b53a24f5e..9675d70f690 100644 --- a/v2/ansible/inventory/script.py +++ b/v2/ansible/inventory/script.py @@ -16,6 +16,8 @@ # along with Ansible. If not, see . ############################################# +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os import subprocess diff --git a/v2/ansible/inventory/vars_plugins/noop.py b/v2/ansible/inventory/vars_plugins/noop.py index 5d4b4b6658c..8f0c98cad56 100644 --- a/v2/ansible/inventory/vars_plugins/noop.py +++ b/v2/ansible/inventory/vars_plugins/noop.py @@ -15,6 +15,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type class VarsModule(object): diff --git a/v2/ansible/parsing/utils/jsonify.py b/v2/ansible/parsing/utils/jsonify.py index 37c97d0195f..59dbf9f8c4c 100644 --- a/v2/ansible/parsing/utils/jsonify.py +++ b/v2/ansible/parsing/utils/jsonify.py @@ -1,4 +1,23 @@ -# FIXME: header +# (c) 2012-2014, Michael DeHaan +# +# 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 . + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type try: import json diff --git a/v2/ansible/playbook/helpers.py b/v2/ansible/playbook/helpers.py index 7242322b88f..92f1c64c83e 100644 --- a/v2/ansible/playbook/helpers.py +++ b/v2/ansible/playbook/helpers.py @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os diff --git a/v2/ansible/playbook/play.py b/v2/ansible/playbook/play.py index 33fd5efd9fa..c7f89888b87 100644 --- a/v2/ansible/playbook/play.py +++ b/v2/ansible/playbook/play.py @@ -16,7 +16,7 @@ # along with Ansible. If not, see . # Make coding more python3-ish -from __future__ import (absolute_import, division) +from __future__ import (absolute_import, division, print_function) __metaclass__ = type from ansible.errors import AnsibleError, AnsibleParserError diff --git a/v2/ansible/plugins/action/assemble.py b/v2/ansible/plugins/action/assemble.py index 638d4b92bb5..4e796bddb6f 100644 --- a/v2/ansible/plugins/action/assemble.py +++ b/v2/ansible/plugins/action/assemble.py @@ -15,6 +15,8 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os import os.path diff --git a/v2/ansible/plugins/action/assert.py b/v2/ansible/plugins/action/assert.py index 7204d93875e..5c4fdd7b89c 100644 --- a/v2/ansible/plugins/action/assert.py +++ b/v2/ansible/plugins/action/assert.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.errors import AnsibleError from ansible.playbook.conditional import Conditional diff --git a/v2/ansible/plugins/action/async.py b/v2/ansible/plugins/action/async.py index 6fbf93d61fe..7c02e09757e 100644 --- a/v2/ansible/plugins/action/async.py +++ b/v2/ansible/plugins/action/async.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import json import random diff --git a/v2/ansible/plugins/action/debug.py b/v2/ansible/plugins/action/debug.py index dcee3e6347d..dc80dfc1795 100644 --- a/v2/ansible/plugins/action/debug.py +++ b/v2/ansible/plugins/action/debug.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.plugins.action import ActionBase from ansible.utils.boolean import boolean diff --git a/v2/ansible/plugins/action/fail.py b/v2/ansible/plugins/action/fail.py index a95ccb32f74..b7845c95c5c 100644 --- a/v2/ansible/plugins/action/fail.py +++ b/v2/ansible/plugins/action/fail.py @@ -15,6 +15,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.plugins.action import ActionBase diff --git a/v2/ansible/plugins/action/fetch.py b/v2/ansible/plugins/action/fetch.py index 7b549f5ecbc..58e7cebb8d2 100644 --- a/v2/ansible/plugins/action/fetch.py +++ b/v2/ansible/plugins/action/fetch.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os import pwd diff --git a/v2/ansible/plugins/action/group_by.py b/v2/ansible/plugins/action/group_by.py index 50e0cc09c43..95db33aa43f 100644 --- a/v2/ansible/plugins/action/group_by.py +++ b/v2/ansible/plugins/action/group_by.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.errors import * from ansible.plugins.action import ActionBase diff --git a/v2/ansible/plugins/action/include_vars.py b/v2/ansible/plugins/action/include_vars.py index 345e0edc0e9..8a7a74d8705 100644 --- a/v2/ansible/plugins/action/include_vars.py +++ b/v2/ansible/plugins/action/include_vars.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os diff --git a/v2/ansible/plugins/action/normal.py b/v2/ansible/plugins/action/normal.py index 66721b4eb25..431d9b0eebe 100644 --- a/v2/ansible/plugins/action/normal.py +++ b/v2/ansible/plugins/action/normal.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.plugins.action import ActionBase diff --git a/v2/ansible/plugins/action/pause.py b/v2/ansible/plugins/action/pause.py index 9c6075e1011..47399fc4939 100644 --- a/v2/ansible/plugins/action/pause.py +++ b/v2/ansible/plugins/action/pause.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import datetime import sys diff --git a/v2/ansible/plugins/action/raw.py b/v2/ansible/plugins/action/raw.py index d1d1b280561..f9cd56572b1 100644 --- a/v2/ansible/plugins/action/raw.py +++ b/v2/ansible/plugins/action/raw.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.plugins.action import ActionBase diff --git a/v2/ansible/plugins/action/script.py b/v2/ansible/plugins/action/script.py index 21a9f41c59b..3ca7dc6a342 100644 --- a/v2/ansible/plugins/action/script.py +++ b/v2/ansible/plugins/action/script.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os diff --git a/v2/ansible/plugins/action/set_fact.py b/v2/ansible/plugins/action/set_fact.py index bf89e7ec517..a7ddf10b474 100644 --- a/v2/ansible/plugins/action/set_fact.py +++ b/v2/ansible/plugins/action/set_fact.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.errors import AnsibleError from ansible.plugins.action import ActionBase diff --git a/v2/ansible/plugins/action/synchronize.py b/v2/ansible/plugins/action/synchronize.py index 81e335b0098..1bc64ff4d5b 100644 --- a/v2/ansible/plugins/action/synchronize.py +++ b/v2/ansible/plugins/action/synchronize.py @@ -15,6 +15,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os.path diff --git a/v2/ansible/plugins/action/template.py b/v2/ansible/plugins/action/template.py index 76b2e78a737..07b406f2beb 100644 --- a/v2/ansible/plugins/action/template.py +++ b/v2/ansible/plugins/action/template.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import base64 import os diff --git a/v2/ansible/plugins/action/unarchive.py b/v2/ansible/plugins/action/unarchive.py index 1b6cb354f0f..b7601ed9107 100644 --- a/v2/ansible/plugins/action/unarchive.py +++ b/v2/ansible/plugins/action/unarchive.py @@ -15,6 +15,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os import pipes diff --git a/v2/ansible/plugins/cache/__init__.py b/v2/ansible/plugins/cache/__init__.py index deed7f3ecde..4aa8fda8bbb 100644 --- a/v2/ansible/plugins/cache/__init__.py +++ b/v2/ansible/plugins/cache/__init__.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from collections import MutableMapping diff --git a/v2/ansible/plugins/cache/base.py b/v2/ansible/plugins/cache/base.py index b6254cdfd48..6ff3d5ed1e2 100644 --- a/v2/ansible/plugins/cache/base.py +++ b/v2/ansible/plugins/cache/base.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import exceptions diff --git a/v2/ansible/plugins/cache/memcached.py b/v2/ansible/plugins/cache/memcached.py index deaf07fe2e2..135e34c2b43 100644 --- a/v2/ansible/plugins/cache/memcached.py +++ b/v2/ansible/plugins/cache/memcached.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import collections import os diff --git a/v2/ansible/plugins/cache/memory.py b/v2/ansible/plugins/cache/memory.py index 007719a6477..15628361513 100644 --- a/v2/ansible/plugins/cache/memory.py +++ b/v2/ansible/plugins/cache/memory.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.plugins.cache.base import BaseCacheModule diff --git a/v2/ansible/plugins/cache/redis.py b/v2/ansible/plugins/cache/redis.py index 7f126de64bb..291ce81c474 100644 --- a/v2/ansible/plugins/cache/redis.py +++ b/v2/ansible/plugins/cache/redis.py @@ -14,9 +14,9 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type -from __future__ import absolute_import -import collections # FIXME: can we store these as something else before we ship it? import sys import time diff --git a/v2/ansible/plugins/connections/accelerate.py b/v2/ansible/plugins/connections/accelerate.py index a31124e119f..925136ecce2 100644 --- a/v2/ansible/plugins/connections/accelerate.py +++ b/v2/ansible/plugins/connections/accelerate.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import json import os diff --git a/v2/ansible/plugins/connections/chroot.py b/v2/ansible/plugins/connections/chroot.py index 38c8af7a690..4e61f4ea559 100644 --- a/v2/ansible/plugins/connections/chroot.py +++ b/v2/ansible/plugins/connections/chroot.py @@ -15,6 +15,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import distutils.spawn import traceback diff --git a/v2/ansible/plugins/connections/funcd.py b/v2/ansible/plugins/connections/funcd.py index 7244abcbe9a..83a0c9b01d3 100644 --- a/v2/ansible/plugins/connections/funcd.py +++ b/v2/ansible/plugins/connections/funcd.py @@ -18,6 +18,9 @@ # along with Ansible. If not, see . # --- +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + # The func transport permit to use ansible over func. For people who have already setup # func and that wish to play with ansible, this permit to move gradually to ansible # without having to redo completely the setup of the network. diff --git a/v2/ansible/plugins/connections/jail.py b/v2/ansible/plugins/connections/jail.py index b721ad62b50..a81f587bfd0 100644 --- a/v2/ansible/plugins/connections/jail.py +++ b/v2/ansible/plugins/connections/jail.py @@ -16,6 +16,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import distutils.spawn import traceback diff --git a/v2/ansible/plugins/connections/libvirt_lxc.py b/v2/ansible/plugins/connections/libvirt_lxc.py index c6cf11f2667..ee824554a02 100644 --- a/v2/ansible/plugins/connections/libvirt_lxc.py +++ b/v2/ansible/plugins/connections/libvirt_lxc.py @@ -16,6 +16,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import distutils.spawn import os diff --git a/v2/ansible/plugins/connections/local.py b/v2/ansible/plugins/connections/local.py index 31d0b296e4a..73583974bf0 100644 --- a/v2/ansible/plugins/connections/local.py +++ b/v2/ansible/plugins/connections/local.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import traceback import os diff --git a/v2/ansible/plugins/connections/paramiko_ssh.py b/v2/ansible/plugins/connections/paramiko_ssh.py index 4bb06e01c36..4562eaa86e3 100644 --- a/v2/ansible/plugins/connections/paramiko_ssh.py +++ b/v2/ansible/plugins/connections/paramiko_ssh.py @@ -14,7 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . - +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type # --- # The paramiko transport is provided because many distributions, in particular EL6 and before diff --git a/v2/ansible/plugins/connections/ssh.py b/v2/ansible/plugins/connections/ssh.py index e59311ead96..2c8f8de8135 100644 --- a/v2/ansible/plugins/connections/ssh.py +++ b/v2/ansible/plugins/connections/ssh.py @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . # +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os import re diff --git a/v2/ansible/plugins/connections/winrm.py b/v2/ansible/plugins/connections/winrm.py index d6e51710b5f..bb704d405c7 100644 --- a/v2/ansible/plugins/connections/winrm.py +++ b/v2/ansible/plugins/connections/winrm.py @@ -14,8 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . - -from __future__ import absolute_import +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import base64 import hashlib diff --git a/v2/ansible/plugins/inventory/directory.py b/v2/ansible/plugins/inventory/directory.py index d340ed75387..a75ad44ea6c 100644 --- a/v2/ansible/plugins/inventory/directory.py +++ b/v2/ansible/plugins/inventory/directory.py @@ -18,7 +18,7 @@ ############################################# # Make coding more python3-ish -from __future__ import (division, print_function) +from __future__ import (absolute_import, division, print_function) __metaclass__ = type import os diff --git a/v2/ansible/plugins/lookup/cartesian.py b/v2/ansible/plugins/lookup/cartesian.py index cc74240826a..c50d53e7f80 100644 --- a/v2/ansible/plugins/lookup/cartesian.py +++ b/v2/ansible/plugins/lookup/cartesian.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from itertools import product diff --git a/v2/ansible/plugins/lookup/csvfile.py b/v2/ansible/plugins/lookup/csvfile.py index 87757399ce5..b67b6bcd1c4 100644 --- a/v2/ansible/plugins/lookup/csvfile.py +++ b/v2/ansible/plugins/lookup/csvfile.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os import codecs diff --git a/v2/ansible/plugins/lookup/dict.py b/v2/ansible/plugins/lookup/dict.py index 61389df7c2e..cc7975ae499 100644 --- a/v2/ansible/plugins/lookup/dict.py +++ b/v2/ansible/plugins/lookup/dict.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.plugins.lookup import LookupBase diff --git a/v2/ansible/plugins/lookup/dnstxt.py b/v2/ansible/plugins/lookup/dnstxt.py index 7100f8d96df..07451079fec 100644 --- a/v2/ansible/plugins/lookup/dnstxt.py +++ b/v2/ansible/plugins/lookup/dnstxt.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os diff --git a/v2/ansible/plugins/lookup/env.py b/v2/ansible/plugins/lookup/env.py index 896f95e13a9..55847dd7779 100644 --- a/v2/ansible/plugins/lookup/env.py +++ b/v2/ansible/plugins/lookup/env.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os diff --git a/v2/ansible/plugins/lookup/etcd.py b/v2/ansible/plugins/lookup/etcd.py index 5b54788985b..002068389f8 100644 --- a/v2/ansible/plugins/lookup/etcd.py +++ b/v2/ansible/plugins/lookup/etcd.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os import urllib2 diff --git a/v2/ansible/plugins/lookup/file.py b/v2/ansible/plugins/lookup/file.py index add4da7f47b..efb039497dd 100644 --- a/v2/ansible/plugins/lookup/file.py +++ b/v2/ansible/plugins/lookup/file.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os import codecs diff --git a/v2/ansible/plugins/lookup/fileglob.py b/v2/ansible/plugins/lookup/fileglob.py index bde016af9e4..89859067150 100644 --- a/v2/ansible/plugins/lookup/fileglob.py +++ b/v2/ansible/plugins/lookup/fileglob.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os import glob diff --git a/v2/ansible/plugins/lookup/first_found.py b/v2/ansible/plugins/lookup/first_found.py index 0ed26880150..e2ae2eb214c 100644 --- a/v2/ansible/plugins/lookup/first_found.py +++ b/v2/ansible/plugins/lookup/first_found.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type # take a list of files and (optionally) a list of paths # return the first existing file found in the paths diff --git a/v2/ansible/plugins/lookup/flattened.py b/v2/ansible/plugins/lookup/flattened.py index 24f1a9ac950..f0a8adaf5e6 100644 --- a/v2/ansible/plugins/lookup/flattened.py +++ b/v2/ansible/plugins/lookup/flattened.py @@ -14,7 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . - +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.errors import * from ansible.plugins.lookup import LookupBase diff --git a/v2/ansible/plugins/lookup/indexed_items.py b/v2/ansible/plugins/lookup/indexed_items.py index 1731dc0e847..4f1dd199471 100644 --- a/v2/ansible/plugins/lookup/indexed_items.py +++ b/v2/ansible/plugins/lookup/indexed_items.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.plugins.lookup import LookupBase diff --git a/v2/ansible/plugins/lookup/inventory_hostnames.py b/v2/ansible/plugins/lookup/inventory_hostnames.py index faffe47eb85..d09dec0c7b5 100644 --- a/v2/ansible/plugins/lookup/inventory_hostnames.py +++ b/v2/ansible/plugins/lookup/inventory_hostnames.py @@ -16,6 +16,9 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + from ansible.errors import * from ansible.plugins.lookup import LookupBase diff --git a/v2/ansible/plugins/lookup/items.py b/v2/ansible/plugins/lookup/items.py index 46925d2a8ba..65ff66d854a 100644 --- a/v2/ansible/plugins/lookup/items.py +++ b/v2/ansible/plugins/lookup/items.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.plugins.lookup import LookupBase diff --git a/v2/ansible/plugins/lookup/lines.py b/v2/ansible/plugins/lookup/lines.py index 507793b18e9..0d842bf148f 100644 --- a/v2/ansible/plugins/lookup/lines.py +++ b/v2/ansible/plugins/lookup/lines.py @@ -15,8 +15,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -import subprocess +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type +import subprocess from ansible.errors import * from ansible.plugins.lookup import LookupBase diff --git a/v2/ansible/plugins/lookup/nested.py b/v2/ansible/plugins/lookup/nested.py index 0f2d146b478..52f4bed1d52 100644 --- a/v2/ansible/plugins/lookup/nested.py +++ b/v2/ansible/plugins/lookup/nested.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.errors import AnsibleError from ansible.plugins.lookup import LookupBase diff --git a/v2/ansible/plugins/lookup/password.py b/v2/ansible/plugins/lookup/password.py index 6e13410e1ab..d262ed79c44 100644 --- a/v2/ansible/plugins/lookup/password.py +++ b/v2/ansible/plugins/lookup/password.py @@ -16,6 +16,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os import errno diff --git a/v2/ansible/plugins/lookup/pipe.py b/v2/ansible/plugins/lookup/pipe.py index 0a7e5cb31ae..d9f74708b28 100644 --- a/v2/ansible/plugins/lookup/pipe.py +++ b/v2/ansible/plugins/lookup/pipe.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import subprocess diff --git a/v2/ansible/plugins/lookup/random_choice.py b/v2/ansible/plugins/lookup/random_choice.py index e899a2dbe3c..de4f31cd0eb 100644 --- a/v2/ansible/plugins/lookup/random_choice.py +++ b/v2/ansible/plugins/lookup/random_choice.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import random diff --git a/v2/ansible/plugins/lookup/redis_kv.py b/v2/ansible/plugins/lookup/redis_kv.py index 08895d4c4ec..e499e83f938 100644 --- a/v2/ansible/plugins/lookup/redis_kv.py +++ b/v2/ansible/plugins/lookup/redis_kv.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os import re diff --git a/v2/ansible/plugins/lookup/sequence.py b/v2/ansible/plugins/lookup/sequence.py index 99783cf566b..1ddeba932f8 100644 --- a/v2/ansible/plugins/lookup/sequence.py +++ b/v2/ansible/plugins/lookup/sequence.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from re import compile as re_compile, IGNORECASE diff --git a/v2/ansible/plugins/lookup/subelements.py b/v2/ansible/plugins/lookup/subelements.py index 93e9e570c41..09a2ca306a1 100644 --- a/v2/ansible/plugins/lookup/subelements.py +++ b/v2/ansible/plugins/lookup/subelements.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.errors import * from ansible.plugins.lookup import LookupBase diff --git a/v2/ansible/plugins/lookup/template.py b/v2/ansible/plugins/lookup/template.py index 74406f64458..e53e1990a0d 100644 --- a/v2/ansible/plugins/lookup/template.py +++ b/v2/ansible/plugins/lookup/template.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os diff --git a/v2/ansible/plugins/lookup/together.py b/v2/ansible/plugins/lookup/together.py index 8b5ff5c8919..2f53121cc8b 100644 --- a/v2/ansible/plugins/lookup/together.py +++ b/v2/ansible/plugins/lookup/together.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from itertools import izip_longest diff --git a/v2/ansible/plugins/lookup/url.py b/v2/ansible/plugins/lookup/url.py index c907bfbce39..59a26ae5413 100644 --- a/v2/ansible/plugins/lookup/url.py +++ b/v2/ansible/plugins/lookup/url.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.plugins.lookup import LookupBase import urllib2 diff --git a/v2/ansible/plugins/shell/csh.py b/v2/ansible/plugins/shell/csh.py index 4e9f8c8af74..96ec84c5bf8 100644 --- a/v2/ansible/plugins/shell/csh.py +++ b/v2/ansible/plugins/shell/csh.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.runner.shell_plugins.sh import ShellModule as ShModule diff --git a/v2/ansible/plugins/shell/fish.py b/v2/ansible/plugins/shell/fish.py index 137c013c12f..53fa9abada6 100644 --- a/v2/ansible/plugins/shell/fish.py +++ b/v2/ansible/plugins/shell/fish.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type from ansible.runner.shell_plugins.sh import ShellModule as ShModule diff --git a/v2/ansible/plugins/shell/powershell.py b/v2/ansible/plugins/shell/powershell.py index 7254df6f7ea..9f3825c3b0f 100644 --- a/v2/ansible/plugins/shell/powershell.py +++ b/v2/ansible/plugins/shell/powershell.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import base64 import os diff --git a/v2/ansible/plugins/shell/sh.py b/v2/ansible/plugins/shell/sh.py index 5fb0dc3add3..497d45eace2 100644 --- a/v2/ansible/plugins/shell/sh.py +++ b/v2/ansible/plugins/shell/sh.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os import re diff --git a/v2/ansible/template/safe_eval.py b/v2/ansible/template/safe_eval.py index ba377054d7a..8dafa433878 100644 --- a/v2/ansible/template/safe_eval.py +++ b/v2/ansible/template/safe_eval.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import ast import sys diff --git a/v2/ansible/utils/color.py b/v2/ansible/utils/color.py index a87717073eb..37d0466d2d1 100644 --- a/v2/ansible/utils/color.py +++ b/v2/ansible/utils/color.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import sys diff --git a/v2/ansible/utils/debug.py b/v2/ansible/utils/debug.py index 3b37ac50a78..5b04ac05726 100644 --- a/v2/ansible/utils/debug.py +++ b/v2/ansible/utils/debug.py @@ -1,3 +1,6 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import os import time import sys diff --git a/v2/ansible/utils/display.py b/v2/ansible/utils/display.py index 62dbeabca51..e30ae225cfa 100644 --- a/v2/ansible/utils/display.py +++ b/v2/ansible/utils/display.py @@ -16,6 +16,8 @@ # along with Ansible. If not, see . # FIXME: copied mostly from old code, needs py3 improvements +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import textwrap import sys diff --git a/v2/ansible/utils/encrypt.py b/v2/ansible/utils/encrypt.py index 878b461c86d..5138dbef705 100644 --- a/v2/ansible/utils/encrypt.py +++ b/v2/ansible/utils/encrypt.py @@ -14,6 +14,9 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + PASSLIB_AVAILABLE = False try: diff --git a/v2/ansible/utils/path.py b/v2/ansible/utils/path.py index ea7fc201a89..e49a2f7d553 100644 --- a/v2/ansible/utils/path.py +++ b/v2/ansible/utils/path.py @@ -14,6 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os import stat From 683c2913c528aa13598cebb7526934cfbd318c2c Mon Sep 17 00:00:00 2001 From: Amandine Lee Date: Mon, 13 Apr 2015 13:28:16 -0700 Subject: [PATCH 11/12] Use print function --- v2/ansible/plugins/action/pause.py | 4 ++-- v2/ansible/plugins/cache/memcached.py | 2 +- v2/ansible/plugins/cache/redis.py | 2 +- v2/ansible/utils/display.py | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/v2/ansible/plugins/action/pause.py b/v2/ansible/plugins/action/pause.py index 47399fc4939..fb35e9601ff 100644 --- a/v2/ansible/plugins/action/pause.py +++ b/v2/ansible/plugins/action/pause.py @@ -101,7 +101,7 @@ class ActionModule(ActionBase): try: if not pause_type == 'prompt': - print "(^C-c = continue early, ^C-a = abort)" + print("(^C-c = continue early, ^C-a = abort)") #print("[%s]\nPausing for %s seconds" % (hosts, seconds)) print("[%s]\nPausing for %s seconds" % (self._task.get_name().strip(), seconds)) time.sleep(seconds) @@ -112,7 +112,7 @@ class ActionModule(ActionBase): result['user_input'] = raw_input(prompt.encode(sys.stdout.encoding)) except KeyboardInterrupt: while True: - print '\nAction? (a)bort/(c)ontinue: ' + print('\nAction? (a)bort/(c)ontinue: ') c = getch() if c == 'c': # continue playbook evaluation diff --git a/v2/ansible/plugins/cache/memcached.py b/v2/ansible/plugins/cache/memcached.py index 135e34c2b43..e7321a5a6b5 100644 --- a/v2/ansible/plugins/cache/memcached.py +++ b/v2/ansible/plugins/cache/memcached.py @@ -30,7 +30,7 @@ from ansible.plugins.cache.base import BaseCacheModule try: import memcache except ImportError: - print 'python-memcached is required for the memcached fact cache' + print('python-memcached is required for the memcached fact cache') sys.exit(1) diff --git a/v2/ansible/plugins/cache/redis.py b/v2/ansible/plugins/cache/redis.py index 291ce81c474..287c14bd2a2 100644 --- a/v2/ansible/plugins/cache/redis.py +++ b/v2/ansible/plugins/cache/redis.py @@ -28,7 +28,7 @@ from ansible.plugins.cache.base import BaseCacheModule try: from redis import StrictRedis except ImportError: - print "The 'redis' python module is required, 'pip install redis'" + print("The 'redis' python module is required, 'pip install redis'") sys.exit(1) class CacheModule(BaseCacheModule): diff --git a/v2/ansible/utils/display.py b/v2/ansible/utils/display.py index e30ae225cfa..f132d4383f9 100644 --- a/v2/ansible/utils/display.py +++ b/v2/ansible/utils/display.py @@ -43,14 +43,14 @@ class Display: if not log_only: if not stderr: try: - print msg2 + print(msg2) except UnicodeEncodeError: - print msg2.encode('utf-8') + print(msg2.encode('utf-8')) else: try: - print >>sys.stderr, msg2 + print(msg2, file=sys.stderr) except UnicodeEncodeError: - print >>sys.stderr, msg2.encode('utf-8') + print(msg2.encode('utf-8'), file=sys.stderr) if C.DEFAULT_LOG_PATH != '': while msg.startswith("\n"): msg = msg.replace("\n","") From d85f97ccfd4e3c61f479c7055088bb8d4d74a51d Mon Sep 17 00:00:00 2001 From: Ian Dotson Date: Mon, 13 Apr 2015 16:31:16 -0400 Subject: [PATCH 12/12] Change how we're calling StringIO since we're now importing the class rather than a module. --- v2/ansible/plugins/action/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2/ansible/plugins/action/__init__.py b/v2/ansible/plugins/action/__init__.py index be83539def6..30d1641090e 100644 --- a/v2/ansible/plugins/action/__init__.py +++ b/v2/ansible/plugins/action/__init__.py @@ -319,7 +319,7 @@ class ActionBase: filter only leading lines since multiline JSON is valid. ''' - filtered_lines = StringIO.StringIO() + filtered_lines = StringIO() stop_filtering = False for line in data.splitlines(): if stop_filtering or line.startswith('{') or line.startswith('['):