Skip to content

Instantly share code, notes, and snippets.

View mkrizek's full-sized avatar

Martin Krizek mkrizek

View GitHub Profile
@mkrizek
mkrizek / repro.sh
Last active November 9, 2017 15:41
#!/bin/bash
TMP_DIR=tmp_include_roles_repro
mkdir -p $TMP_DIR/roles/{x,y}/tasks
cat > $TMP_DIR/playbook.yml << EOF
- hosts: localhost
tasks:
- set_fact:
role_name_in_fact: "x"
#!/bin/bash
TMP_DIR=tmp_group_vars
mkdir -p $TMP_DIR/{dir,group_vars,inv}/
cat > $TMP_DIR/playbook.yml << EOF
- include: dir/playbook2.yml
EOF
diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py
index 6a9428ddfd..a6bee588ef 100644
--- a/lib/ansible/plugins/strategy/__init__.py
+++ b/lib/ansible/plugins/strategy/__init__.py
@@ -865,10 +865,10 @@ class StrategyBase:
# * raise an error or show a warning when a conditional is used
# on a meta task that doesn't support them
- def _evaluate_conditional(h):
- all_vars = self._variable_manager.get_vars(play=iterator._play, host=h, task=task)
@mkrizek
mkrizek / .py
Created February 12, 2018 12:35
35356-unit-test
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import patch, MagicMock
@mkrizek
mkrizek / 36028.sh
Created February 26, 2018 13:08
36028.sh
#!/bin/bash
DIR=tmp_36028
mkdir -p $DIR/roles/my_role/{tasks,library}
cat > $DIR/playbook.yml << EOF
- hosts: localhost
gather_facts: no
pre_tasks:
@mkrizek
mkrizek / 36028.sh
Created February 26, 2018 13:42
repro-36028
#!/bin/bash
DIR=tmp_36028
mkdir -p $DIR/roles/{my_role,my_role2}/{tasks,library}
cat > $DIR/playbook.yml << EOF
- hosts: localhost
gather_facts: no
roles:
diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py
index d9a0c185e8..5a2a9bcc09 100644
--- a/lib/ansible/plugins/strategy/linear.py
+++ b/lib/ansible/plugins/strategy/linear.py
@@ -335,6 +335,24 @@ class StrategyModule(StrategyBase):
else:
new_blocks = self._load_included_file(included_file, iterator=iterator)
+
+ def _create_noop_block(original_block, parent):
@mkrizek
mkrizek / jinja-native.yaml
Created June 1, 2018 12:52
Native Jinja2 Types
# Upstream Jinja2 native types docs: http://jinja.pocoo.org/docs/2.10/nativetypes/
# Upstream Jinja2 native types PR: https://github.com/pallets/jinja/pull/708
# Jinja2 native types in Ansible PR: https://github.com/ansible/ansible/pull/32738
# ansible-devel@ announcement: https://groups.google.com/forum/#!topic/ansible-devel/o42OoC0VZ4A
# Preserving types of castings
- hosts: localhost
gather_facts: no
vars:
adict:
diff --git a/lib/ansible/executor/task_queue_manager.py b/lib/ansible/executor/task_queue_manager.py
index 67a741b989..844ab621a8 100644
--- a/lib/ansible/executor/task_queue_manager.py
+++ b/lib/ansible/executor/task_queue_manager.py
@@ -232,7 +232,7 @@ class TaskQueueManager:
new_play = play.copy()
new_play.post_validate(templar)
- new_play.handlers = new_play.compile_roles_handlers() + new_play.handlers
+ new_play.handlers = new_play.handlers + new_play.compile_roles_handlers()
diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py
index 41b74edabd..98466cb37c 100644
--- a/lib/ansible/plugins/strategy/__init__.py
+++ b/lib/ansible/plugins/strategy/__init__.py
@@ -368,7 +368,7 @@ class StrategyBase:
return self._inventory.get_host(host_name)
def search_handler_blocks_by_name(handler_name, handler_blocks):
- for handler_block in handler_blocks:
+ for handler_block in reversed(handler_blocks):