Skip to main content

Ansible

Table of Contents​

介绍​

ansible 是一个基于 python 实现的自动化运维工具, 实现对多个系统进行批量化操作.

环境​

安装

 $ apt install ansible

配置节点​

编辑 /etc/ansible/hosts 添加群组或节点

[manager]
localhost

[node]
172.17.0.10

命令​

 $ ansible
$ ansible-doc
$ ansible-playbook
$ ansible-vault
$ ansible-console

$ ansible <host pattern> -m <module> -a <args>
$ ansible all -m shell -a "ifconfig"
>

查询​

 $ ansible --version
$ ansible all --list-host
>

执行命令​

 $ ansible <host pattern> -m command -a <command>
$ ansible <host pattern> -m shell -a <shell command>
>

文件​

 $ ansible node -m copy -a "src=/root/local dst=/root/remote"
$ ansible node -m fetch -a "src=/root/remote dst=/root/local"
>

Playbook​