file.file_exists & file.directory_exists won't work
See original GitHub issueThis software called PrinterAgent is installed on a windows minion, all I want to do is add a flag file or directory to the newest version that we roll out and then just if it doesn’t exists then it should simply follow through with the install.
State: (I tried this state on 5 different windows minions, it always seems to not return what I want it to. Also I tried the same thing with file.file_exists and added the file in the directory and its the same issue.)
{% if not salt['file.directory_exists']('C:\BCFranchise\PrinterAgent\v1.0.0.10') %}
#Check for backed up JPOS
backup-jpos:
file.copy:
- name: c:\Confidential\PrinterAgentBackup\jpos.xml
- source: c:\Confidential\PrinterAgent\jpos.xml
- force: True
- makedirs: True
- skip_verify: True
- state_output: mixed
delete-printer-agent-directory:
cmd.run:
- name: rm -r c:\Confidential\PrinterAgent -Force
- shell: powershell
- state_output: mixed
# Install PrinterAgent
copy_printer_agent_directory:
file.recurse:
- name: c:\Confidential\PrinterAgent
- source: salt://files/printeragent/{{ pillar['printeragent-versions'] }}/PrinterAgent/
- makedirs: True
- state_output: mixed
# Restores JPOS
restore-jpos:
file.copy:
- name: c:\Confidential\PrinterAgent\jpos.xml
- source: c:\Confidential\PrinterAgentBackup\jpos.xml
- force: True
- skip_verify: True
{% endif %}
Also Yes, I made sure that the path name is correct and the directory/file name, also its good to note that if I run the command from the command line it returns correctly, its only when I put it into a state file within a Jinja template that it errors out.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How do I check whether a file exists without exceptions?
To check whether a Path object exists independently of whether is it a file or directory, use exists() : if my_file.exists(): # path...
Read more >Python Check if File Exists: How to Check If a Directory Exists?
Python exists() method is used to check whether specific file or directory exists or not. It is also used to check if a...
Read more >file_exists - Manual - PHP
Returns true if the file or directory specified by filename exists; false otherwise. Note: This function will return false for symlinks pointing to ......
Read more >No such file or directory? But the file exists! - Ask Ubuntu
The file exists (e.g. file command works), making for a puzzling error message. This may mean there's a problem with the loader. Categories...
Read more >Check If a File or Directory Exists in Java - Baeldung
In this quick tutorial, we're going to get familiar with different ways to check the existence of a file or directory.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
@Cybergenik Can you provide the error and/or traceback that you receive when attempting to run the above state?