Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
c4c3cc31
Commit
c4c3cc31
authored
Nov 19, 2014
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Transform both values of a task name into a byte str prior to comparing
Fixes #9571
parent
a897a5ea
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
3 deletions
+32
-3
lib/ansible/callbacks.py
+2
-0
lib/ansible/utils/__init__.py
+11
-0
test/integration/Makefile
+2
-3
test/integration/unicode.yml
+17
-0
No files found.
lib/ansible/callbacks.py
View file @
c4c3cc31
...
...
@@ -603,11 +603,13 @@ class PlaybookCallbacks(object):
call_callback_module
(
'playbook_on_no_hosts_remaining'
)
def
on_task_start
(
self
,
name
,
is_conditional
):
name
=
utils
.
to_bytes
(
name
)
msg
=
"TASK: [
%
s]"
%
name
if
is_conditional
:
msg
=
"NOTIFIED: [
%
s]"
%
name
if
hasattr
(
self
,
'start_at'
):
self
.
start_at
=
utils
.
to_bytes
(
self
.
start_at
)
if
name
==
self
.
start_at
or
fnmatch
.
fnmatch
(
name
,
self
.
start_at
):
# we found out match, we can get rid of this now
del
self
.
start_at
...
...
lib/ansible/utils/__init__.py
View file @
c4c3cc31
...
...
@@ -1265,13 +1265,24 @@ def make_su_cmd(su_user, executable, cmd):
)
return
(
'/bin/sh -c '
+
pipes
.
quote
(
sudocmd
),
None
,
success_key
)
# For v2, consider either using kitchen or copying my code from there for
# to_unicode and to_bytes handling (TEK)
_TO_UNICODE_TYPES
=
(
unicode
,
type
(
None
))
def
to_unicode
(
value
):
# Use with caution -- this function is not encoding safe (non-utf-8 values
# will cause tracebacks if they contain bytes from 0x80-0xff inclusive)
if
isinstance
(
value
,
_TO_UNICODE_TYPES
):
return
value
return
value
.
decode
(
"utf-8"
)
def
to_bytes
(
value
):
# Note: value is assumed to be a basestring to mirror to_unicode. Better
# implementations (like kitchen.text.converters.to_bytes) bring that check
# into the function
if
isinstance
(
value
,
str
):
return
value
return
value
.
encode
(
'utf-8'
)
def
get_diff
(
diff
):
# called by --diff usage in playbook and runner via callbacks
...
...
test/integration/Makefile
View file @
c4c3cc31
...
...
@@ -34,13 +34,12 @@ includes:
unicode
:
ansible-playbook unicode.yml
-i
$(INVENTORY)
-e
@
$(VARS_FILE)
-v
$(TEST_FLAGS)
# Test the start-at-task flag #9571
ansible-playbook unicode.yml
-i
$(INVENTORY)
-e
@
$(VARS_FILE)
-v
--start-at-task
'*¶'
-e
'start_at_task=True'
$(TEST_FLAGS)
non_destructive
:
ansible-playbook non_destructive.yml
-i
$(INVENTORY)
-e
@
$(VARS_FILE)
$(CREDENTIALS_ARG)
-v
$(TEST_FLAGS)
mine
:
ansible-playbook mine.yml
-i
$(INVENTORY)
-e
@
$(VARS_FILE)
$(CREDENTIALS_ARG)
-v
$(TEST_FLAGS)
destructive
:
ansible-playbook destructive.yml
-i
$(INVENTORY)
-e
@
$(VARS_FILE)
$(CREDENTIALS_ARG)
-v
$(TEST_FLAGS)
...
...
test/integration/unicode.yml
View file @
c4c3cc31
...
...
@@ -41,3 +41,20 @@
tasks
:
-
debug
:
msg='Unicode is a good thing ™'
-
debug
:
msg=АБВГД
# Run this test by adding to the CLI: -e start_at_task=True --start-at-task '*¶'
-
name
:
'
Show
that
we
can
skip
to
unicode
named
tasks'
hosts
:
localhost
gather_facts
:
false
vars
:
flag
:
'
original'
start_at_task
:
False
tasks
:
-
name
:
'
Override
flag
var'
set_fact
:
flag='new'
-
name
:
'
A
unicode
task
at
the
end
of
the
playbook:
¶'
assert
:
that
:
-
'
flag
==
"original"'
when
:
start_at_task|bool
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment