CN112685051A - Method, device, platform and storage medium for automatically executing shell script - Google Patents

Method, device, platform and storage medium for automatically executing shell script Download PDF

Info

Publication number
CN112685051A
CN112685051A CN202011629816.2A CN202011629816A CN112685051A CN 112685051 A CN112685051 A CN 112685051A CN 202011629816 A CN202011629816 A CN 202011629816A CN 112685051 A CN112685051 A CN 112685051A
Authority
CN
China
Prior art keywords
script
shell
yaml
module
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011629816.2A
Other languages
Chinese (zh)
Inventor
万三
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Teamsun Technology Co ltd
Original Assignee
Beijing Teamsun Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Teamsun Technology Co ltd filed Critical Beijing Teamsun Technology Co ltd
Priority to CN202011629816.2A priority Critical patent/CN112685051A/en
Publication of CN112685051A publication Critical patent/CN112685051A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The application discloses a method, a device, a platform and a storage medium for automatically executing a shell script, wherein the method comprises the steps of obtaining a current operation to be executed, wherein the operation comprises information of a target host and information of the target shell script corresponding to the target host; filling a target shell script in a shell module area of the YAML script; wherein, the shell script parameter of the shell module area is defined according to double curly brackets in the double quotation marks; the YAML script is executed according to the task execution instruction call tool to run the YAML script on the target host. Through the scheme, the shell script can be executed on the cloud environment management platform to achieve automatic management, compared with the prior art, the method does not need a client to additionally develop the YAML script, and only needs to design the shell script to achieve automatic management, so that the requirement on developers can be reduced, and the cost of human resources is reduced.

Description

