Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Step explanation for accelerating the efficiency of Ansible external deployment using GlobalSSH

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Today, the editor will bring you an article on how to use GlobalSSH to accelerate the efficiency of Ansible external deployment. The editor thinks it's pretty good, so I'll share it for you as a reference. Let's follow the editor and have a look.

What is Ansible?

Ansible is a simple and efficient automatic orchestration, deployment and configuration management tool without Agent architecture, which realizes the communication between remote nodes and management nodes through SSH protocol.

The purpose of Ansible is to simplify a large number of complex and repetitive operation and maintenance work and to establish a unified automation culture within the company with streamlined technical ideas. The Agent-free architecture makes it simpler than other tools, Ansible can do better based on SSH, and its high ease of use makes it easy to integrate into the existing system, so it is widely used.

UCloud Ansible usage scenario

Ansible is also heavily used within UCloud. For example, the machine × × product deployment system, which has greatly improved the deployment efficiency through Ansible, has become an important tool for UCloud computer room deployment. For another example, the existing large-scale grayscale publishing system solves the problems of grayscale release, rollback and control by integrating the basic API and Callback functions of Ansible. The system has been running stably online for more than 3 years and has completed tens of thousands of related grayscale publishing tasks.

The use of Ansible in the computer × × product deployment system will be described in detail below. It is believed that it will be helpful to readers with multiple computer room deployment needs.

Overseas multi-computer room deployment

We are based on Ansible centralized batch deployment and management services, centralized management center is located in Beijing / Shanghai computer room. When overseas nodes (such as Lagos, Ho Chi Minh, etc.) need to be built, cloud products and internal services are deployed remotely through Ansible. Some cloud products are built on UCloud CVMs as the IaaS layer, so they are also connected to the corresponding overseas CVMs through SSH.

This is similar to the usage scenario of ordinary users, whether it is self-built IDC or public cloud, or even multi-cloud deployment to manage servers on different clouds at the same time, there is a need for batch deployment.

An additional pain point for overseas deployment is the issue of deployment efficiency. Ansible uses the SSH protocol for communication, and the creation and communication speed of SSH channels are slow. When it needs to be managed through the public network, and the network environment is poor or the bandwidth is insufficient, the execution time is basically unbearable. When deploying with Ansible, stutter, connection failure, slow transmission speed and other phenomena often occur. When using Copy module to transfer larger code packages / image files, you basically have to wait until the flowers are gone.

Our solution is to integrate UCloud's PaaS product GlobalSSH into Ansible to improve the efficiency of multinational remote management servers.

GlobalSSH

In order to ensure the operation and maintenance of overseas data centers, GlobalSSH has adopted many UCloud IaaS products, such as ULB4 (layer 4 load balancer), UDPN (intercontinental interconnection, 0 packet loss) and high-packet CVMs, and introduced intelligent DNS services to provide access to the nearest area. Network forwarding is based on mature and stable GRE and NAT technology, and supports TCP port (except 80,443) four-layer forwarding.

Deployment in Ansible Playbook mode

We integrate GlobalSSH into Ansible and do a simple copy and installation of the package, as shown below.

1) first, we create one CVM in Beijing No.2 and one in Lagos (Nigeria) via UCloud API or console with a bandwidth of 1Mb, in which the GlobalSSH feature is automatically enabled in Lagos server room (all UCloud overseas data centers are enabled automatically), as shown below:

2) prepare a simple Ansible Playbook and complete three steps: gather facts, copy code package, and yum installation code. The relevant playbook is as follows:

-hosts: all tasks:-name: copy test copy: src=/data/MySQL-devel-5.6.41-1.el6.x86_64.rpm dest=/data/test-name: install mysql-devel yum: name=/data/MySQL-devel-5.6.41-1.el6.x86_64.rpm state=present

3) prepare a hosts file to configure the domain name generated by GlobalSSH. Ansible's support for GlobalSSH is very simple, as long as you add ansible_ssh_host=xxx.xxx.xxx.xxx.ipssh.net to the host variable. Our data center deployment system combines the Dynamic Inventory feature of Ansible to add the accelerated domain name of GlobalSSH to the ansible_ssh_host variable in the generated inventory. It is also very easy to use, as shown below.

[root@10-10-83-12222] # cat hosts_nrly [all] 152.32.140.39 ansible_ssh_pass=example [root@10-10-83-122122] # cat hosts_nrly_1 [all] 152.32.140.39 ansible_ssh_pass=example ansible_ssh_host=152.32.140.39.ipssh.net

4) execute the playbook using the ansible-playbook command, and the task is completed.

Test comparison

As mentioned earlier, GlobalSSH has greatly improved the efficiency of our overseas deployment. You can test the specific acceleration effect by writing another Playbook without GlobalSSH acceleration.

Playbook without GlobalSSH is relatively easy to write, which is basically similar to the above, except that the accelerated domain name is not used in the hosts file in step 3, but the original public network IP address is entered directly.

In order to prevent the inaccuracy of the results of a single test, 10 times are tested here, and the average values are compared.

Test commands:

Time for i in seq 1 10; do ansible-playbook-I hosts_nrly test_playbook.yml; done time for i in seq 1 10; do ansible-playbook-I hosts_nrly_1 test_playbook.yml; done

The final result is as follows, you can see that in a simple Ansible Playbook deployment, the effect after GlobalSSH acceleration is improved by 32.23%.

Ansible Ad-hoc mode

GlobalSSH can improve the stability and speed of the entire network transmission under low-speed bandwidth, especially for the improvement of RTT (Round-Trip Time) round-trip delay, it has the speed advantage that the external network elastic IP does not have. So we think it is also of great help to the Ansible Ad-hoc approach.

Operators often use Ad-hoc, which is similar to pssh, but supports all module syntax of Ansible. The common use scenario is to execute commands in batches and view the echo results. In order to verify the hypothesis, we have also done a similar test on the Ad-hoc method, and found that the optimization effect after GlobalSSH is more obvious, and the optimization speed is more than 50%. The detailed results are shown below.

Test commands:

Time for i in seq 1 10; do ansible-I hosts_nrly all-m shell-a "cat / var/log/messages"; done time for i in seq 1 10; do ansible-I hosts_nrly_1 all-m shell-a "cat / var/log/messages"; done

Test results:

Summary

Ansible is a widely used DevOps tool, and we can easily integrate GlobalSSH into it according to our needs, avoiding the adverse effects of SSH stutters in server deployment.

After reading the appeal, have you mastered the method of using GlobalSSH to accelerate the efficiency of Ansible external deployment? If you want to know more related content, welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report