Seven commonly used commands for Ansible automated operation and maintenance

王林
Release: 2024-02-18 17:48:02
forward
621 people have browsed it

After installing ansible, we can use it through seven main instructions, which are: ansible, ansible-doc, ansible-galaxy, ansible-lint, ansible-playbook, ansible-pull, ansible-vault. We can learn how to use them by looking at the usage section of the command, and detailed information can be obtained by running "command -h".

Seven commonly used commands for Ansible automated operation and maintenanceAnsible common commands

ansible

The core part of Ansible is used to execute ad-hoc commands, that is, a single command. By default, the command needs to specify the host and option parts. If no module is specified, the command module is used by default. However, the module used by default can be modified in /etc/ansible/ansible.cfg, for example #module_name = command.

ansible 192.168.182.130 -a 'date'
Copy after login

ansible-doc

This command is used to view module information. Commonly used parameters include -l and -s

#列出所有已安装的模块ansible-doc-l
ansible-doc-l
#查看具体某模块的用法,这里如查看command模块
ansible-doc-s command
Copy after login

ansible-playbook

ansible-playbook command is the most commonly used command. It reads the playbook file and then performs corresponding actions. This will be discussed later.

ansible-galaxy

The ansible-galaxy command can easily download third-party extension modules from https://galaxy.ansible.com/, similar to centos' yum, python's pip or easy_install.

ansible-galaxy install aeriscloud.docker
Copy after login

ansible-lint

ansible-lint is a tool for checking the syntax of playbook. Usage is as follows:

ansible-lint playbook.yml
Copy after login

ansible-pull

The use of this instruction requires talking about another mode of ansible, pull mode, which is exactly the opposite of the push mode we usually use. It is suitable for the following scenarios: you have a huge number of machines that need to be configured, even if the usage is very high The threads still take a lot of time; you'll want to run Anisble on a machine without network connectivity, such as after installing it on boot.

ansible-vault

  • ansible-vault is mainly used when the configuration file contains sensitive information and you don’t want it to be seen. Vault can help you encrypt/decrypt the configuration file, which is an advanced usage.
  • Mainly for playbooks that involve configuring passwords or other variables, you can use this command to encrypt, so that what we see through cat will be a password string file. When editing, you need to enter the preset password. Open.
  • When executing this kind of playbook file, you need to add the --ask-vault-pass parameter, and you also need to enter a password before it can be executed normally.

The above is the detailed content of Seven commonly used commands for Ansible automated operation and maintenance. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:mryunwei.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template