[ansible-project] Re: Calling powershell function via Ansible
Thanks for the note on the "Become" double hop snafu's, found another post from a year or so ago where you helped someone else with resolving their become issues and used that to muddle through it myself. solution - name: Create DFS links win_shell: | . C:\scripts\USERNAME\dfsadd_func.ps1 dfsadd -junction "{{ vol_junction }}" -obj_name "{{ obj_name }}" -prd_vserver "{{ prd_vserver }}" -dr_vserver "{{ dr_vserver }}" -prd_state "{{ prd_state }}" -dr_state "{{ dr_state }}" become: yes become_method: runas become_user: "userna...@domain.net" I really appreciate the assist. On Thursday, March 5, 2020 at 5:05:13 PM UTC-5, Jesse Lyon wrote: > > Jordan, > > The methodology I was following was "if it worked through ise, why's this > not pass it properly?", I knew I was doing something wrong, I just didn't > know what yet. > > I'll give this a shot in the morning and report back. > > After 12 punches on the card of "Jordan saves the day" do you earn a > prize? > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d2bca78b-f3bc-4c90-8645-113438df0b43%40googlegroups.com.
[ansible-project] Re: Calling powershell function via Ansible
Jordan, The methodology I was following was "if it worked through ise, why's this not pass it properly?", I knew I was doing something wrong, I just didn't know what yet. I'll give this a shot in the morning and report back. After 12 punches on the card of "Jordan saves the day" do you earn a prize? -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f49ca391-1281-4af6-b462-872d7c5f8bbf%40googlegroups.com.
[ansible-project] Re: Calling powershell function via Ansible
When you call powershell.exe with -File you cannot run multiple commands after that, it's designed to run a script with potential arguments. You can even see in the error from powershell it thinks the file it needs to run is `C:\Scripts\USERNAME\dfsadd_func.ps1;' (with the semicolon) so that's why it is saying the extension is wrong. If you are trying to run a function that is sourced from a file do the following - name: Create DFS links win_shell: | . C:\Scripts\USERNAME\dfsadd_func.ps1 # dot source the file to load the functions dfsadd -junction Apps -obj_name toast -prd_vserver PROD -dr_vserver DR -prd_state online -dr_state offline Please bear in mind the double hop problem with WinRM where you will be unable to talk to downstream servers in your task unless you use something like become or your auth is CredSSP or Kerberos with credential delegation enabled. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/efdc8a5e-0262-4ca8-913b-bbbecc97cf75%40googlegroups.com.