Method, device, platform and storage medium for automatically executing shell script
Technical Field
The embodiment of the application relates to the field of cloud environment management platforms, in particular to a method, a device, a platform and a storage medium for automatically executing shell scripts.
Background
In the delivery process of the cloud environment management platform, a user is generally required to write a Markup Language (YAML Ain't Markup Language, YAML) script to upload the YAML script to the cloud environment management platform for automatic operation and maintenance, and the YAML script has high requirements on technical personnel and can be used only by installing a corresponding installation package. More Shell scripts are adopted when the cloud environment management platform deploys the application software, so that a user needs to know the YAML script and the Shell script at the same time, the requirement on the user is high, and the labor cost is increased.
Disclosure of Invention
In order to solve the above problems, embodiments of the present application provide a method, an apparatus, a platform, and a storage medium for automatically executing a shell script, where the method may automatically execute the shell script on a cloud environment management platform to implement automated management.
In a first aspect, an embodiment of the present application provides a method for automatically executing a shell script, where the method includes:
acquiring a current job to be executed, wherein the job comprises information of a target host and information of a target shell script corresponding to the target host;
filling a target shell script in a shell module area of the YAML script; wherein, the shell script parameter of the shell module area is defined according to double curly brackets in the double quotation marks;
the YAML script is executed according to the task execution instruction call tool to run the YAML script on the target host.
Optionally, before acquiring the target job, the method further comprises:
and receiving the configuration operation of the user, and calling the tool to create the job in response to the configuration operation.
Optionally, the tool comprises an AWX tool.
Optionally, the shell script includes: at least one of an operation and maintenance script, an application deployment script, a configuration host script, and a command execution script.
In a second aspect, an embodiment of the present application provides an apparatus for automatically executing a shell script, where the apparatus includes:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a current job to be executed, and the job comprises information of a target host and information of a target shell script corresponding to the target host;
the generating module is used for filling the target shell script in a shell module area of the YAML script; wherein, the shell script parameter of the shell module area is defined according to double curly brackets in the double quotation marks;
and the operation module is used for calling a tool to execute the YAML script according to the task execution instruction so as to operate the YAML script on the target host.
Optionally, the apparatus further includes a receiving module and a creating module;
the receiving module is used for receiving configuration operation of a user;
a creation module to invoke a tool to create the job in response to a configuration operation.
Optionally, the tool comprises an AWX tool.
Optionally, the shell script includes: at least one of an operation and maintenance script, an application deployment script, a configuration host script, and a command execution script.
In a third aspect, an embodiment of the present application provides a cloud management platform, including: the device comprises a memory, a processor and a computer program which is stored in the memory and can run on the processor, wherein when the processor executes the computer program, the method for automatically executing the shell script provided by the embodiment of the application is realized.
In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method for automatically executing a shell script as provided in the present application is implemented.
The embodiment of the application provides a method, a device, a platform and a storage medium for automatically executing a shell script, wherein the method comprises the steps of obtaining a current operation to be executed, wherein the operation comprises information of a target host and information of the target shell script corresponding to the target host; filling a target shell script in a shell module area of the YAML script; wherein, the shell script parameter of the shell module area is defined according to double curly brackets in the double quotation marks; the YAML script is executed according to the task execution instruction call tool to run the YAML script on the target host. Through the scheme, the shell script can be executed on the cloud environment management platform to achieve automatic management, compared with the prior art, a client does not need to additionally develop the YAML script, and only needs to design and develop the shell script to achieve automatic management, so that the requirement on developers can be reduced, and the human resource cost is reduced.
Drawings
Fig. 1 is a flowchart of a method for automatically executing a shell script in an embodiment of the present application;
FIG. 2 is a schematic diagram of a YAML script in an embodiment of the present application;
FIG. 3 is a schematic diagram of a shell script in an embodiment of the present application;
fig. 4 is a schematic structural diagram of an apparatus for automatically executing a shell script in an embodiment of the present application;
fig. 5 is another schematic structural diagram of an apparatus for automatically executing a shell script in an embodiment of the present application;
fig. 6 is a schematic structural diagram of a cloud management platform in an embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the application and are not limiting of the application. It should be further noted that, for the convenience of description, only some of the structures related to the present application are shown in the drawings, not all of the structures.
In addition, in the embodiments of the present application, the words "optionally" or "exemplarily" are used for indicating as examples, illustrations or explanations. Any embodiment or design described herein as "optionally" or "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, use of the words "optionally" or "exemplarily" etc. is intended to present the relevant concepts in a concrete fashion.
Fig. 1 is a method for automatically executing a shell script according to an embodiment of the present application, where the method may be applied to a cloud management platform, and as shown in fig. 1, the method may include:
and S101, acquiring the current job to be executed.
The job in the embodiment of the present application may be understood as an orchestration job on the cloud environment management platform, for example, which application software needs to be deployed to which hosts, and the like. The obtained operation may include information of a target host and information of a target shell script corresponding to the target host, and the information of the target shell script may include parameters of the shell script. For example, the installation directory, download address, etc. of the shell script.
Illustratively, the obtaining manner of the Shell script may include: technicians log in the cloud environment management platform and upload the content of the script to a script library specified in the cloud environment management platform.
And S102, filling the target shell script in a shell module area of the YAML script.
After the cloud management platform obtains the current job to be executed, the job including the target shell script can be filled into the shell module area of the YAML script.
Illustratively, the generated YAML script containing the shell script may be as shown in fig. 2, where the blocks in fig. 2 are to note the shell modules of the YAML script.
In the embodiment of the present application, the shell script parameters of the shell module area are defined according to double curly brackets in a double quotation mark, so as to meet the requirement that the parameter format in YAML is set as double curly brackets. As shown in the block in fig. 3, the definition mode for the shell script, that is, the required format defined by the shell script parameters, may be: for example,
variable_name="{{variable_name}}"。
install_path="{{install_path}}"。
it should be noted that the variable names in double-curly brackets may not be consistent with the defined variable names. For example, var1 { { var2} }. Variables in double braces require cloud management platform definition and assignment of values, such as the content in the annotation portion of the "#" line split in fig. 3.
And S103, executing the YAML script according to the task execution instruction calling tool so as to run the YAML script on the target host.
Preferably, the AWX tool can be invoked to execute the generated YAML script to enable running the YAML script on the target host. AWX provides a web-based user interface, REST API and task engine built on desktop. Graphical AWX enables more convenient orchestration and deployment of interactive playbooks, and provides centralized logging, auditing, and system tracking. AWX is an open source version of business edition Ansible Tower.
The AWX tool automation operation bottom layer executes an infrastructure technology, the infrastructure technology integrates the advantages of a plurality of operation and maintenance tools (Puppet, Chef, Func and Fabric), and functions of batch system configuration, batch program deployment, batch operation commands and the like can be achieved. The AWX tool can encapsulate the alarm operation, provides an arrangement interface and can realize batch operation.
The embodiment of the application provides a method for automatically executing a shell script, which can be applied to a cloud management platform and comprises the steps of obtaining a current operation to be executed, wherein the operation comprises information of a target host and information of the target shell script corresponding to the target host; filling a target shell script in a shell module area of the YAML script; wherein, the shell script parameter of the shell module area is defined according to double curly brackets in the double quotation marks; the YAML script is executed according to the task execution instruction call tool to run the YAML script on the target host. Through the scheme, the shell script can be executed on the cloud environment management platform to achieve automatic management, compared with the prior art, a client does not need to additionally develop the YAML script, and only needs to design and develop the shell script to achieve automatic management, so that the requirement on developers can be reduced, and the human resource cost is reduced.
In an example, before performing step S101, an implementation manner provided in an embodiment of the present application further includes: and receiving the configuration operation of the user, and calling the tool to create the job in response to the configuration operation.
The configuration operation in the embodiment of the present application may be understood as parameter requirements and the like that need to be set for the orchestration operation, such as the target host information and the shell script related in the above process. Illustratively, the shell script may include at least one of an operation and maintenance script, an application deployment script, a configuration host script, and a command script, and the operation and maintenance script, the application deployment script, the configuration host script, and the command script may be applied to scenarios such as automatic operation and maintenance, automatic deployment of application software, batch configuration of a host, and batch execution of commands.
In one example, after the YAML script is generated in step S102, the generated YAML script may also be transferred to the item catalog of the AWX tool.
The AWX tool provides two functions of a template task and workflow, and can create the template on an AWX interface according to a directory path of a YAML script and the YAML script, and create the workflow according to the template. The template is used as a task template to specify host information of the target host and the YAML script needing to be operated, the template is executed on the AWX, the function of executing the YAML script containing the shell script on the target host can be realized, and finally the shell script is executed on the target host. Workflow is a Workflow that may be used to orchestrate a template, such as running multiple templates on a target host in a parallel execution manner, or running multiple templates on a target host in a sequential execution manner.
Taking the test.sh script as an example, the content of the test.sh script can be executed on the target host by calling an AWX tool to run the workflow on the cloud management platform, so that the cloud management platform can automatically manage the target host according to the content of the test.sh script.
It should be noted that the AWX is not visible on the interface on the cloud management platform, and the AWX is a bottom implementation tool for implementing automatic management on the cloud management platform.
Fig. 4 is a device for automatically executing a shell script according to an embodiment of the present application, and as shown in fig. 4, the device includes: an acquisition module 401, a generation module 402, and an operation module 403;
the obtaining module 401 is configured to obtain a job to be executed currently, where the job includes information of a target host and information of a target shell script corresponding to the target host;
a generating module 402, configured to fill the target shell script in a shell module area of the YAML script;
the shell module is contained in the device, and shell script parameters of a shell module area are defined according to double curly brackets in double quotation marks;
and the running module 403 is used for executing the YAML script according to the task execution instruction calling tool so as to run the YAML script on the target host.
As shown in fig. 5, the apparatus may further include a receiving module 404 and a creating module 405;
a receiving module 404, configured to receive a configuration operation of a user;
a create module 405 for invoking a tool to create a job in response to a configuration operation.
Illustratively, the tools may include AWX tools, and the shell script may include at least one of an operation script, an application deployment script, a configuration host script, and a command execution script.
The device for automatically executing the shell script can execute the method for automatically executing the shell script provided in fig. 1, and has corresponding devices and beneficial effects in the method, which are specifically referred to the above embodiments and are not described herein again.
Fig. 6 is a schematic structural diagram of a cloud management platform according to embodiment 6 of the present invention, as shown in fig. 6, the cloud management platform includes a controller 601, a memory 602, an input device 603, and an output device 606; the number of controllers 601 in the cloud management platform may be one or more, and one controller 601 is taken as an example in fig. 6; the controller 601, the memory 602, the input device 603, and the output device 606 in the cloud management platform may be connected by a bus or other means, and fig. 6 illustrates an example of connection by a bus.
The memory 602 is used as a computer-readable storage medium for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the method for automatically executing the shell script in the embodiment of fig. 1 (e.g., the obtaining module 401, the generating module 402, and the running module 403 in the device for automatically executing the shell script). The controller 601 executes various functional applications and data processing of the cloud management platform by running software programs, instructions and modules stored in the memory 602, that is, the method for automatically executing the shell script is implemented.
The memory 602 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, the memory 602 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, the memory 602 may further include memory remotely located from the controller 601, which may be connected to a terminal/server through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 603 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the cloud management platform. The output device 606 may include a display device such as a display screen.
Embodiments of the present application also provide a storage medium containing computer-executable instructions that, when executed by a computer controller, perform a method of automatically executing shell scripts, the method comprising the steps shown in fig. 1.
From the above description of the embodiments, it is obvious for those skilled in the art that the present application can be implemented by software and necessary general hardware, and certainly can be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) to implement the methods or functions described in the embodiments of the present application.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present application and the technical principles employed. It will be understood by those skilled in the art that the present application is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the application. Therefore, although the present application has been described in more detail with reference to the above embodiments, the present application is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present application, and the scope of the present application is determined by the scope of the appended claims.

