I'm not a Windows peson at all, but it looks to me a bit as if you may not
be waiting long enough after the reboot? To test this, just put in a fixed
(say) two minute delay to make absolutely certain; f that makes a
difference you can work on fine-tuning the delay and/or detecting readiness.

The other possibility is the variables in the second script - you might
like to add code to the script to output the value of "$servername" to a
file, then inspect the file when the script has been run. And/or
experimentally hardcode a servername just to see if it then works.

Thirdly, what if anything is in the variable "RDSInstall" after the script
has been run? A debug statement in your Ansible script might help there.

Regards, K.




On Sat, Jan 19, 2019 at 5:12 AM DC <dccla...@gmail.com> wrote:

> Hello,
>
> I am trying to automate building an MS RDS Server 2016.  The automation of
> the server build works great up until the last part when it tries to
> install RDS.  Two scripts run separately to install RDS, the first one
> installs the RDS feature, and then Ansible should restart the server after
> the feature gets installed. The first PS script below is not running when
> called on by the Ansible playbook and it does not restart the server as
> well.
>
> *First PS Script that Runs*
> Add-WindowsFeature –Name RDS-RD-Server –IncludeAllSubFeature
>
>
> *After the server bounces the next PS script to install RDS and configure
> the deployment.*
> Enter code here...$servername=(Get-WmiObject win32_computersystem).
> DNSHostName+"."+(Get-WmiObject win32_computersystem).Domain
>
> Import-Module RemoteDesktop
>
> New-RDSessionDeployment -ConnectionBroker "$servername" -WebAccessServer
> "$servername" -SessionHost "$servername"
>
> New-RDSessionCollection -CollectionName "LTS" -SessionHost "$servername"
> -ConnectionBroker "$servername"
>
> Set-RDSessionCollectionConfiguration -CollectionName "LTS" -UserGroup
> "directory\RDS-Users" -ClientDeviceRedirectionOptions 0x0000
> -ClientPrinterRedirected $False
>
>
> Both scripts get copied to a temp folder on the server correctly via
> Ansible.  Both scripts work perfectly when I run them from the PS editor
> but when I try to use Ansible they do not work.  The 2nd script should take
> 5-7 minutes to install RDS, it finishes within seconds   I am starting to
> think it is the way the scripts are executing since it works perfectly in
> the PS editor but does not work when being called on by Ansible.  Any
> suggestions on how to troubleshoot further?
>
> *Here is the Main.yml file to install RDS*
> - name: Copy Windows Feature installation script
>   win_copy:
>     src: TS_Script1.ps1
>     dest: c:\temp\TS_Script1.ps1
>
> - name: Install Windows Feature installation script
>   win_shell: c:\temp\TS_Script1.ps1
>   register: result
>
> - name: Reboot from Windows feature install
>   win_reboot:
>   when: result == "Completed"
>
> #Wait for the machine to reboot from installing the windows features
> - name: Waiting for reboot
>   local_action: shell ansible -u {{ansible_user_id}} -m ping {{
> inventory_hostname }}
>   register: result
>   until: result.rc == 0
>   retries: 30
>   delay: 10
>
> - name: Copy RDS installation script
>   win_copy:
>     src: TS_Script2_Install_RDS.ps1
>     dest: c:\temp\TS_Script2_Install_RDS.ps1
>
> - name: Install RDS installation script
>   win_shell: c:\temp\TS_Script2_Install_RDS.ps1
>   register: RDSInstall
>
> - name: Reboot from Windows feature install
>   win_reboot:
>   when: RDSInstall == "Completed"
>
>
>
>
> Thanks in Advance!!
> DC
>
> --
> 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 post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/ee20a3da-7b96-461f-8839-435ffd4f9366%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/ee20a3da-7b96-461f-8839-435ffd4f9366%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TK69L6dDGzaX8bcLyBg0rhrv60dpXpniRRO617qSim8A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to