I'm attempting to script a backup process of a docker volume hosted in a azure linux app service.
I need to create a ssh tunnel using powershell. Calling the script from task scheduler with the following powershell -noninteractive -File R:\path\to\ftp-backups.ps1
When the following command is executed to create the tunnel
az webapp create-remote-connection --subscription 00000000-9dfs-4fdsxexxxx-324jklsdf4308320324 --resource-group my-resource-group -n my-app-name -p 12345
The powershell dialog that has come up offers the interactive options of
Opening tunnel on port: 12345
SSH is available { username: user, password: password }
Ctrl + C to close
The script does not move past this point, how can I suppress this interactive dialog prompt so the rest of the script will continue?
I responded to your question on a different forum. Posting here for visibility
The engineering team revamped this command recently which was deployed as part of CLI release 2.8.0. The PowerShell script should work now.
https://github.com/MicrosoftDocs/azure-docs-cli/blob/master/docs-ref-conceptual/release-notes-azure-cli.md#appservice-1
Related
I need to create a playbook that will delete files older then X days on a remote share location which has Windows NTFS share permissions. Account that can access the share is AD service account (different then the one used for Ansible). Ansible is Tower version with RedHat as OS. There is no PowerShell host which I can use as intermediary.
There is a win-share-module https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_share_module.html#ansible-collections-ansible-windows-win-share-module but host that execute module must be Windows not Linux.
There is also ansible.windows.win_powershell module, but for this I have to install PowerShell in Ansible Tower, right?
What would be the best and easiest you would do it?
UPDATE
Let me add that I installed powershell on Linux but when doing this basic test
---
- name: Delete old PowerFlex storage backups
hosts: localhost
gather_facts: no
connection: local
tasks:
- name: Run basic PowerShell script
ansible.windows.win_powershell:
script: |
echo "Hello World"
I get the error
"module_stderr": "/bin/sh: powershell: command not found\n",
On the other hand when I login to linux CLI, I can enter into PowerShell with pwsh (not powershell), so I guess this module calls different version of PowerShell.
What is a workaround on this?
Thanks.
The win_powershell module is not going to work on your Tower machine. It will only work on windows OS.
Since you need to run this script a linux hosts, you can use shell module, and specify the executable path to wherever pwsh is on your machine. I would use a script for easier development/testing, but you can also use direct commands.
- name: execute pwsh
ansible.builtin.shell: /path/to/Invoke-Script.ps1
args:
executable: /bin/pwsh
I have local Windows 10 and remote Ubuntu server.
I want to automate connection to server and write executable script witch connects by ssh to server and open new terminal from another server.
What it's supposed to look like
I double click on bat
And then script
inits ssh connect
writes password
gives the user a terminal with a ready ssh connection.
That is, it mimics the following
Problems
How to wait ssh password request? All commands executes immediately.
(additional) can I write it in .sh script, run script, execute all in "start" terminal (from which I run .sh script) and then pass ssh control to invoked terminal?
It's best if someone writes a ready-made script
Automatically enter SSH password with script
Answers:
Direct answer - use expects. But sshpass is better. Also RSA-key can be used.
Can`t tell anything.
Can be done without any 3rd party tools like this:
$env:TMPPW=Get-Content -Path 'secure_file.txt' ; $un='MyUserName'
$j=Start-Job -ScriptBlock{Start-Sleep -Seconds 1
(New-Object -ComObject wscript.shell).SendKeys("$env:TMPPW{ENTER}")}
& ssh.exe -q -4 -l $un 127.0.0.1 'whoami'
$env:TMPPW=([guid]::NewGuid()).Guid ; $env:TMPPW=$null
I do have following setup:
a win PC with gitlab-runner installed (working)
a powershell script running on the same PC is starting an application
a gitlab server to connect this local PC and starting the powershell script
Now when starting the powershell script directly from the local PC, the application starts and terminates after done - working as expected. When starting the same powershell script with the gitlab server (yml-file) then I can see that the application has been started (new process in taskmanager) but it is not running as well it never terminates.
When manually end the task I see that gitlab terminates again.
Question:
what could be the root cause?
is it possible to run the powershell script with gitlab-runner? I think there is a way with the command "exec". How does the command looks like when calling the powershell script?
is it possible to run the application not in the background in order to see whats going on?
others?
thanks in advance
I think there is a bug with the gitlab runner on windows.
No matter which shell you configure in the config.toml the runner
will always use cmd.exe for an exec local run.
Specify the --shell argument to override the default cmd.exe shell:
> gitlab-runner exec shell your_job --shell pwsh
If you run this locally in your project, it outputs to .builds/, so add this to your .gitignore because git will see it and think you might want to add a submodule.
We are using some custom modules in our Perl automation framework which runs through Jenkin pipeline. Recently we got package not found error for all custom modules while executing test cases in AIX servers as latest Perl version is installed there . So we tried to add "PERL5LIB" in the path as mentioned in document
https://perlmaven.com/how-to-change-inc-to-find-perl-modules-in-non-standard-locations
We added "export PERL5LIB=/home/foobar/code" in /etc/profile of the AIX server and script getting executed without any issue when running from local AIX machine.
Issue:
But we have Jenkin pipeline to execute the scripts in AIX server using ssh. Now when we do SSH to the AIX server in the pipeline script the variables that we have set in /etc/profile does not load and we get package not found error.
Question: How can I load the profile in the AIX server while running it from pipeline? or is there any other way to handle this. Before executing script I want to export PERL5LIB in remote AIX server through pipeline (only once) and the I should not get package not found error.
Below solutions I have tried :
Load the /etc/profile: ssh AIX server ./etc/profile (using dot since source not working in AIX)
Adding this line "export PERL5LIB=/home/foobar/code" in .ssh/environment in AIX server and set PermitUserEnviorment yes
Appreciate any help on this.
Assign values to variables the usual way:
ssh user#host 'export PERL5LIB=/somepath; echo $PERL5LIB'
user#hosts's password:
/somepath
or
ssh user#host '. /etc/profile.local; echo $PERL5LIB'
user#hosts's password:
/somepath/from/profile
Edit:
If you have to execute multiple commands, create a script and upload it to the target computer, for example:
SCRIPTNAME=/tmp/$$.$RANDOM.script
scp myscript.sh user#host:"$SCRIPTNAME"
ssh user#host "$SCRIPTNAME"
This is solved with below changes.
Step 1: Edit ~/.ssh/environment. Add variable PERL5LIB="/path of the module/"
Step 2: Edit /etc/ssh/sshd_config. Change variable PermitUserEnvironment from no to yes. Uncomment it if commented. This will enable access of environment variables to SSH.
Step 3: Restart SSHD service. (This is imp. I had tried step 1 and 2 before also but not restarted the service so solution was not working)
We can create a script and run it before executing automation test from pipeline.
need help :
informatica is installed on windows ,
so pmcmd will not work to schedule informatica workflow,
n e patch or utility to schedule informatica workflow (on windows) through unix(pmcmd).
any other solution to schedule informatica workflow (on windows). ??
Please Google for the error you have: " no gateway connectivity is provided for domain". And to resolve the issue, add the environment variable INFA_DOMAINS_FILE.
More can be found for example on: this page
We can run pmcmd command from windows command line.In command line mode we have to give every bit of information like (domain name,integration service name,username and passwords in each command.Below is the syntax
pmcmd startworkflow -sv Myintservice -d Mydomain -u username -p password -f foldername workflowname
Please lookup the help of pmcmd command just to make sure if I have misstated anything.