Ansible基础

Ansible

GitHub:https://github.com/ansible/

官方:https://www.ansible.com

官方文档:https://docs.ansible.com

Ansible命令使用

Ansible语法使用ansible <pattern_goes_here> -m <module_name> -a <arguments>

-m NAME,–module-name=NAME:指定执行使用的模块

-u USERNAME,–user=USERNAME:指定远程主机以USERNAME运行命令

-s,–sudo:相当于Linux系统下的sudo命令

-USUDO_USERNAME,–sudo-user=SUDO_USERNAME:使用sudo,相当于Linux下的sudo命令

-C -check只检查不实际执行

-e EXTRA_VARS,引用外部参数

-i INVENTORY,指定仓库列表,默认/etc/ansible/hosts

–list-hosts,列出执行主机列

安装目录

配置文件目录:/etc/ansible/

执行文件目录:/usr/bin/

Lib库依赖目录:/usr/lib/pythonX.X/site-packages/ansible/

Help文档目录:/usr/share/doc/ansible-X.X.X/

Man文档目录:/usr/share/man/man1/

安装

1.安装

[root@docker ~]# git clone git://github.com/ansible/ansible.git --recursive
[root@docker ~]# cd ansible/

 2.进行源码安装

[root@docker ansible]# make && make install

 3.先安装pip包管理工具,然后安装ansible 程序所使用的几个python模块

[root@docker ansible]# easy_install pip
[root@docker ansible]# pip install paramiko PyYAML Jinja2 httplib2 six

 4.更新ansible 代码时用到的两条命令

[root@docker ansible]# git pull --rebase
Current branch devel is up to date.
[root@docker ansible]# git submodule update --init --recursive
原文地址:https://www.cnblogs.com/cevinchen/p/9513600.html