Claims (10)

1. A method for automatically executing shell scripts is applied to a cloud management platform and comprises the following steps:
acquiring a current job to be executed, wherein the job comprises information of a target host and information of a target shell script corresponding to the target host;
filling the target shell script in a shell module area of the YAML script; wherein, the shell script parameter of the shell module area is defined according to double curly brackets in double quotation marks;
executing the YAML script according to a task execution instruction call tool to run the YAML script on the target host.
2. The method of claim 2, further comprising, prior to said obtaining a target job:
and receiving a configuration operation of a user, and calling the tool to create the job in response to the configuration operation.
3. The method of claim 2, wherein the tool comprises an AWX tool.
4. The method of claim 1, wherein the shell script comprises: at least one of an operation and maintenance script, an application deployment script, a configuration host script, and a command execution script.
5. An apparatus for automatically executing a shell script, comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a current job to be executed, and the job comprises information of a target host and information of a target shell script corresponding to the target host;
the generating module is used for filling the target shell script in a shell module area of the YAML script; wherein, the shell script parameter of the shell module area is defined according to double curly brackets in double quotation marks;
and the operation module is used for calling a tool to execute the YAML script according to the task execution instruction so as to operate the YAML script on the target host.
6. The apparatus of claim 5, further comprising a receiving module and a creating module;
the receiving module is used for receiving configuration operation of a user;
the creation module is used for responding to the configuration operation to call the tool to create the operation.
7. The apparatus of claim 6, wherein the tool comprises an AWX tool.
8. The apparatus of claim 5, wherein the shell script comprises: at least one of an operation and maintenance script, an application deployment script, a configuration host script, and a command execution script.
9. A cloud management platform, comprising: memory, processor and computer program stored on the memory and executable on the processor, the processor implementing a method of automatically executing shell scripts according to any of claims 1 to 4 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a method of automatically executing shell scripts according to any one of claims 1 to 4.
CN202011629816.2A 2020-12-31 2020-12-31 Method, device, platform and storage medium for automatically executing shell script Pending CN112685051A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011629816.2A CN112685051A (en) 2020-12-31 2020-12-31 Method, device, platform and storage medium for automatically executing shell script

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011629816.2A CN112685051A (en) 2020-12-31 2020-12-31 Method, device, platform and storage medium for automatically executing shell script

