Script generation method and device, equipment and storage medium
The Playbook execution script is generated through the preset Ansible task framework and directed acyclic graph interactive interface, which solves the problem of high difficulty in writing Ansible playbook and realizes low-threshold and convenient script writing.
Patent Information
- Application Number
- CN202410951191.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-16
- Publication Date
- 2024-08-20
AI Technical Summary
Ansible playbooks are difficult to write and require in-depth programming knowledge and an in-depth understanding of the Ansible framework, resulting in a high threshold for non-professionals to use automated operation and maintenance tools.
Provides a script generation method that uses the preset Ansible task framework and directed acyclic graph interactive interface to generate Playbook execution scripts through task configuration information and task relationship operation instructions, lowering the writing threshold and improving convenience.
By flexibly setting task relationships through the pre-set task framework and graphical interactive interface, the Playbook execution script can be written with only a small amount of coding, which reduces the difficulty of writing, improves the convenience of writing, and reduces the reliance on complex syntax.
Smart Images

Figure CN118519630A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of operation and maintenance technology, and in particular to a script generation method, device, equipment and storage medium. Background Art
[0002] Ansible is a powerful open source automated operation and maintenance tool, mainly used for IT (Information Technology) configuration management, application deployment, task execution, and file synchronization between multiple nodes. It does not require any client software to be installed on the controlled nodes, and only relies on SSH (Secure Shell, secure network protocol) or WinRM (remote management service for Windows environment) to perform tasks. One of the core concepts of Ansible is Playbook, which is a script written in YAML (a format for expressing data serialization) language to describe the process of automated tasks. At present, Ansible playbooks are usually written manually. Writing high-quality Ansible execution scripts requires deep programming knowledge and a deep understanding of the Ansible framework, which sets a high threshold for many non-professionals who want to use Ansible for automated operation and maintenance.
[0003] It can be seen that how to reduce the difficulty of writing Ansible playbooks and improve the convenience of writing Playbooks is a problem to be solved in this field. Summary of the invention
[0004] In view of this, the purpose of the present invention is to provide a script generation method, device, equipment and storage medium, which can flexibly set the task relationship between various script tasks based on the graphical interactive interface of the directed acyclic graph, and only a small amount of coding is required to complete the writing of the Playbook execution script, which lowers the threshold and improves convenience. The specific scheme is as follows:
[0005] In a first aspect, the present application provides a script generation method, comprising:
[0006] Obtaining task configuration information for a preset Ansible task framework to generate a number of current script tasks based on the task configuration information and the corresponding preset Ansible task framework; the preset Ansible task framework is a pre-set task framework for generating Ansible script tasks;
[0007] Based on a preset directed acyclic graph interactive interface, task relationship operation instructions for a number of current script tasks are obtained; the task relationship operation instructions include operation instructions for preset task plug-ins and preset task dependencies;
[0008] Generate a final Playbook execution script according to the task relationship operation instructions and several of the current script tasks.
[0009] Optionally, before obtaining the task configuration information for the preset Ansible task framework, the method further includes:
[0010] Based on the types and corresponding structures of Ansible tasks, a task framework for several task types is constructed to obtain a preset Ansible task framework; the task types include shell tasks, variable setting tasks, conditional judgment tasks, Jinja2 template tasks, compression or decompression tasks, and file creation or deletion tasks.
[0011] Optionally, the generating a plurality of current script tasks based on the task configuration information and a corresponding preset Ansible task framework includes:
[0012] According to the task type corresponding to the task configuration information, the task configuration information is added to a preset Ansible task framework of the corresponding task type to obtain corresponding current script tasks.
[0013] Optionally, before acquiring task relationship operation instructions for a plurality of current script tasks based on a preset directed acyclic graph interactive interface, the method further includes:
[0014] Based on the execution scenario of Ansible tasks, several task plug-ins are constructed to obtain preset task plug-ins; the preset task plug-ins include a loop plug-in, a regular plug-in, a host selection plug-in, a message output plug-in, an environment variable declaration plug-in and a one-time execution plug-in.
[0015] Optionally, the preset task dependency relationship includes a sequential structure, a concurrent structure, a conditional structure between tasks, and a dependency structure between tasks and preset task plug-ins.
[0016] Optionally, the obtaining of task relationship operation instructions for a plurality of current script tasks based on a preset directed acyclic graph interactive interface includes:
[0017] Acquire a first drag instruction for the current script task based on a preset directed acyclic graph interactive interface;
[0018] Acquire a second drag instruction for a preset task plug-in based on a preset directed acyclic graph interaction interface;
[0019] A third drag instruction for the preset task dependency is obtained based on a preset directed acyclic graph interaction interface.
[0020] Optionally, generating a final Playbook execution script according to the task relationship operation instruction and the plurality of current script tasks includes:
[0021] Based on the first drag instruction, the second drag instruction and the third drag instruction, the final Playbook execution script is constructed using the relevant current script tasks, preset task plug-ins and preset task dependencies.
[0022] In a second aspect, the present application provides a script generation method, comprising:
[0023] A task generation module, used to obtain task configuration information for a preset Ansible task framework, so as to generate a number of current script tasks based on the task configuration information and the corresponding preset Ansible task framework; the preset Ansible task framework is a pre-set task framework for generating Ansible script tasks;
[0024] An operation instruction acquisition module, used to acquire task relationship operation instructions for several current script tasks based on a preset directed acyclic graph interactive interface; the task relationship operation instructions include operation instructions for preset task plug-ins and preset task dependencies;
[0025] An execution script generation module is used to generate a final Playbook execution script according to the task relationship operation instructions and a number of the current script tasks.
[0026] In a third aspect, the present application provides an electronic device, including:
[0027] Memory, used to store computer programs;
[0028] A processor is used to execute the computer program to implement the script generation method as described above.
[0029] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, which, when executed by a processor, implements the script generation method as described above.
[0030] It can be seen that the present application first obtains the task configuration information for the preset Ansible task framework to generate several current script tasks based on the task configuration information and the corresponding preset Ansible task framework; the preset Ansible task framework is a preset task framework for generating Ansible script tasks; then based on the preset directed acyclic graph interactive interface, task relationship operation instructions for several of the current script tasks are obtained; the task relationship operation instructions include operation instructions for preset task plug-ins and preset task dependencies; then the final Playbook execution script is generated according to the task relationship operation instructions and several of the current script tasks. It can be seen that the present application can pre-set the task framework, and the current script task can be obtained through the task configuration information. After that, the task relationship between each script task can be flexibly set through the graphical interactive interface based on the directed acyclic graph, and finally the corresponding Playbook execution script is generated; only a small amount of coding is required in the process to complete the writing of the Playbook execution script, without the need to deeply learn the complex Playbook syntax, which reduces the threshold for writing Playbook execution scripts and improves convenience. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0032] Figure 1 A flow chart of a script generation method disclosed in this application;
[0033] Figure 2 A schematic diagram of a shell task framework disclosed in this application;
[0034] Figure 3 A schematic diagram of a variable setting task framework disclosed in this application;
[0035] Figure 4 A schematic diagram of a conditional judgment task framework disclosed in this application;
[0036] Figure 5 A schematic diagram of a Jinja2 template task framework disclosed in this application;
[0037] Figure 6 A schematic diagram of a compression or decompression task framework disclosed in this application;
[0038] Figure 7A schematic diagram of a file creation or deletion task framework disclosed in this application;
[0039] Figure 8 A schematic diagram of a file modification task framework disclosed in this application;
[0040] Fig. 9 A schematic diagram of a file / directory status detection task framework disclosed in this application;
[0041] Fig.10 A schematic diagram of a file copying task framework disclosed in this application;
[0042] Fig.11 A schematic diagram of a sequential task structure disclosed in this application;
[0043] Fig.12 A schematic diagram of a concurrent task structure disclosed in this application;
[0044] Fig.13 A schematic diagram of a conditional task structure disclosed in this application;
[0045] Fig.14 A schematic diagram of a task and plug-in dependency relationship disclosed in this application;
[0046] Fig.15 A schematic diagram of a specific Playbook execution script disclosed in this application;
[0047] Fig.16 This is a schematic diagram of the structure of a script generating device disclosed in this application;
[0048] Fig.17 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] See also Figure 1 As shown, an embodiment of the present invention discloses a script generation method, including:
[0051] Step S11, obtaining task configuration information for a preset Ansible task framework, so as to generate a plurality of current script tasks based on the task configuration information and the corresponding preset Ansible task framework; the preset Ansible task framework is a pre-set task framework for generating Ansible script tasks.
[0052] In the embodiments of the present application, several Ansible task frameworks can be pre-set. While retaining the powerful functional characteristics of Ansible, the instructions of Ansible can be reconstructed based on user-friendliness and operational efficiency to make it more compact in structure. In a specific embodiment, before obtaining the task configuration information for the preset Ansible task framework, it can also include: constructing a task framework for several task types based on the type and corresponding structure of the Ansible task to obtain a preset Ansible task framework; the task types include shell (an interface program) tasks, variable setting tasks, conditional judgment tasks, Jinja2 (a template engine) template tasks, compression or decompression tasks, and file creation or deletion tasks. Specifically, a task framework for several corresponding task types can be constructed based on the type and task structure of the original Ansible task; among them, such as Figure 2 The shell task shown allows users to execute shell commands on the remote host to implement specific operations, and it has high flexibility. Users can freely write and submit shell commands according to the needs of specific scenarios and execute them on the remote server. All kinds of tasks, whether system maintenance, data processing or service deployment, can be solved efficiently. Users can decide whether the shell task captures the output of command execution results. For tasks that require real-time monitoring or subsequent analysis, users can choose to save all information during the command execution process; for tasks that only need to be executed without recording the results, you can choose not to capture the results. In addition, the shell task also includes the option of variable list setting, which further enhances its scalability and adaptability. Users can obtain and replace the parameter values of shell commands by pre-defining and setting variable lists. Such as Figure 3The variable setting task shown is to assign specific values to Ansible variables and realize flexible and dynamic application of variables in the entire task process. Users can directly create variables in the task and set their values. In addition, this task can receive the output results of the predecessor task (if the predecessor task records the output). Users can customize the processing logic to deeply process and convert these input data, and then assign them to variables. It should be pointed out that by using auxiliary plug-ins such as loop plug-ins and regular plug-ins, the processing capabilities of variable setting tasks can be greatly improved, so that variable setting tasks can process sequence data and cope with complex logical scenarios. For example, when different information from different hosts needs to be set for a certain parameter, the variable setting task can traverse a list containing all host information and set the corresponding variable value according to the characteristics of each host in the loop. The variable setting task builds a powerful and flexible variable management framework by accepting the output of the predecessor task, user-defined processing logic and auxiliary plug-ins. As Figure 4 The conditional judgment task shown in Figure 1 plays the role of a logical decision maker. The user determines the sequence of tasks to be executed next by setting the conditional statements of the task. Figure 5 The Jinja2 template task shown in the figure can dynamically configure various files. By using the powerful Jinja2 template engine, the file content on the remote host can be accurately controlled and managed by filling and rendering the template file. Users can define Jinja2 template files in the task and specify the files on the remote host to be affected. Figure 6 The compression / decompression task shown is used to compress or decompress files on a remote host. Figure 7 The file creation or deletion task shown is used for operations such as creating and deleting, copying and moving files or directories on the remote host, and creating soft links. In a specific embodiment, it may include the following: Figure 8 The file modification task shown in the figure can support users to insert custom content at a specified location in a specified file, or delete the specified file content. Fig. 9 The file / directory status detection task shown is used to detect whether a file or directory exists on the remote host, and the result can be saved in a variable. Fig.10The file copy task shown can meet the user's requirements for copying local files to a remote host. It can specify the local files to be copied and the target location to copy them to on the remote host. Accordingly, in a specific embodiment, it can include: a host name setting task for setting the name of the remote host; a user group and user account management task for creating or deleting users and user groups on the remote host, and switching task execution users; a failure termination task is generally used in conjunction with a conditional judgment plug-in. If the termination condition is met, the entire task fails and outputs a failure message. Debug task: used to output debugging information during the execution of the Playbook in order to better understand the status of task execution and the value of variables. Custom messages can be output to record steps, status changes or other important information, and can also be used to view the specific value of a variable in an intermediate step.
[0053] In a specific embodiment, the generating of several current script tasks based on the task configuration information and the corresponding preset Ansible task framework may include: adding the task configuration information to the preset Ansible task framework of the corresponding task type according to the task type corresponding to the task configuration information, and obtaining several corresponding current script tasks. Specifically, the current script task can be obtained by adding the task configuration information to the Ansible task framework of the corresponding task type, and the script tasks at this time are independent tasks and there is no task relationship.
[0054] Step S12: acquiring task relationship operation instructions for several current script tasks based on a preset directed acyclic graph interactive interface; the task relationship operation instructions include operation instructions for preset task plug-ins and preset task dependencies.
[0055] In this embodiment, based on the visual DAG (Directed Acyclic Graph) workflow platform, the relationship between tasks can be clearly expressed, and based on the directed acyclic graph interactive interface, task relationship operation instructions for several current script tasks can be obtained, which are used to set the relationship between tasks; wherein, the task relationship operation instructions include setting instructions for task plug-ins, and setting instructions for dependency relationships between tasks or between tasks and plug-ins.
[0056] In a specific embodiment, before obtaining the task relationship operation instructions for the current script tasks based on the preset directed acyclic graph interactive interface, it can also include: constructing several task plug-ins based on the execution scenario of the Ansible task to obtain the preset task plug-in; the preset task plug-in includes a loop plug-in, a regular plug-in, a host selection plug-in, a message output plug-in, an environment variable declaration plug-in and a one-time execution plug-in. Specifically, different task plug-ins can be pre-set based on different task execution scenarios, and can specifically include: a loop plug-in: used to implement a loop task, which can traverse the values in the data structure set by the user, and the obtained values and their indexes can be used in the task. In actual application, the user first needs to clearly set the data structure to be traversed, whether it is a simple numerical sequence, a string array, or a complex nested structure. The loop plug-in obtains each element and its index therein for the task using this plug-in. Regular plug-in: You can use regular expressions to match content and set new variables according to the matching content. Host selection plug-in: used to specify the task execution host. Message plug-in: used for message output. Environment variable declaration plug-in: used to declare environment variables during task execution. run_once (one-time execution) plug-in: specifies that the task is executed only once.
[0057] Furthermore, the preset task dependency relationship includes the sequential structure, concurrent structure, conditional structure between tasks, and the dependency structure between tasks and preset task plug-ins. All task nodes form a DAG graph, which mainly has four structures: sequential structure, concurrent structure, conditional structure and dependency structure. Among them, the sequential structure is the task nodes that are executed in series, such as Fig.11 The following are three tasks in a sequential structure. A concurrent structure consists of several tasks that can be executed in parallel, such as Fig.12 The following shows the tasks of the concurrent structure. The conditional structure consists of conditional judgment tasks and their different branches, such as Fig.13 The following is a task with a conditional structure. It should be noted that the dependency structure is quite special. It is not a structural relationship between tasks, but a relationship between tasks and plug-ins. Plug-ins are attached to task nodes to constrain task nodes or give them richer functions. For example, Fig.14 The following is a diagram of the dependency relationship between tasks and plug-ins. These basic structural combinations constitute the entire workflow, playing the role of process control and changing the execution order. These four structures cover almost all situations in the workflow process.
[0058] In a specific embodiment, the task relationship operation instructions for several current script tasks are obtained based on a preset directed acyclic graph interaction interface, which may include: obtaining a first drag instruction for the current script task based on a preset directed acyclic graph interaction interface; obtaining a second drag instruction for a preset task plug-in based on a preset directed acyclic graph interaction interface; obtaining a third drag instruction for the preset task dependency relationship based on a preset directed acyclic graph interaction interface. Specifically, when obtaining the task relationship operation instructions, the sequential relationship between tasks, the relationship between plug-ins and tasks, and the dependency relationship between tasks correspond to different drag instructions respectively; so as to organize the task sequence based on different drag instructions, and set the dependency relationship and execution order between tasks.
[0059] Step S13: Generate a final Playbook execution script according to the task relationship operation instructions and the current script tasks.
[0060] In this embodiment, the dependency and execution order between tasks can be set based on the task relationship operation instructions and the corresponding current script tasks, and the task flow can be clarified to generate the final Playbook execution script. In a specific embodiment, the generation of the final Playbook execution script based on the task relationship operation instructions and the current script tasks may include: based on the first drag instruction, the second drag instruction and the third drag instruction, the final Playbook execution script is constructed using the relevant current script tasks, preset task plug-ins and preset task dependencies. Specifically, based on the directed acyclic graph interactive interface, users can Figure 1 Similarly, set the first drag-and-drop instruction for the task, the second drag-and-drop instruction for the plug-in, and the third drag-and-drop instruction for the dependency, so that the order of tasks, the relationship between plug-ins and tasks, and the execution relationship between tasks can be set respectively; through these drag-and-drop instructions, the final Playbook execution script can be constructed. It should be pointed out that in a specific embodiment, several execution script templates can be pre-set, and the corresponding Playbook execution script can be obtained by simply entering the task configuration information in the template, such as Fig.15 A specific Playbook execution script is shown.
[0061] It can be seen that the present application can pre-set the task framework, obtain the current script task through the task configuration information, and then flexibly set the task relationship between the script tasks through the graphical interactive interface based on the directed acyclic graph, and finally generate the corresponding Playbook execution script; only a small amount of coding is required to complete the writing of the Playbook execution script in the process, and there is no need to deeply learn the complex Playbook syntax, which lowers the threshold for writing Playbook execution scripts, and uses a directed acyclic graph as a construction model for the workflow, allowing users to organize task sequences in a clear and orderly manner; easily setting the dependencies and execution order between tasks greatly reduces the difficulty of understanding complex logical relationships, even in the face of multi-layer nested or conditional branching task structures, they can see it at a glance and get started quickly; users can also refer to a series of built-in best practice templates to quickly build basic workflows.
[0062] like Fig.16 As shown, the embodiment of the present application discloses a script generation method, including:
[0063] The task generation module 11 is used to obtain task configuration information for a preset Ansible task framework, so as to generate a number of current script tasks based on the task configuration information and the corresponding preset Ansible task framework; the preset Ansible task framework is a pre-set task framework for generating Ansible script tasks;
[0064] An operation instruction acquisition module 12 is used to acquire task relationship operation instructions for several current script tasks based on a preset directed acyclic graph interactive interface; the task relationship operation instructions include operation instructions for preset task plug-ins and preset task dependencies;
[0065] The execution script generation module 13 is used to generate a final Playbook execution script according to the task relationship operation instructions and a number of the current script tasks.
[0066] It can be seen that the present application can pre-set the task framework, obtain the current script task through the task configuration information, and then flexibly set the task relationship between the script tasks through a graphical interactive interface based on a directed acyclic graph, and finally generate the corresponding Playbook execution script; only a small amount of coding is required to complete the writing of the Playbook execution script during the process, without the need to in-depth study of the complex Playbook syntax, which lowers the threshold for writing Playbook execution scripts and improves convenience.
[0067] In a specific embodiment, the device may further include:
[0068] The task framework building module is used to build task frameworks for several task types based on the types and corresponding structures of Ansible tasks to obtain a preset Ansible task framework; the task types include shell tasks, variable setting tasks, conditional judgment tasks, Jinja2 template tasks, compression or decompression tasks, and file creation or deletion tasks.
[0069] In a specific embodiment, the task generation module 11 may include:
[0070] The task generation unit is used to add the task configuration information to a preset Ansible task framework of the corresponding task type according to the task type corresponding to the task configuration information, so as to obtain a corresponding number of current script tasks.
[0071] In a specific embodiment, the device may further include:
[0072] The plug-in construction module is used to construct several task plug-ins based on the execution scenario of the Ansible task to obtain the preset task plug-in; the preset task plug-in includes a loop plug-in, a regular plug-in, a host selection plug-in, a message output plug-in, an environment variable declaration plug-in and a one-time execution plug-in.
[0073] In a specific embodiment, the operation instruction acquisition module 12 may include:
[0074] A first operation instruction acquisition unit, used for acquiring a first drag instruction for the current script task based on a preset directed acyclic graph interaction interface;
[0075] A second operation instruction acquisition unit, used to acquire a second drag instruction for a preset task plug-in based on a preset directed acyclic graph interaction interface;
[0076] The third operation instruction acquisition unit is used to acquire a third drag instruction for the preset task dependency relationship based on a preset directed acyclic graph interaction interface.
[0077] In another specific embodiment, the execution script generation module 13 may include:
[0078] An execution script generation unit is used to construct a final Playbook execution script based on the first drag instruction, the second drag instruction and the third drag instruction using relevant current script tasks, preset task plug-ins and preset task dependencies.
[0079] Furthermore, the present application also discloses an electronic device. Fig.17 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.
[0080] Fig.17 A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the script generation method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0081] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0082] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0083] The operating system 221 is used to manage and control the hardware devices on the electronic device 20 and the computer program 222, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the script generation method executed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0084] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the script generation method disclosed above. The specific steps of the method can refer to the corresponding contents disclosed in the above embodiments, and will not be repeated here.
[0085] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0086] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0087] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0088] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0089] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A script generation method, characterized in that: include: Obtaining task configuration information for a preset Ansible task framework to generate a number of current script tasks based on the task configuration information and the corresponding preset Ansible task framework; the preset Ansible task framework is a pre-set task framework for generating Ansible script tasks; Based on a preset directed acyclic graph interactive interface, task relationship operation instructions for a number of current script tasks are obtained; the task relationship operation instructions include operation instructions for preset task plug-ins and preset task dependencies; Generate a final Playbook execution script according to the task relationship operation instructions and several of the current script tasks.
2. The script production method according to claim 1, characterized in that: Before obtaining the task configuration information for the preset Ansible task framework, the method further includes: Based on the types and corresponding structures of Ansible tasks, a task framework for several task types is constructed to obtain a preset Ansible task framework; the task types include shell tasks, variable setting tasks, conditional judgment tasks, Jinja2 template tasks, compression or decompression tasks, and file creation or deletion tasks.
3. The script production method according to claim 2, characterized in that: The generating of a plurality of current script tasks based on the task configuration information and the corresponding preset Ansible task framework includes: According to the task type corresponding to the task configuration information, the task configuration information is added to a preset Ansible task framework of the corresponding task type to obtain corresponding current script tasks.
4. The script production method according to claim 1, characterized in that: Before obtaining the task relationship operation instructions for the current script tasks based on the preset directed acyclic graph interactive interface, the method further includes: Based on the execution scenario of Ansible tasks, several task plug-ins are constructed to obtain preset task plug-ins; the preset task plug-ins include a loop plug-in, a regular plug-in, a host selection plug-in, a message output plug-in, an environment variable declaration plug-in and a one-time execution plug-in.
5. The script production method according to claim 4, characterized in that: The preset task dependency relationship includes a sequential structure, a concurrent structure, a conditional structure between tasks, and a dependency structure between tasks and preset task plug-ins.
6. The script production method according to any one of claims 1 to 5, characterized in that: The step of obtaining task relationship operation instructions for a plurality of current script tasks based on a preset directed acyclic graph interactive interface includes: Acquire a first drag instruction for the current script task based on a preset directed acyclic graph interactive interface; Acquire a second drag instruction for a preset task plug-in based on a preset directed acyclic graph interaction interface; A third drag instruction for the preset task dependency is obtained based on a preset directed acyclic graph interaction interface.
7. The script production method according to claim 6, characterized in that: The generating of the final Playbook execution script according to the task relationship operation instruction and the current script tasks includes: Based on the first drag instruction, the second drag instruction and the third drag instruction, the final Playbook execution script is constructed using the relevant current script tasks, preset task plug-ins and preset task dependencies.
8. A script generation method, characterized in that: include: A task generation module, used to obtain task configuration information for a preset Ansible task framework, so as to generate a number of current script tasks based on the task configuration information and the corresponding preset Ansible task framework; the preset Ansible task framework is a pre-set task framework for generating Ansible script tasks; An operation instruction acquisition module, used to acquire task relationship operation instructions for several current script tasks based on a preset directed acyclic graph interactive interface; the task relationship operation instructions include operation instructions for preset task plug-ins and preset task dependencies; An execution script generation module is used to generate a final Playbook execution script according to the task relationship operation instructions and a number of the current script tasks.
9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the script generation method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Used to store a computer program, which, when executed by a processor, implements the script generation method according to any one of claims 1 to 7.
Citation Information
Cited By
Multi-script execution method of virtual controller
CN119356817A
Multi-script execution method for a virtual controller
CN119356817B
