Comments (15)
Still an issue. By the way win_get_url handles it correctly.
from ansible.windows.
From @jhawkesworth on Apr 18, 2018 08:49
I don't think it can work like this as the win_package path parameter can take a url or a windows path, so you could get undesirable results if you expanded environment variable names in urls.
If you need to use %TEMP% dir you can retrieve it from facts. Like this
$ cat test.yml
---
- hosts: windowsbox
gather_facts: true
vars:
msi_path: '{{ansible_env.TEMP}}\bla.msi'
tasks:
- name: show path
debug:
var: msi_path
from ansible.windows.
From @jborean93 on Apr 18, 2018 09:09
@jhawkesworth it could still be doable, we would just need to verify if the value for path is an actual path and then expand if it is otherwise keep it the same as before.
from ansible.windows.
From @jhawkesworth on Apr 18, 2018 09:48
@jborean93 yep I think we talked about this before and were reluctant to have a 'path_or_url' type, so its still a 'str' in the module parameters.
I wonder if it would be better to move over time to having 2 mutually-exclusive path
and url
parameters, rather than trying to get path
to handle both things. Less intuitive I suppose.
from ansible.windows.
From @olenm on Apr 19, 2018 17:49
I can argue either way to have it path
and url
or simply have path
handle both url's and file-paths. Should be easy to see if a protocol is defined in the string of path
and deduce if it's a URL - then parse it accordingly (including basic auth-fun), and if not use path and pull out %var%
blobs. - And hope nobody uses %vars%
in their URL paths.
Thanks! I will attempt the ansible_env.TEMP
instead of the windows-env-var syntax; especially since powershell MS is making the move to powershell and using ${env:bla}
(makes me wonder how long until that is supported in CMD and other windows-areas).
Edit: I would suggest maybe add to the win_package
docs that %vars% are currently not supported? I was using %vars%
elsewhere and assumed it should work here too.
from ansible.windows.
From @olenm on Apr 19, 2018 20:29
Well I tried {{ansible_env.TEMP}}
and it failed on another part - actually it hung forever (maybe a different issue completely - likely due to "arguments": https://app.datadoghq.com/account/settings#agent/windows
I'll tinker with it later and may file another bug - currently 'fix' is to keep using win_msi
for the time being.
from ansible.windows.
From @trondhindenes on Apr 22, 2018 08:29
Powershell doesn't have the concept of %VAR%
, that's a cmd thing. IMHO this is not a bug.
from ansible.windows.
From @jborean93 on Apr 23, 2018 08:13
@trondhindenes, we already have this ability in some other modules to automatically expand environment variables enclosed in %
. While I agree it isn't a PowerShell thing it's probably something we want to add here to expand path like values.
from ansible.windows.
From @jhawkesworth on Apr 24, 2018 07:02
Yeah, perhaps we didn't do a good thing allowing the DOS-style %VAR% syntax for expansion, but I guess it is understood by many.
I wonder if perhaps we should/could/already do allow ${env:var_name}
syntax and perhaps move over to in future in examples, just because we shouldn't expect playbook readers to understand DOS-isms.
@olenm - feel free to create a documentation pull request regarding explaining that you can't use path expansion currently.
I guess if we could parse out the module parameter types this could be automatically added to the documentation pages and then it would be there in the module docs.
I wonder if having a path_or_url module parameter type might be useful elsewhere, or whether it would be better to add it just to this module (probably the latter until some other places where it is useful are discovered).
from ansible.windows.
From @jborean93 on Apr 24, 2018 07:15
@jhawkesworth the good thing about dos style expansion is that we can easily expand it safely with [System.Environment]::ExpandEnvironmentVariables
whereas the latter would require us to do Invoke-Expression
which is a bit more insecure. In the end this should be a simple fix, just run https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1#L186-L198 to determine whether the expanded value is a path. If it is use that value, if it isn't use the unexpected value.
The trouble we have is that win_package allows you to specify the path as a URL whereas we probably should have made that path only and get people to use win_get_url but hindsight is 20/20.
from ansible.windows.
From @jhawkesworth on Apr 24, 2018 16:13
@jborean93 good point, I was thinking more of playbook readability than safety-of-implementation.
from ansible.windows.
From @dagwieers on Apr 26, 2018 10:27
There is one problem in the case where the intent is to store a value with the %VAR%
preserved. One such case is win_regedit where the automatic expansion is usually unwanted. So the main question for every supplied entry containing %VAR%
is whether we are the "consumer" of that data, or we are only "processing" it for someone else to consume (as-is).
The behaviour may depend on this, but should also be clearly communicated to the user in the module documentation. Does the module allow for variable expansion or not (or conditionally).
from ansible.windows.
From @shorbachuk on Feb 03, 2019 18:21
Any update or workaround on this? I have a use case and I would like to do something like this:
- name: Install the Visual C thingy
win_package:
path: %windir%\syswow64\cscript.exe
product_id: '{CF2BEA3C-26EA-32F8-AA9B-331F7E34BA97}'
chdir: C:\Temp\Install
arguments: InstallWrapper.vbs
from ansible.windows.
From @shorbachuk on Feb 03, 2019 18:59
I would also add that I am fine with the ${env:var_name} syntax. I've tried the syntax below and it doesn't work:
- name: Install the Visual C thingy win_package: path: '${env:windir}\syswow64\cscript.exe' product_id: '{CF2BEA3C-26EA-32F8-AA9B-331F7E34BA97}' chdir: C:\Temp\Install arguments: InstallWrapper.vbs
from ansible.windows.
From @ShachafGoldstein on Jun 04, 2019 18:01
Why not change it here to expand the vars? - It won't break other use cases that need unexpanded vars and solve it on a larger scale and future uses
from ansible.windows.
Related Issues (20)
- Error Installing Windows Server Updates with Ansible HOT 2
- Install Application with InstallAnywhere HOT 1
- win_get_url does not respect content-disposition HOT 1
- win_update failed since ansible 7.7.0 HOT 3
- win_update show different trigger in Event Viewer HOT 1
- ansible.windows.win_powershell misinterprets block scalar (string block) HOT 2
- win_package: support checksum verification HOT 2
- intermittent winrm connection failures with large hosts count HOT 8
- intermittent "unable to delete temporary file" errors HOT 9
- Win_updates fail with "Exception from HRESULT: 0x80072EE2" HOT 2
- Windows Update Module not installing any updates HOT 4
- Windows update failes due to update loop HOT 3
- win_environment : Maybe add an option to read variable content ? HOT 5
- Error during machine sid retrieval: An error (1788) occurred while enumerating the group membership. The member's SID could not be resolved. HOT 8
- Access denied after renaming windows host : Server not found in Kerberos database HOT 10
- Failed to create temporary directory when running win_template module against Windows Server 2019 HOT 10
- win_copy doesnt work when folder name has special character HOT 2
- Add account_expires functionality from the Set-LocalUser PowerShell Cmdlet HOT 2
- Using Machine credentials from AAP passed to playbook with ansible.windows.win_copy fails HOT 2
- ERROR DURING WINRM SEND INPUT - attempting to recover: WinRMTransportError Bad HTTP response returned from server. Code 413 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible.windows.