Publications (1)

Publication Number Publication Date
CN112685051A true CN112685051A (en) 2021-04-20

Family

ID=75455994

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011629816.2A Pending CN112685051A (en) 2020-12-31 2020-12-31 Method, device, platform and storage medium for automatically executing shell script

Country Status (1)

Country Link
CN (1) CN112685051A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114553930A (en) * 2022-01-26 2022-05-27 石化盈科信息技术有限责任公司 System integration method and device, computer equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130060814A1 (en) * 2011-09-07 2013-03-07 International Business Machines Corporation Transforming hierarchical language data into relational form
CN105512036A (en) * 2015-12-12 2016-04-20 天津南大通用数据技术股份有限公司 Test template for automatically generating test case according to preset rules and test method
CN110795224A (en) * 2019-10-30 2020-02-14 北京思特奇信息技术股份有限公司 Automatic operation and maintenance system and method based on infrastructure
CN111061555A (en) * 2019-12-22 2020-04-24 济南浪潮数据技术有限公司 Operation and maintenance method based on infrastructure and related device
CN111930388A (en) * 2020-07-13 2020-11-13 银盛支付服务股份有限公司 Continuous integration method and system based on k8s and docker container
CN112083919A (en) * 2020-08-27 2020-12-15 远光软件股份有限公司 YAML template-based target service code generation method and device
CN112114813A (en) * 2020-09-17 2020-12-22 四川长虹电器股份有限公司 Automatic generation method of yaml script based on production line

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130060814A1 (en) * 2011-09-07 2013-03-07 International Business Machines Corporation Transforming hierarchical language data into relational form
CN105512036A (en) * 2015-12-12 2016-04-20 天津南大通用数据技术股份有限公司 Test template for automatically generating test case according to preset rules and test method
CN110795224A (en) * 2019-10-30 2020-02-14 北京思特奇信息技术股份有限公司 Automatic operation and maintenance system and method based on infrastructure
CN111061555A (en) * 2019-12-22 2020-04-24 济南浪潮数据技术有限公司 Operation and maintenance method based on infrastructure and related device
CN111930388A (en) * 2020-07-13 2020-11-13 银盛支付服务股份有限公司 Continuous integration method and system based on k8s and docker container
CN112083919A (en) * 2020-08-27 2020-12-15 远光软件股份有限公司 YAML template-based target service code generation method and device
CN112114813A (en) * 2020-09-17 2020-12-22 四川长虹电器股份有限公司 Automatic generation method of yaml script based on production line

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
流年晕开时光: "ansible核心模块playbook介绍", pages 1 - 15, Retrieved from the Internet <URL:https://www.cnblogs.com/deny/p/11504170.html> *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114553930A (en) * 2022-01-26 2022-05-27 石化盈科信息技术有限责任公司 System integration method and device, computer equipment and storage medium
CN114553930B (en) * 2022-01-26 2024-04-16 石化盈科信息技术有限责任公司 System integration method, device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN107766126B (en) Container mirror image construction method, system and device and storage medium
CN108829409B (en) Distributed system rapid deployment method and system
US12093668B2 (en) iOS application program construction method and apparatus, electronic device, and storage medium
WO2018161799A1 (en) Cloud application deployment method and system
CN110752947A (en) K8s cluster deployment method and device, and deployment platform
CN107733985B (en) Method and device for deploying functional components of cloud computing system
Sandobalin et al. An infrastructure modelling tool for cloud provisioning
CN110096424B (en) Test processing method and device, electronic equipment and storage medium
CN108897547B (en) Software automation deployment method and device
CN111459539B (en) Continuous integration pipeline operation method and device based on mirror layering
CN111580926A (en) Model publishing method, model deploying method, model publishing device, model deploying device, model publishing equipment and storage medium
CN113778486B (en) Method, device, medium and equipment for containerization processing of code pipeline
CN110673923A (en) XWIKI system configuration method, system and computer equipment
CN113377665B (en) Container technology-based testing method and device, electronic equipment and storage medium
CN116860266A (en) Application containerized deployment method and device, electronic equipment and storage medium
CN116301951B (en) Micro-service application installation upgrading method and device based on kubernetes
CN114047953A (en) Pipeline configuration method and device, computer equipment and storage medium
CN117112122A (en) Cluster deployment method and device
CN115421740A (en) Deployment method and device of cloud native application
CN110109684B (en) Block chain link point management proxy service installation method, electronic device and storage medium
CN114912897A (en) Workflow execution method, workflow arrangement method and electronic equipment
CN112685051A (en) Method, device, platform and storage medium for automatically executing shell script
CN113448650A (en) Live broadcast function plug-in loading method, device, equipment and storage medium
CN115794659B (en) Distributed parallel testing method, device, equipment and medium for CFD software
CN111897565A (en) Data processing method, device and equipment based on Internet of things

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination