Adding a Target Host to a Host Cluster for CodeArts Deploy
This section describes the preparations for adding target hosts to a host cluster. Before adding a host to a created host cluster, you need to perform the following operations on the host.
Prerequisites
- A host cluster is available, and you have the permission to add hosts to the cluster.
- A host that meets the following requirements is available. (If you do not have a host, purchase one by referring to Purchasing an ECS.)
- A public IP address has been bound.
- A host is configured.
- If you need to monitor a host, you need to create an agency for the host. For details, see Creating an Agency.
This configuration has been completed for Huawei Cloud ECSs (Linux) by default. You do not need to configure it again. However, you need to configure it for Windows ECSs.
Configuring a Linux Host
To ensure that the connectivity verification of the Linux host is successful, ensure that Python is installed on the Linux host and the SELinux mechanism is enabled. The target host must meet the following requirements:
- Install Python
Install Python version 2.6 or later. If Python earlier than 2.6 has been installed, run the following commands to install the following modules on the host:
- Ubuntu
sudo apt install python-minimal python-simplejson
- CentOS or EulerOS
sudo yum install python-minimal python-simplejson ln -s /usr/bin/python2 /usr/bin/python
Before using Advanced Packaging Tool (APT) or Yellowdog Updater Modified (yum), ensure that an available source has been configured.
- Ubuntu
- Enable SELinux and install libselinux-python
- Run the following command to check the SELinux status:
/usr/sbin/sestatus
Mode corresponding to the value of SELinux:
SELinux=disabled: disabled.
SELinux=enforcing: forcible mode, indicating that all behavior that violates the security policy are prohibited.
SELinux=permissive: indicates that all behavior that violates security policies are not prohibited but are recorded in logs.
- If SELinux is set to disabled, SELinux is disabled on the host. In this case, perform the following steps to change the SELinux status.
- Run the following command to edit the config file of the SELinux:
vi /etc/selinux/config
- Modify the SELinux parameters based on the site requirements.
SELinux=enforcing: forcible mode, indicating that all behavior that violates the security policy are prohibited.
SELinux=permissive: indicates that all behavior that violates security policies are not prohibited but are recorded in logs.
- After the modification, press Esc to exit. Run the following command to save the file and exit.
wq
- Create the hidden file .autorelabel in the root directory, run the following command, and restart the Linux host.
touch /.autorelabel
- Run the following command to edit the config file of the SELinux:
- Run the following commands to install libselinux-python:
- Ubuntu
sudo apt install libselinux-python
- CentOS or EulerOS
sudo yum install libselinux-python
- Ubuntu
- Run the following command to check the SELinux status:
Configuring the Host Running Windows
For details about how to configure a host running Windows 10, or Windows Server 2016 or Windows Server 2019 as the target host, see the configuration method of Windows Server 2012. For details about how to obtain the script, see Windows2016ConfigureRemotingForAnsible.zip.
For details about how to configure a target host running Windows 7, see the configuration method of Windows 2012. For details about how to obtain the script, see Windows2012ConfigureRemotingForAnsible.
To use an automatic configuration script to add a host running Windows Server 2012 as an authorized host, perform the following steps:
- Perform Security Configuration, to ensure successful connectivity verification.
- Obtain the automatic configuration script.
- Download Windows2012ConfigureRemotingForAnsible.zip.
- Decompress Windows2012ConfigureRemotingForAnsible.zip to obtain script Windows2012ConfigureRemotingForAnsible.ps1.
- Configure the host.
Log in to the host, open PowerShell, access the directory where script Windows2012ConfigureRemotingForAnsible.ps1 is stored, and run the following command:
.\Windows2012ConfigureRemotingForAnsible.ps1
The output is as follows:
The system may display a message indicating that the file cannot be loaded and a digital signature is required.
This error occurs because the script cannot be executed in default mode of PowerShell. If this happens, run the following command in PowerShell to change the execution policy to unrestricted:
set-executionpolicy unrestricted
Enter Y to confirm the change.
- View the configuration.
Run the following command in PowerShell:
winrm e winrm/config/listener
If the output contains HTTPS and Hostname is not left blank, the listening is successful. The Windows Server 2012 deployment environment is automatically configured.
If Hostname is left blank in the command output, the host does not have IIS or signature certificate information. In this case, run the following script:
# Configure WinRM. winrm enumerate winrm/config/listener winrm quickconfig winrm set winrm/config/service/auth '@{Basic="true"}' winrm set winrm/config/service/auth '@{CredSSP="true"}' winrm set winrm/config/service '@{AllowUnencrypted="true"}' # Install IIS. Import-Module servermanager Add-windowsfeature Web-Server,Web-WebServer,Web-Common-Http,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-App-Dev,Web-ASP,Web-ISAPI-Ext,Web-Health,Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor,Web-Security,Web-Filtering,Web-Stat-Compression,Web-Mgmt-Tools # Create a self-signed certificate. New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My\ -DnsName 'windows-deploy-connect' # View the self-signed certificate. ls Cert:\LocalMachine\My # Add a secure connection using the created self-signed certificate. $windows_test_key=(Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object {$_.Subject -match "windows-deploy-connect"}).Thumbprint cmd /c "winrm set winrm/config/Listener?Address=*+Transport=HTTPS @{Enabled=`"true`";Port=`"5986`";Hostname=`"windows-deploy-connect`";CertificateThumbprint=`"$windows_test_key`"}"
To manually add a host running Windows Server 2012 as an authorized host, perform the following steps:
- Change the PowerShell execution policy to unrestricted.
Open PowerShell as an administrator and run the following command:
set-executionpolicy unrestricted
The output is as follows.
Enter Y to confirm the change.
- Configure Windows remote management (WinRM).
- Run the following commands in PowerShell:
winrm enumerate winrm/config/listener winrm quickconfig winrm set winrm/config/service/auth '@{Basic="true"}' winrm set winrm/config/service/auth '@{CredSSP="true"}' winrm set winrm/config/service '@{AllowUnencrypted="true"}'
- Run the following command to check whether the configuration is successful:
winrm get winrm/config/service/auth
If the values of Basic, Kerberos, and CredSSP are all true, the configuration is successful.
- Run the following commands in PowerShell:
- Install the certificate.
- Open Server Manager, and start IIS.
- Click
- On the Installation Type page, select the first option and click Next.
- Go to the Server Roles page and select Web Server (IIS).
- Go to the Features page, select .NET Framework 4.5, and click .
- Go to the Role Services page, select IIS Management Scripts and Tools and Management Service, and click
- Add a certificate.
- Press Windows+R to open the Run dialog box, enter the inetmgr command for opening the IIS management window, and click OK.
- Open IIS Manager, and double-click Server Certificates.
- On the Server Certificates page, click Create Self-Signed Certificate.
- In the Specify Friendly Name dialog box, enter the certificate name and click OK.
- Run the following command to view the certificate in PowerShell:
ls Cert:\LocalMachine\My
If the following two columns of data are displayed, the certificate is added.
- Use the certificate to listen to the HTTPS port and configure a secure connection.
The commands are in the following format:
winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Port="User-defined port; default: 5986";Hostname="Certificate domain name";CertificateThumbprint="Certificate key value"}
- Hostname is the value in the Subject column in the preceding step.
- CertificateThumbprint is the value behind "CN=" next to the Thumbprint column in the preceding step. Every two characters are separated by a space.
Enter the following commands in the command prompt, as shown in the following figure.
winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Port="5986";Hostname="XXXXXXXXXXXXXXXX";CertificateThumbprint="DF D7 02 1D F6 AB E2 78 C2 0D 87 4C FC 15 5F 16 D3 33 24 2A"}
Run the command in the command prompt and separate every two characters in the value of Thumbprint with a space. Otherwise, the connectivity verification may fail. If the characters are not separated by spaces, delete the signatures and add them again.
If the system displays a message indicating that the service cannot create the resource because it already exists, run the following command to delete the resource and perform this step again:
winrm delete winrm/config/Listener?Address=*+Transport=HTTPS
- Run the following command to check whether the listening is successful in PowerShell:
winrm e winrm/config/listener
If the output contains HTTPS, the listening is successful.
- Ensure that security configuration has been performed by referring to Security Configuration to ensure successful connectivity verification.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot