Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow templating local files #13873

Closed
dnd opened this issue Jul 1, 2014 · 10 comments · Fixed by #14228
Closed

Allow templating local files #13873

dnd opened this issue Jul 1, 2014 · 10 comments · Fixed by #14228
Labels
Bug broken, incorrect, or confusing behavior Regression The issue is a bug that breaks functionality known to work in previous releases.
Milestone

Comments

@dnd
Copy link
Contributor

dnd commented Jul 1, 2014

Currently file.managed does not allow templating of local files. There have been a few times I have had files inside of a git repo that I have cloned to a server and wanted to template them in the current context. Unfortunately that doesn't seem possible at the moment.

@whiteinge whiteinge added this to the Approved milestone Jul 1, 2014
@whiteinge
Copy link
Contributor

Thanks. This would be a useful addition.

@terminalmage
Copy link
Contributor

This should work... IIRC, the file.managed state caches the file in the minion cache and renders the template there before comparing it to the targeted file. This might actually be a bug. I'll investigate.

@terminalmage
Copy link
Contributor

Ahh, OK, so I was mistaken. It appears that local files cannot be used as a source for file.managed states, period. So it's not simply a matter of templating not working.

@whiteinge
Copy link
Contributor

I would like to have a standalone "render" execution module so you can tap into the renderer system from arbitrary places. Plus it could be reused in other modules that are currently repeating the templating boilerplate code. I started on an implementation -- probably can't finish this week but I think I can make it happen before the Helium RC.

@terminalmage
Copy link
Contributor

OK, just FYI the rendering code is also in the cron.file state, I abstracted it a long time ago. So, if you make any changes, refs in salt/states/cron.py will also likely need to be updated.

@cro
Copy link
Contributor

cro commented Jul 1, 2014

@whiteinge: me too--I envision using it to ease config file management during application development.

C. R. Oldham, Engineer, SaltStack
cr@saltstack.com

On Jul 1, 2014, at 4:50 PM, Seth House notifications@github.com wrote:

I would like to have a standalone "render" execution module so you can tap into the renderer system from arbitrary places. Plus it could be reused in other modules that are currently repeating the templating boilerplate code. I started on an implementation -- probably can't finish this week but I think I can make it happen before the Helium RC.


Reply to this email directly or view it on GitHub.

@yanatan16
Copy link
Contributor

I have been templating local files with file:// prefix with file.managed for a while, but that broke when i pulled the latest develop. It was working on the latest stable (v2014.1.5)

My test case:

# salt-call state.single file.managed name=/tmp/docker-builds/devsite-server/Dockerfile source=file:///src/devsite/config/Dockerfile.configured template=jinja
[INFO    ] Loading fresh modules for state activity
[INFO    ] Running state [/tmp/docker-builds/devsite-server/Dockerfile] at time 16:08:37.788876
[INFO    ] Executing state file.managed for /tmp/docker-builds/devsite-server/Dockerfile
[ERROR   ] Unable to manage file: No connection adapters were found for 'file:///src/devsite/config/Dockerfile.configured'
[INFO    ] Completed state [/tmp/docker-builds/devsite-server/Dockerfile] at time 16:08:37.793651
local:
----------
          ID: /tmp/docker-builds/devsite-server/Dockerfile
    Function: file.managed
      Result: False
     Comment: Unable to manage file: No connection adapters were found for 'file:///src/devsite/config/Dockerfile.configured'
     Started: 16:08:37.788876
     Duration: 4 ms
     Changes:

Summary
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1

@stas
Copy link
Contributor

stas commented Jul 14, 2014

We've recently stumbled upon a similar issue. It would be very handy to have the file:// source type support for file state.

----------
          ID: deploy_app_static
    Function: file.recurse
        Name: /var/www/app/static/
      Result: False
     Comment: Invalid source 'file:///var/www/git/static' (must be a salt:// URI)
     Changes:   
----------

@terminalmage
Copy link
Contributor

This is fixed in #14228, and I've added tests to keep this from regressing again. Thanks for reporting, we should be able to get this into the next release.

@terminalmage terminalmage added Bug and removed Feature labels Jul 15, 2014
@stas
Copy link
Contributor

stas commented Jul 15, 2014

💃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Regression The issue is a bug that breaks functionality known to work in previous releases.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants