Copy local file in Saltstack - salt-stack

I am in a masterless salt-minion, but I would like to manage a file locally. How do I copy a local file around in an Saltstack .sls file?
E.g. something like
/etc/mymodule/proxy.conf:
file.managed:
- source: /mymodule.conf

I guess you want to take a look at file.copy instead of file.managed.
State file.managed uses source key to download content from URI (can be salt://, http://, etc.) - it won't intelligently guess that, if there is no URI scheme in source value, then it should use local path on the minion it runs at.

Related

How to download files from SFTP that doesn't have actural files in Synapse?

I have a little bit complicate situation here:
I need to download files from a SFTP daily. I connect to the SFTP with username and SSH key, the keys have a passphrase.
This SFTP has no actual files. All the files on the server is 0 bytes. The server will dynamicly generate the file if it get a "get" command.
So when I connect the SFTP with Winscp, everything went perfectly.
But I have to do it in Synapse.
I managed to connect it in Pipeline with copy activity, and I managed to download all the files, but with no data content inside.
Does anyone know how I can download the files with content?
If you actually have files with content in SFTP location, then they should also be automatically copied using the pipeline in your Synapse. In case if you just want to copy the files that are having the content and ignore empty files, then you will have to use a get metadata activity to check the size of the file (i.e., > 0 bytes) and then filter those files only to copy to your desired destination. Using the childItems you can get the fileName, Type and Size and use these properties in the subsequent copy activity to only copy filter files to your destination.

Is there a way to serve a directory using map local and Charles?

I have a network request in the form of:
http://www.blahblah.com/folder/version/dist
I would like to add a rule to the Map Local option in Charles, in order to serve a directory that looks like:
Users/me/Documents/code/project/dist
The file structure of both dist folders are the same. My current request rule is: http://www.blahblah.com/folder/*/dist, and I'm asking it to serve Users/me/Documents/code/project/dist in its place, however, the files still come from the original requested resource.
Is there a way to proxy a whole directory?
You should be able to do so, by what is said in the CharlesProxy documentation:
If you are testing css, swf or image changes you can map those file types to your local development copy of the website so you can browse the live site with all your development assets. Create a mapping from live.com/*.css to the root of your local development copy, and similar mappings for the other file types. Alternatively you can map whole directories or individual files as required.
I guess your problem might be on the path where you are trying to map from. I would say you need to add an asterisk at the end of your path, something like:
http://www.blahblah.com/folder/*/dist/*
You can try to add the .css as done in the example
http://www.blahblah.com/folder/*/dist/*.css

vagrant/puphpet: adding a custom nginx default conf file

i use Puphpet to create a local testing vagrant /VM servers and my question is:
I ssh into the VM to change my etc/nginx/conf.d/default.conf config file, but every now and then when either i have to to or choose to i destroy the said vm to mainly re-create or because of issue, i need to repeat the above process of having to update a few config files.
Is there a way say within the vagrantfile or the comman.yaml (puphpet) file to actually add this automatically so i don't need to do this at all.
You could create a shell script in puphpet/files/exec-once[1] to replace your default.conf file.

Reading/writing a text file in a servlet, where should this file be stored in JBoss?

I have servlet deployed in JBoss. I want to read/write data into a text file based on the client input. Where should this text file be put in the JBoss directory structure?
There the /data directory is for.
Its absolute path is available by the jboss.server.data.dir system property.
File dataDir = new File(System.getProperty("jboss.server.data.dir"));
File yourFile = new File(dataDir, "filename.ext");
// ...
See also:
JBoss Wiki - JBoss Properties
Note that you're this way tight-coupling the web application code to a specific server. If you ever want to change servers, keep in mind to change the above code as well to whatever the new server supports (or not).

Nautilus script: $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS empty for WebDAV folders

When writing a Nautilus script, $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS gives the path to the file whose context menu has been clicked, for instance /home/nico/test.txt.
But when the file is within a WebDAV share, the variable is empty.
Is it a bug?
How to get the path for a WebDAV file?
My script is intended to be used for files on WebDAV shares.
I have just found this list of variables:
https://help.ubuntu.com/community/NautilusScriptsHowto
The one I was looking for is $NAUTILUS_SCRIPT_SELECTED_URIS, it works on WebDAV too, returning for instance dav://admin#localhost:8080/alfresco/webdav/User%20Homes/leo/test.txt
Nautilus' $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS is only for LOCAL (mounted) files, and by design is blank for remote files, like $1, $2...
For REMOTE files, like WebDAV, or Samba network shares, FTP servers, (or any other location where $NAUTILUS_SCRIPT_CURRENT_URI is not like file://...), use $NAUTILUS_SCRIPT_SELECTED_URIS

Resources