Deploy to a physical data center
Deploy artifacts to VMs or bare-metal hosts in a physical data center.
This tutorial helps you get started with Harness Continuous Delivery (CD). We will guide you through creating a CD pipeline with deployment type Secure Shell (SSH) or WinRM that manages remote Linux servers.
Before you begin
Verify that you have the following:
One or more Linux VM. Use your own Linux VM or we recommend using Vagrant for starting a new VM instance.
SSH Private Key to authenticate to the remote vm/server. For steps, go to Passwordless SSH using public-private key pairs.
Docker to set up and start Docker Delegate.
Getting Started with Harness CD
Log in to Harness.
Select Projects, and then select Default Project.
For the pipeline to run successfully, follow all of the steps below as they are, including the naming conventions.
Set up the Harness Delegate
In Project Setup, select Delegates.
Select Delegates.
Select Install delegate. For this tutorial, let's explore how to install the Docker delegate.
In the command provided,
ACCOUNT_ID,MANAGER_ENDPOINTandDELEGATE_TOKENare auto-populated values that you can obtain from the delegate installation wizard.docker run --cpus=1 --memory=2g \ -e DELEGATE_NAME=docker-delegate \ -e NEXT_GEN="true" \ -e DELEGATE_TYPE="DOCKER" \ -e ACCOUNT_ID=ACCOUNT_ID \ -e DELEGATE_TOKEN=DELEGATE_TOKEN \ -e MANAGER_HOST_AND_PORT=MANAGER_ENDPOINT harness/delegate:23.05.79310
Verify that the delegate is installed successfully and can connect to the Harness Manager.
Set up a Harness secret for your SSH private key
In Project Setup, select Secrets.
Select New Secret > SSH Credential.
Enter the secret name
harness_sshprivatekeyand click Continue.With SSH Key as the Auth Scheme, select Username/SSH Key as the Authentication method.
Enter the username for the user account on the remote server in the Username field. For example: ubuntu
Next, select Create or Select a Secret and click New Secret File.
Enter the Secret Name ssh-private-key and click Browse to upload the SSH Private Key to Harness Secret Manager.
Click Save and if needed modify the SSH port number.
Finally, click Save and Continue.
Set up Harness connectors to your physical data center and Artifactory repository
Create a Physical Data Center connector
Copy the contents of pdc-connector.yml.
In Harness, in Project Setup, select Connectors.
Select Create via YAML Builder and paste the copied YAML.
In the YAML, replace HOST_IP_OR_FQDN with the Host IP/FQDN and DELEGATE_NAME with the installed delegate name. To obtain the delegate name, navigate to Default Project > Project Setup > Delegates.
Select Save Changes and verify that the new connector named harness_pdc is successfully created.
Finally, select Test under CONNECTIVITY STATUS to ensure the connection is successful.
Create a Artifactory connector
For this tutorial, we'll use an artifact for a ToDo List app, todolist.war, which is available in a public Harness Artifactory repo.
Copy the contents of artifactory-connector.yml.
In Harness, in Project Setup, select Connectors.
Select Create via YAML Builder and paste the copied YAML.
Select Save Changes and verify that the new connector named harness_artifactrepo is successfully created.
Finally, select Test under CONNECTIVITY STATUS to ensure the connection is successful.
Set up the Harness environment
In Default Project, select Environments.
Select New Environment and toggle to YAML to use the YAML editor.
Copy the contents of environment.yml and paste it into the YAML editor and select Save.
In Infrastructure Definitions, select Infrastructure Definition and select Edit YAML.
Copy the contents of infrastructure-definition.yml and paste it into the YAML editor.
Select Save and verify that the environment and infrastructure definition is created successfully.
Set up the Harness service
In Default Project, select Services.
Select New Service.
Name the service
harness_ssh.Select Save, and then in the Configuration tab, toggle to YAML to use the YAML editor.
Select Edit YAML and copy the contents of service.yml and paste it into the YAML editor.
Select Save and verify that the Service harness_ssh is successfully created.
Set up the pipeline
In Default Project, select Pipelines.
Select New Pipeline.
Enter the name
harness_ssh_pipeline.Select Inline to store the pipeline in Harness.
Select Start and, in the Pipeline Studio, toggle to YAML to use the YAML editor.
Select Edit YAML to enable edit mode, and choose any of the following execution strategies. Paste the respective YAML based on your selection.
Copy the contents of pipeline-ssh-canary.yml and paste it into the YAML editor.
Select Save.
You can switch to the Visual editor and confirm the pipeline, stage, and execution steps are as shown below.

Copy the contents of pipeline-ssh-rolling.yml and paste it into the YAML editor.
Select Save.
You can switch to the Visual editor and confirm the pipeline, stage, and execution steps are as shown below.

