I have a powershell script for installing MS SQL 2014 to a Windows Server 2016 (manually tested and confirmed working properly).
powershell script abbreviated:
$sqlInstanceName = {{ sqlInstance }}
$localAdminPword = {{ localAdminPword }}
### Some more variables here declared the same as above
echo [OPTIONS] > $SQLServerInstallerPath\SQLServerConfigurationFile
### more echo lines like the above.
& $SQLServerInstallerPath\setup /SAPWD=$localAdminPword /ConfigurationFile=$SQLServerInstallerPath\SQLServerConfigurationFile
My playbook is simple just hosts for the target host and two tasks, I just generate the script using win_template, and then execute it with win_shell. something like:
---
- name: Install SQL
hosts: "{{ newhost }}"
tasks:
- name: generate script
win_template:
src: "scriptName"
dest: "{{ path }}//scriptName.ps1"
- name: run script
win_shell: ./scriptName.ps1
args:
chdir: "{{ path }}"
Here's a rundown of the scenarios:
Scenario 1:
I use Ansible tower to run the job targeting a server newly provisioned with vRealize Automation.
Output says it's successful, no problems.
I login to the new server and see that MS SQL wasn't installed, the powershell script didn't work... weird,
so I logged off the server and I ran the same job again, no changes, just rerun it.
I logged in the server again, this time, MS SQL was installed properly.
Scenario 2:
I repeated scenario 1 completely, everything the same, this time, I ran the job twice in succession.
I logged in the server, saw the MS SQL wasn't installed.
Logged off, then ran the job again, Logged in, saw MS SQL installed
Scenario 3:
I provision a new server, exactly the same as the previous scenarios, but this time, I logged into it to just look at the desktop, take a peek at the start menu, then logged off.
I now run the same job again once, on this new server I provisioned.
After the job completed successfully, I logged into the server and MS SQL was properly installed.
It seems that it won't work, unless I do a first Login on to the new server before running this job. Which defeats the purpose of automating it... Does anyone have an idea about this? Is there some sort of setting or flag I should look into? (note: the server doesn't have the "change password on first login" thing, as far as I'm aware, I didn't specify any first login things on that server.) I need this to work without doing a first login.
Related
Im trying to automate an MSI installer using Ansible. The MSI performs a lot of the steps but then calls DbTool.exe which opens another CMD window and does a bunch of DB stuff, once complete its closes and the MSI resumes.
When I manually run the below from CMD, its successful:
msiexec.exe /i "Package.msi" /quiet /L*V "PackageInstall.log" ISQLSERVER=(local) ISQLAUTH=sql ISQLUID=sa ISQLPWD=********
However, when I do the same from Ansible the play hangs when the MSI executes Dbtool.exe. I can see it Running in Task Manager but isnt doing anything. When the DBtool executes theres no interaction needed unless theres exceptions when running. The Dbtool.exe creates logs but unfortutantley theres no logs as I dont think its getting far enough to start.
- name: Installing Package
win_package:
path: "{{ Generic_Temp_Path }}\\Package\\{{PackageLatestVersion.stdout}}\\Package64_CTI.msi"
arguments: /L*V "{{ Generic_Temp_Path }}\Package\{{PackageLatestVersion.stdout}}\PackageInstall.log" ISQLSERVER={{ UT_DB_Servername }} ISQLAUTH={{ UT_DB_SA_Auth }} ISQLUID={{ UT_DB_SA_User }} ISQLPWD={{ UT_DB_SA_Pass }}"
wait_for_children: yes
Here is the MSI Log, not a lot to see other than its ran it and waiting:
MSI (s) (5C:04) [09:27:36:132]: Executing op: ActionStart(Name=Database.NUI_CreateDB,Description=Creating database...,)
MSI (s) (5C:04) [09:27:36:132]: Executing op: CustomActionSchedule(Action=Database.NUI_CreateDB,ActionType=9298,Source=C:\Program Files\Package\Utilities\DbTool\DbTool.exe,Target=**********,)
The play is running under AdminUser and is the same account I use to manually run the silent installer from CMD so I dont believe its account related.
Ive asked my dev to add some debugging to the dbtool.exe to maybe see if its hanging at some point but from the current logging, theres nothing to go from.
Has anyone come across this before and know any steps to move forward with debugging?
Many Thanks,
Brad.
I have a playbook, as below:
tasks:
- name: Execute a program_A on managed node
win_command: 'D:test\program_A.exe'
I run this playbook but hung and no any response on managed node (Windows 2012). (i.e. there is a program_A.exe process generated on managed node but no response, it's CPU usage time is always 0%)
I also tired to replace win_command by win_shell module, raw module, but it still hung and no response on managed node...
When I try to open a command window on the managed node to run D:\test\program_A.exe directly, the program_A.exe was successfully executed.
What could be wrong?
Make sure the exe file is executed by the same privilege. eg. when you directly execute it, you are using Administrator, but in playbook, you may use guest rule.
I have a setup.exe file to install on Windows Server 2012. Upon clicking the SETUP file, a PowerShell console will popup and will start the installation process. As the process goes through, I will be asked many questions for initial configuration, such as:
>username:
>password:
...................#starts with setup again with verbose outputs
>SQL Server Address:
>SQL Server Database Name:
..................#starts with setup again with verbose outputs
>Database Username:
>Database user password:
.................#starts with setup again with verbose outputs
>Application Name:
.................#starts with setup again with verbose outputs
..............................................................
I install this application from time to time and I want to know if I can write a PowerShell script to give the answers via the script, since I am a newcomer to Powershell, I am here to seek help.
Thanks
I'm deploying a Windows 2012 R2 VSI and need to be able to manage it using Ansible.
I'm using this Ansible sample script ConfigureRemotingForAnsible.ps1 although renamed and have the script hosted on SL Object storage. I specify a postinstall script URL including https (which is supposed to cause the execution of the script after downloading) during the order.
After the Windows VSI is ready I attempt to run a win-ping as follows:
- name: ad1 ready
gather_facts: false
tags: setup
hosts: ad1
tasks:
- name: ping the windows vsi
win_ping:
This fails with the output:
fatal: [169.55.189.16]: UNREACHABLE! => {"changed": false, "msg": "ssl: HTTPSConnectionPool(host='169.55.189.16', port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x107c0b310>: Failed to establish a new connection: [Errno 61] Connection refused',))", "unreachable": true}
If I connect to the system and look in c:\PostInstall I see my script has been downloaded. If I then open a PowerShell and run the script, I am able to then run the above win-ping successfully.
This tells me that the script is downloaded cleanly and is apparently correct, but is not being executed in spite of the https in the postinstall URL.
I can't find any documentation on requirements of the postinstall script for windows, but I'm wondering if the problem is that I'm using a PowerShell script, and that the post provision process tries to run this in a standard CMD shell.
Does anyone have any ideas or thoughts on what could be wrong?
It should work with powershell succesfully, you should be able to see the logs of the powershell execution in "C:\postInstallScript.log" perhaps it contains more information about the error.
Anyway if you are still facing this issue I suggest you to open a ticket in Softlayer with "hardware issue" subject, because the issue is likely due to a restriction in the windows machine which is not allowing to execute the script.
Regards
I believe the problem with PowerShell as a provisioning script is the default configuration of PowerShell requires a signed PowerShell script to execute (with no arguments defined). If the PowerShell script is not signed, the execution policy has to be changed on the server, or flags passed to the PowerShell interpreter to allow execution.
I'm using Vagrant and Ansible to create my Bitbucket Server on Ubuntu 15.10. I have the server setup complete and working but I have to manually run the start-webapp.sh script to start the server each time I reprovision the server.
I have the following task in my Bitbucket role in Ansible and when I increase the verbosity I can see that I get a positive response from the server saying it will be running at http://localhost/ but when I go to the URL the server isn't on. If I then SSH in to the server and run the script myself, getting the exact same response after running the script I can see the startup webpage.
- name: Start the Bitbucket Server
become: yes
shell: /bitbucket-server/atlassian-bitbucket-4.7.1/bin/start-webapp.sh
Any advice would be great on how to fix this.
Thanks,
Sam
Probably better to change that to an init script and use the service module to start it. For example, see this role for installing bitbucket...
Otherwise, you're subject to HUP and other issues from running processes under an ephemeral session.