From 345ce424c60573463e54f5964be2b3c52b2bf16d Mon Sep 17 00:00:00 2001 From: = Date: Wed, 7 Oct 2015 06:24:37 +0100 Subject: [PATCH 01/14] Explictly set the version of strict mode to use for powershell modules. --- docsite/rst/developing_modules.rst | 2 +- lib/ansible/module_utils/powershell.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docsite/rst/developing_modules.rst b/docsite/rst/developing_modules.rst index 36c8283846a..26a10193139 100644 --- a/docsite/rst/developing_modules.rst +++ b/docsite/rst/developing_modules.rst @@ -509,7 +509,7 @@ Windows modules checklist * Favour native powershell and .net ways of doing things over calls to COM libraries or calls to native executables which may or may not be present in all versions of windows * modules are in powershell (.ps1 files) but the docs reside in same name python file (.py) * look at ansible/lib/ansible/module_utils/powershell.ps1 for common code, avoid duplication -* Ansible uses strictmode so be sure to test with that enabled +* Ansible uses strictmode version 2.0 so be sure to test with that enabled * start with:: #!powershell diff --git a/lib/ansible/module_utils/powershell.ps1 b/lib/ansible/module_utils/powershell.ps1 index 58e121b95a4..c150b077443 100644 --- a/lib/ansible/module_utils/powershell.ps1 +++ b/lib/ansible/module_utils/powershell.ps1 @@ -26,7 +26,7 @@ # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -Set-StrictMode -Version Latest +Set-StrictMode -Version 2.0 # Ansible v2 will insert the module arguments below as a string containing # JSON; assign them to an environment variable and redefine $args so existing From 354383874f9accfd265dd290a2377477414073ca Mon Sep 17 00:00:00 2001 From: Florian Apolloner Date: Wed, 7 Oct 2015 11:37:23 +0200 Subject: [PATCH 02/14] Show a nice error if the role name is missing. --- lib/ansible/cli/galaxy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py index 60970929ac1..3903275a2f0 100644 --- a/lib/ansible/cli/galaxy.py +++ b/lib/ansible/cli/galaxy.py @@ -167,8 +167,8 @@ class GalaxyCLI(CLI): force = self.get_opt('force', False) offline = self.get_opt('offline', False) - role_name = self.args.pop(0).strip() - if role_name == "": + role_name = self.args.pop(0).strip() if self.args else None + if not role_name: raise AnsibleOptionsError("- no role name specified for init") role_path = os.path.join(init_path, role_name) if os.path.exists(role_path): From c4c8493f1b5480d3bebf659dac15ce55e3608327 Mon Sep 17 00:00:00 2001 From: deyvsh Date: Wed, 7 Oct 2015 12:33:39 +0100 Subject: [PATCH 03/14] Add an example for map() to the filters page --- docsite/rst/playbooks_filters.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docsite/rst/playbooks_filters.rst b/docsite/rst/playbooks_filters.rst index b8a847a5e7d..301e556f1d0 100644 --- a/docsite/rst/playbooks_filters.rst +++ b/docsite/rst/playbooks_filters.rst @@ -527,11 +527,18 @@ To escape special characters within a regex, use the "regex_escape" filter:: # convert '^f.*o(.*)$' to '\^f\.\*o\(\.\*\)\$' {{ '^f.*o(.*)$' | regex_escape() }} + +To make use of one attribute from each item in a list of complex variables, use the "map" filter (see the `Jinja2 map() docs`_ for more):: + + # get a comma-separated list of the mount points (e.g. "/,/mnt/stuff") on a host + {{ ansible_mounts|map(attribute='mount')|join(',') }} A few useful filters are typically added with each new Ansible release. The development documentation shows how to extend Ansible filters by writing your own as plugins, though in general, we encourage new ones to be added to core so everyone can make use of them. +.. _Jinja2 map() docs: http://jinja.pocoo.org/docs/dev/templates/#map + .. _builtin filters: http://jinja.pocoo.org/docs/templates/#builtin-filters .. seealso:: From 254d6be5201903c6529aa5e0dc83383b74dda3f8 Mon Sep 17 00:00:00 2001 From: Juraci Date: Wed, 7 Oct 2015 10:10:57 -0300 Subject: [PATCH 04/14] Adding get_path method to Task class --- lib/ansible/playbook/task.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index c225c8b9722..bc32903f7f8 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -101,6 +101,12 @@ class Task(Base, Conditional, Taggable, Become): super(Task, self).__init__() + def get_path(self): + ''' return the absolute path of the task with its line number ''' + + if hasattr(self, '_ds'): + return "%s:%s" % (self._ds._data_source, self._ds._line_number) + def get_name(self): ''' return the name of the task ''' From e52950a939aa03b0dd100283a757723349eced1e Mon Sep 17 00:00:00 2001 From: Juraci Date: Wed, 7 Oct 2015 10:11:50 -0300 Subject: [PATCH 05/14] Displaying task_path on task start when verbosity is more than 3 --- lib/ansible/plugins/callback/default.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ansible/plugins/callback/default.py b/lib/ansible/plugins/callback/default.py index e5f8ed12ccc..a10ee349c3c 100644 --- a/lib/ansible/plugins/callback/default.py +++ b/lib/ansible/plugins/callback/default.py @@ -110,6 +110,10 @@ class CallbackModule(CallbackBase): def v2_playbook_on_task_start(self, task, is_conditional): self._display.banner("TASK [%s]" % task.get_name().strip()) + if self._display.verbosity > 3: + path = task.get_path() + if path: + self._display.display("task path: %s" % path, color='cyan') def v2_playbook_on_cleanup_task_start(self, task): self._display.banner("CLEANUP TASK [%s]" % task.get_name().strip()) From dac3684fd1c871b31d17d2b47e82bb9708467e37 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 7 Oct 2015 12:12:35 -0400 Subject: [PATCH 06/14] changed task color to dark gray to keep it from being confused with ignore/skip --- lib/ansible/plugins/callback/default.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/plugins/callback/default.py b/lib/ansible/plugins/callback/default.py index a10ee349c3c..42bd64436fa 100644 --- a/lib/ansible/plugins/callback/default.py +++ b/lib/ansible/plugins/callback/default.py @@ -113,7 +113,7 @@ class CallbackModule(CallbackBase): if self._display.verbosity > 3: path = task.get_path() if path: - self._display.display("task path: %s" % path, color='cyan') + self._display.display("task path: %s" % path, color='dark gray') def v2_playbook_on_cleanup_task_start(self, task): self._display.banner("CLEANUP TASK [%s]" % task.get_name().strip()) From 155282f94aea92675019dcc3be5927f729feaf94 Mon Sep 17 00:00:00 2001 From: deyvsh Date: Wed, 7 Oct 2015 17:40:50 +0100 Subject: [PATCH 07/14] Indicate that credstash plugin is new in v2 Also offer a poor-man's alternative. --- docsite/rst/playbooks_lookups.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docsite/rst/playbooks_lookups.rst b/docsite/rst/playbooks_lookups.rst index 877ec4702f4..ea98adf99a6 100644 --- a/docsite/rst/playbooks_lookups.rst +++ b/docsite/rst/playbooks_lookups.rst @@ -203,6 +203,7 @@ default empty string return value if the key is not in the ini file The Credstash Lookup ```````````````````` +.. versionadded:: 2.0 Credstash is a small utility for managing secrets using AWS's KMS and DynamoDB: https://github.com/LuminalOSS/credstash @@ -233,7 +234,9 @@ You can specify regions or tables to fetch secrets from:: - name: "Test credstash lookup plugin -- get the company's github password" debug: msg="Credstash lookup! {{ lookup('credstash', 'company-github-password', table='company-passwords') }}" +If you're not using 2.0 yet, you can do something similar with the credstash tool and the pipe lookup (see below):: + debug: msg="Poor man's credstash lookup! {{ lookup('pipe', 'credstash -r us-west-1 get my-other-password') }}" .. _more_lookups: From aec58bfbb3c3f5cb9391ed0358743a0619dcd56d Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Wed, 7 Oct 2015 14:26:23 -0400 Subject: [PATCH 08/14] Update playbooks_blocks.rst Remove heading that appears to be extraneous. --- docsite/rst/playbooks_blocks.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docsite/rst/playbooks_blocks.rst b/docsite/rst/playbooks_blocks.rst index 4d391c76186..7dce94b6d72 100644 --- a/docsite/rst/playbooks_blocks.rst +++ b/docsite/rst/playbooks_blocks.rst @@ -36,7 +36,6 @@ privilege escalation for all the enclosed tasks. Error Handling `````````````` -About Blocks Blocks also introduce the ability to handle errors in a way similar to exceptions in most programming languages. .. code-block:: YAML From 8a1426059f2a55adf2c2111192f25f53a0d870b8 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 7 Oct 2015 12:47:35 -0400 Subject: [PATCH 09/14] added entry for task path/line when verbose --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a65765d0718..bf342ed4cc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -285,6 +285,7 @@ you avoid ever writing sensitive plaintext to disk. * ansible-vault rekey accepts the --new-vault-password-file option. * Configuration items defined as paths (local only) now all support shell style interpolations. * Many fixes and new options added to modules, too many to list here. +* Now you can see task file and line number when using verbosity of 3 or above. ## 1.9.2 "Dancing In the Street" - Jun 26, 2015 From 638bc14566f8f1044d1bbd8f57e68c348ec82b89 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 7 Oct 2015 15:41:11 -0400 Subject: [PATCH 10/14] now deps is always a list --- lib/ansible/cli/galaxy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py index 3903275a2f0..716eac9616d 100644 --- a/lib/ansible/cli/galaxy.py +++ b/lib/ansible/cli/galaxy.py @@ -347,7 +347,7 @@ class GalaxyCLI(CLI): # install dependencies, if we want them if not no_deps and installed: - role_dependencies = role.metadata.get('dependencies', []) + role_dependencies = role.metadata.get('dependencies') or [] for dep in role_dependencies: self.display.debug('Installing dep %s' % dep) dep_req = RoleRequirement() From c77733e64eade7d1764c23142305c99ad21b4143 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 7 Oct 2015 15:52:06 -0400 Subject: [PATCH 11/14] added docs for commonly used region parameter in some ec2 modules --- .../utils/module_docs_fragments/ec2.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lib/ansible/utils/module_docs_fragments/ec2.py diff --git a/lib/ansible/utils/module_docs_fragments/ec2.py b/lib/ansible/utils/module_docs_fragments/ec2.py new file mode 100644 index 00000000000..3681c0ea8d1 --- /dev/null +++ b/lib/ansible/utils/module_docs_fragments/ec2.py @@ -0,0 +1,29 @@ +# (c) 2015, Ansible, Inc +# +# 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 . + + +class ModuleDocFragment(object): + + # EC2 only documentation fragment + DOCUMENTATION = """ +options: + region: + description: + - The AWS region to use. If not specified then the value of the EC2_REGION environment variable, if any, is used. See U(http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region) + required: false + aliases: [ 'aws_region', 'ec2_region' ] +""" From d8769c93c7410e562b1e8189772a707f05230ffb Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 7 Oct 2015 16:41:58 -0400 Subject: [PATCH 12/14] updated ec2 region description to add missing other env var --- lib/ansible/utils/module_docs_fragments/ec2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/utils/module_docs_fragments/ec2.py b/lib/ansible/utils/module_docs_fragments/ec2.py index 3681c0ea8d1..92557407260 100644 --- a/lib/ansible/utils/module_docs_fragments/ec2.py +++ b/lib/ansible/utils/module_docs_fragments/ec2.py @@ -23,7 +23,7 @@ class ModuleDocFragment(object): options: region: description: - - The AWS region to use. If not specified then the value of the EC2_REGION environment variable, if any, is used. See U(http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region) + - The AWS region to use. If not specified then the value of the AWS_REGION or EC2_REGION environment variable, if any, is used. See U(http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region) required: false aliases: [ 'aws_region', 'ec2_region' ] """ From 27e5271cdfb3dc84a5920c05b3e6c7e851c99125 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 7 Oct 2015 21:25:38 -0400 Subject: [PATCH 13/14] Added bigip_gtm_wide_ip module to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf342ed4cc1..6af025ee375 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -109,6 +109,7 @@ New Modules: * amazon: s3_lifecycle * amazon: s3_logging * apk +* bigip_gtm_wide_ip * bundler * centurylink: clc_blueprint_package * centurylink: clc_firewall_policy From ae69409d9c7024f2fc7f74ab26ba75268673fa59 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 7 Oct 2015 21:38:11 -0400 Subject: [PATCH 14/14] added openstack fact modules --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6af025ee375..e1275cd1e8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -156,7 +156,9 @@ New Modules: * openstack: os_client_config * openstack: os_floating_ip * openstack: os_image +* openstack: os_image_facts * openstack: os_network +* openstack: os_network_facts * openstack: os_nova_flavor * openstack: os_object * openstack: os_router