Copy the contents of pipeline-ssh-basic.yml and paste it into the YAML editor.
Select Save.
You can switch to the Visual editor and confirm the pipeline, stage, and execution steps are as shown below.

Finally, it's time to execute the pipeline.
Select Run, and then select Run Pipeline to initiate the deployment.
Observe the execution logs as Harness copies the artifact from source to the remote server.
After a successful execution, you can check the artifact in your remote server using the following command:
Congratulations!🎉
You've just learned how to use Harness CD to copy an artifact to your remote servers via SSH.
Before you begin
Verify that you have the following:
A Windows VM. Use your own Windows VM or we recommend using Vagrant for starting a new vm instance.
Docker to set up and start Docker Delegate.
Getting Started with Harness CD
Log into Harness.
Select Projects, and then select Default Project.
For the pipeline to run successfully, please follow all of the following steps as they are, including the naming conventions.
Delegate
In Project Setup, select Delegates.
Select Delegates.
Select Install delegate. For this tutorial, let's explore how to install the Docker Delegate.
In the command provided,
ACCOUNT_ID,MANAGER_ENDPOINTandDELEGATE_TOKENare auto-populated values that you can obtain from the delegate Installation wizard.
Verify that the delegate is installed successfully and can connect to the Harness Manager.
Secrets
In Project Setup, select Secrets.
Select New Secret > WinRM Credential.
Enter the secret name
harness_winrmpwdand click Continue.With NTLM as the Auth Scheme, Enter the domain name. This is the Active Directory domain name where the user account in the credentials is registered.
Enter the username for the user account on the remote server in the Username field. Eg: Administrator
Next, select Create or Select a Secret and click New Secret Text.
Enter the Secret Name winrm_passwd and enter the user password in the Secret Value field and click Save.
Finally, click Save and Continue and verify the connection to the remote Windows server.
Connectors
Create a Physical Data Center connector.
Copy the contents of pdc-connector.yml.
In Harness, in Project Setup, select Connectors.
Select Create via YAML Builder and paste the copied YAML.
In the YAML, replace HOST_IP_OR_FQDN:PORT with the Host IP/FQDN along with the PORT number to 5985 and DELEGATE_NAME with the installed delegate name. To obtain the delegate name, navigate to Default Project > Project Setup > Delegates.
Select Save Changes and verify that the new connector named harness_pdc is successfully created.
Finally, select Test under CONNECTIVITY STATUS to ensure the connection is successful.
Create a Artifactory Connector. For this tutorial, we'll use a publicly available ToDo List app artifact, todolist.war, available in a public Harness Artifactory repo.
Copy the contents of artifactory-connector.yml.
In Harness, in Project Setup, select Connectors.
Select Create via YAML Builder and paste the copied YAML.
Select Save Changes and verify that the new connector named harness_artifactrepo is successfully created.
Finally, select Test under CONNECTIVITY STATUS to ensure the connection is successful.
Environment
In Default Project, select Environments.
Select New Environment and toggle to YAML to use the YAML editor.
Copy the contents of environment.yml and paste it into the YAML editor and select Save.
In Infrastructure Definitions, select Infrastructure Definition and select Edit YAML.
Copy the contents of infrastructure-definition.yml and paste it into the YAML editor.
Select Save and verify that the environment and infrastructure definition is created successfully.
Services
In Default Project, select Services.
Select New Service.
Name the service
harness_winrm.Select Save, and then in the Configuration tab, toggle to YAML to use the YAML editor.
Select Edit YAML and copy the contents of service.yml and paste it into the YAML editor.
Select Save and verify that the Service harness_ssh is successfully created.
Pipeline
In Default Project, select Pipelines.
Select New Pipeline.
Enter the name
harness_winrm_pipeline.Select Inline to store the pipeline in Harness.
Select Start and, in the Pipeline Studio, toggle to YAML to use the YAML editor.
Select Edit YAML to enable edit mode, and choose any of the following execution strategies. Paste the respective YAML based on your selection.
Copy the contents of pipeline-canary.yml and paste it into the YAML editor.
Select Save.
You can switch to the Visual editor and confirm the pipeline, stage, and execution steps are as shown below.

Copy the contents of pipeline-rolling.yml and paste it into the YAML editor.
Select Save.
You can switch to the Visual editor and confirm the pipeline, stage, and execution steps are as shown below.

Copy the contents of pipeline-basic.yml and paste it into the YAML editor.
Select Save.
You can switch to the Visual editor and confirm the pipeline, stage, and execution steps are as shown below.

Finally, it's time to execute the pipeline. Select Run, and then select Run Pipeline to initiate the deployment.
Observe the execution logs as Harness copy the artifact from source to the remote server.
After a successful execution, you can check the artifact in your remote server using the following command:
Congratulations!🎉
You've just learned how to use Harness CD to copy an artifact to your remote servers via WinRM.
Last updated
Was this helpful?