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
9b587d44
Commit
9b587d44
authored
May 09, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #339 from mgwilliams/feature-unicode
Allow unicode (utf8) in templates
parents
dd5f5359
b89d8db7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
lib/ansible/runner.py
+3
-3
lib/ansible/utils.py
+3
-2
No files found.
lib/ansible/runner.py
View file @
9b587d44
...
...
@@ -29,6 +29,7 @@ import tempfile
import
time
import
base64
import
getpass
import
codecs
import
ansible.constants
as
C
import
ansible.connection
...
...
@@ -202,7 +203,7 @@ class Runner(object):
afd
,
afile
=
tempfile
.
mkstemp
()
afo
=
os
.
fdopen
(
afd
,
'w'
)
afo
.
write
(
data
)
afo
.
write
(
data
.
encode
(
"utf8"
)
)
afo
.
flush
()
afo
.
close
()
...
...
@@ -432,7 +433,6 @@ class Runner(object):
# apply templating to source argument
inject
=
self
.
setup_cache
.
get
(
conn
.
host
,{})
print
source
source
=
utils
.
template
(
source
,
inject
,
self
.
setup_cache
)
# files are saved in dest dir, with a subdir for each host, then the filename
...
...
@@ -542,7 +542,7 @@ class Runner(object):
copy_module
=
self
.
_transfer_module
(
conn
,
tmp
,
'copy'
)
# template the source data locally
source_data
=
file
(
utils
.
path_dwim
(
self
.
basedir
,
source
)
)
.
read
()
source_data
=
codecs
.
open
(
utils
.
path_dwim
(
self
.
basedir
,
source
),
encoding
=
"utf8"
)
.
read
()
resultant
=
''
try
:
resultant
=
utils
.
template
(
source_data
,
inject
,
self
.
setup_cache
)
...
...
lib/ansible/utils.py
View file @
9b587d44
...
...
@@ -21,6 +21,7 @@ import sys
import
os
import
shlex
import
re
import
codecs
import
jinja2
import
yaml
import
optparse
...
...
@@ -233,7 +234,7 @@ def varReplace(raw, vars):
def
template
(
text
,
vars
,
setup_cache
,
no_engine
=
False
):
''' run a text buffer through the templating engine '''
vars
=
vars
.
copy
()
text
=
varReplace
(
str
(
text
),
vars
)
text
=
varReplace
(
unicode
(
text
),
vars
)
vars
[
'hostvars'
]
=
setup_cache
if
no_engine
:
# used when processing include: directives so that Jinja is evaluated
...
...
@@ -251,7 +252,7 @@ def double_template(text, vars, setup_cache):
def
template_from_file
(
path
,
vars
,
setup_cache
,
no_engine
=
False
):
''' run a file through the templating engine '''
data
=
file
(
path
)
.
read
()
data
=
codecs
.
open
(
path
,
encoding
=
"utf8"
)
.
read
()
return
template
(
data
,
vars
,
setup_cache
,
no_engine
=
no_engine
)
def
parse_yaml
(
data
):
...
...
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