[ https://issues.apache.org/jira/browse/AMBARI-3556?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13800531#comment-13800531 ]
Andrew Onischuk commented on AMBARI-3556: ----------------------------------------- These changes can be described by the lines below: {code} - def __init__(self): + def __init__(self, basedir=None, params=None): + """ + @param basedir: basedir/files, basedir/templates are the places where templates / static files + are looked up + @param params: configurations dictionary (this will be accessible in the templates) + """ {code} So now our code will just like this: {code} def main(): # this we should pass as parameter basedir = "/HDP/Stack2.0.6/HBase/" # this will be parsed from json config = { "hadoop_base": "/opt/hadoop", "hdfs_path": "/home/hduser/hdfs", "jobtrackerport": "8021", "replication": "3", "hdfsport": "8020", "slaves": ["hadoop-02","hadoop-03","hadoop-04"], "master": "hadoop-01", "version": "0.20.203.0", "java_home": "/usr/jdk" } with Environment(basedir, config) as env: # ... File("/lol1.txt", owner = "root", group = "root", content = Template("lol1.txt.j2")) # ... File("/a/b/file.txt", owner = "root", group = "root", content = StaticFile("some1.txt")) # ... env.run() {code} {code} basedir files some1.txt templates lol1.txt.j2 any_location script.py {code} > Resource management. Rewrite Templates and Static Files to declarative rather > than cookbook-oriented > ---------------------------------------------------------------------------------------------------- > > Key: AMBARI-3556 > URL: https://issues.apache.org/jira/browse/AMBARI-3556 > Project: Ambari > Issue Type: Bug > Reporter: Andrew Onischuk > Assignee: Andrew Onischuk > Fix For: 1.5.0 > > > 1) Since Kokki should be used with kitchen and cookbooks. Templates are not > working then we use declative form. This can be fixed by replacing the > location of cookbook with our custom param passed to the enviroment. > 2) Also Here we should change the way variables are sent to templating > engine. Since we will be getting variables from json configurations files and > then parsing it into variable, probaby a dictionary of dictionaries. We > should not use any files with configurations (like it is done in Kokki), but > just pass the dictionary with the configuration params to the enviroment, > which should handle it. -- This message was sent by Atlassian JIRA (v6.1#6144)