In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
What is the architecture and working principle of Ansible? for this question, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
Ansible is a model-driven configuration manager that supports multi-node publishing and remote task execution. SSH is used by default for remote connections. There is no need to install additional software on the managed node and can be extended using a variety of programming languages.
I. basic structure of Ansible
The above figure shows the basic architecture of ansible, which is composed of the following parts:
Core: ansible
Core modules (Core Modules): these are all modules that come with ansible.
Expansion module (Custom Modules): if the core module is not sufficient to perform a function, you can add an extension module
Plug-in (Plugins): complements the function of the module
Script (Playbooks): a task profile for ansible that defines multiple tasks in the script and is executed automatically by ansible
Connection plug-in (Connectior Plugins): ansible connects to each host based on the connection plug-in. Although ansible connects to each host using ssh, it also supports other connection methods, so a connection plug-in is required.
Host cluster (Host Inventory): defines hosts managed by ansible
Second, the working principle of Ansible
The above are two ansible working schematic diagrams found on the Internet, both of which are basically an extension of the architecture diagram. You can see from the picture above:
1. The management side supports local, ssh and zeromq to connect the managed end. The ssh-based connection is used by default-this part corresponds to the connection module in the basic architecture diagram.
2. Host Inventory (host cluster) can be classified by application type, and the management node realizes the corresponding operation through all kinds of modules-single module, batch execution of single command, which can be called ad-hoc.
3. The management node can realize the collection of multiple task through playbooks to realize one kind of function, such as the installation and deployment of web service, the batch backup of database server and so on. Playbooks we can simply understand that the system through the combination of multiple ad-hoc operation configuration files.
III. Seven orders of ansible
After installing ansible, we found that ansible provided us with a total of seven instructions: ansible, ansible-doc, ansible-galaxy, ansible-lint, ansible-playbook, ansible-pull, ansible-vault. Here we only look at the usage section, and the details can be obtained by "instruction-h".
1 、 ansible
[root@localhost] # ansible-h
Usage: ansible [options]
Ansible is the core part of the instruction, which is mainly used to execute ad-hoc commands, that is, a single command. The default needs to be followed by the host and options, and when the module is not specified by default, the command module is used. Such as:
[root@361way.com] # ansible 192.168.0.102-a 'date'
192.168.0.102 | success | rc=0 > >
Tue May 12 22:57:24 CST 2015
However, the modules used by default can be modified in ansible.cfg. The parameters under the ansible command are explained as follows:
2 、 ansible-doc
Ansible-doc-h
Usage: ansible-doc [options] [module...]
This directive is used to view module information. There are two common parameters,-l and-s, as follows:
/ / list all installed modules
# ansible-doc-l
/ / View the usage of a specific module, such as the command module
# ansible-doc-s command
3 、 ansible-galaxy
Ansible-galaxy-h
Usage: ansible-galaxy [init | info | install | list | remove] [--help] [options].
The ansible-galaxy instruction is used to easily download third-party extension modules from https://galaxy.ansible.com/ sites, and we can vividly understand that they are similar to yum under centos, pip under python or easy_install. The following is an example:
[root@localhost ~] # ansible-galaxy install aeriscloud.docker
-downloading role 'docker', owned by aeriscloud
-downloading role from https://github.com/AerisCloud/ansible-docker/archive/v1.0.0.tar.gz
-extracting aeriscloud.docker to / etc/ansible/roles/aeriscloud.docker
-aeriscloud.docker was installed successfully
This installs an aeriscloud.docker component, with the aeriscloud in front of the user name that created the module on galaxy, followed by its module. In practical applications, you can also specify txt or yml files to download and install multiple components. You can refer to the official documentation for this section.
4 、 ansible-lint
Ansible-lint is a tool for checking the syntax of playbook. The usage is ansible-lint playbook.yml.
5 、 ansible-playbook
This instruction is the most frequently used instruction, which performs the corresponding action after reading the playbook file, which will be used as a key point later.
6 、 ansible-pull
This instruction uses another mode that needs to talk about ansible-pull mode, which is contrary to the push mode that we often use, and it applies to the following scenarios: you have a large number of machines to configure, and it takes a lot of time to use very high threads; you have to run Anisble on a machine that does not have a network connection, such as installing after startup. This part will also be discussed in a separate section.
7 、 ansible-vault
Ansible-vault is mainly used in configuration files that contain sensitive information and do not want it to be seen. Vault can help you encrypt / decrypt this configuration file, which belongs to advanced usage. Mainly for playbooks, such as when it comes to configuring passwords or other variables, you can encrypt through this instruction, so that what we see through cat is a password string file, which needs to be opened by entering a pre-set password when editing. When this kind of playbook file is executed, you need to add the-- ask-vault-pass parameter, and you also need to enter a password before it can be executed normally.
This is the answer to the question about the architecture and working principle of Ansible. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.