Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added basic support for ssh on Windows for raw script execution through Ansible #752

Merged
merged 11 commits into from
Jun 28, 2021

Conversation

laurentganne
Copy link
Contributor

Pull Request description

Description of the change

Added the ability to run scripts on Windows through Ansible, having openssh configured on the Windows host as described at https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse

What I did

The following modifications were done:

prov/ansible/execution.go
As described in https://docs.ansible.com/ansible/latest/user_guide/windows_setup.html#configuring-ansible-for-ssh-on-windows
to configure Ansible to use SSH for Windows hosts, defining ansible_connection=sshand ansible_shell_type=cmd

prov/ansible/execution_ansible.go:
The creation/removal of files and drectories is done using ansible.windows.win_file on Windows

prov/terraform/commons/resources.go:
Updated the default timeout as windows provisionning can take more time than linux distributions

helper/consulutil/consul_ratelimit_publisher.go
misc.: added a logs in daemon in case of failure storing a value

How to verify it

Tested in LEXIS context, in a component running this playbook: https://github.com/lexis-project/application-templates/blob/v0.1.3/weather-climate/components/adms/playbooks/adms_run.yaml
first creating a powershell script from a template
then executing this script

Description for the changelog

Add basic support for ssh on Windows (GH-751)

Applicable Issues

Closes #751

Copy link
Member

@loicalbertin loicalbertin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 👏

@@ -876,6 +885,10 @@ func (e *executionCommon) generateHostConnection(ctx context.Context, buffer *by
if host.port != 0 && host.port != 22 {
buffer.WriteString(fmt.Sprintf(" ansible_ssh_port=%d", host.port))
}
// Specific ansible connection settings are needed on windows targets
if strings.Contains(host.osType, "windows") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know but maybe it worthwhile to be mentioned somehow in the documentation.
Maybe here https://yorc.readthedocs.io/en/stable/tosca.html#supported-operations-implementations
As it seems to be a very specific behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, proposign to add this:

Basic support for raws scripts execution through Ansible playbooks is also provided on Windows targets configured to use ssh.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@sonarcloud
Copy link

sonarcloud bot commented Jun 28, 2021

@laurentganne laurentganne merged commit e92a063 into develop Jun 28, 2021
@laurentganne laurentganne deleted the feature/experimental-windows-target branch June 28, 2021 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add basic support for ssh on Windows
2 participants