← 返回命令列表

Linux command

ansible 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Ping

ansible all -m ping

Example

ansible [webservers] -a "uptime"

Example

ansible [webservers] -a "apt update" --become

Example

ansible [hosts] -m [apt] -a "name=nginx state=present" --become

Example

ansible -i [inventory.ini] all -m ping

说明

ansible is an agentless IT automation tool that executes tasks on remote systems over SSH. It uses a push-based model, requiring no software installation on managed nodes beyond Python and SSH access. For ad-hoc commands, ansible executes modules against hosts matching a pattern. For complex automation, use ansible-playbook with YAML playbooks.

参数

-m _module_
Module to execute (default: command)
-a _args_
Module arguments
-i _inventory_
Inventory file or path
--become
Run operations with privilege escalation
-K, --ask-become-pass
Prompt for privilege escalation password
-u _user_
Connect as this user
-k, --ask-pass
Prompt for SSH password
-f _forks_
Number of parallel processes
-v, -vvv
Increase verbosity
--check
Dry run (don't make changes)
--list-hosts
List hosts matching pattern

FAQ

What is the ansible command used for?

ansible is an agentless IT automation tool that executes tasks on remote systems over SSH. It uses a push-based model, requiring no software installation on managed nodes beyond Python and SSH access. For ad-hoc commands, ansible executes modules against hosts matching a pattern. For complex automation, use ansible-playbook with YAML playbooks.

How do I run a basic ansible example?

Run `ansible all -m ping` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -m _module_ do in ansible?

Module to execute (default: command)