2.4.1 Ansible
//检查服务器存活
ansible web1 m ping
//复制本地文件到远程
ansible web1 m copy a “src=/etc/fstab dest=/tmp/fstab owner=root group=root mode=644 backup=yes”
图2-2 Ansible执行结果错误的结果返回
图2-3 Ansible执行结果正确的结果返回
ansible-galaxy [init|info|install|list|remove] [--help] [options] ...
(2) 第二部分的help用法显示[help]
ansible-galaxy init -help
Usage: ansible-galaxy init [options] role_name
Options:
-f, --force Force overwriting an existing role
-h, --help show this help message and exit
-c, --ignore-certs Ignore SSL certificate validation errors.
-p INIT_PATH, --init-path=INIT_PATH
The path in which the skeleton role will be created.
The default is the current working directory.
--offline Don't query the galaxy API when creating roles
-s API_SERVER, --server=API_SERVER
The API server destination
-v, --verbose verbose mode (-vvv for more, -vvvv to enable
connection debugging)
--version show program's version number and exit
其它选项的该help用法一样。
(3) 第三部分的参数项[options]
该部分结合第一部分的参数完成ansible-galaxy完整的功能用法,如:
ansible-galaxy init [options] role_name即ansible-galaxy init后跟[-f|-h|-c|-p|--offline|-s SERVER|-v|--version] 后跟rolename表示一条完整的命令。
具体可参考如下:
//下载用户hectcastro的nginx这个Role到本地并忽略错误(默认存放/etc/ansible/roles/)
ansible-galaxy --ignore-errors install azavea.git
因为ansible-galaxy是对https://galaxy.ansible.com该网站的上传、下载、配置类工作,如有类似如下报错,请确保该网站可正常访问。
the API server (galaxy.ansible.com) is not responding, please try again later.
*/20 * * * * root /usr/local/bin/ansible-pull -o -C 2.1.0 -d /srv/www/king-gw/ -i /etc/ansible/hosts -U git://git.kingifa.com/king-gw-ansiblepull
|