pip是python的包管理工具,使用它来安装Ansible非常简单,但是,需要注意的是这样安装的软件不会随操作系统的升级而升级,然而这样也无所谓。下面是从pip安装的命令
pip install ansible
从源码安装
从源码安装是获取最新版本的一个好方式,但是通过源码安装的版本没有发行版本那样经过良好的测试。在自己更新的时候也要很小心,同时还要确保操作系统系统更新之后,软件还能继续工作。从git库下载然后安装,使用以下命令
$ git clone git://github.com/ansible/ansible.git $ cd ansible $ sudo make install
Setting up Ansible Ansible needs to be able to get an inventory of the machines that you want to configure in order to manage them. This can be done in many ways due to inventory plugins. Several different inventory plugins are included with the base install. We will go over these later in the book, but for now we will cover the hosts file inventory. The default Ansible inventory file is named hosts and placed in /etc/ansible . It is formatted like an INI file. Group names are enclosed in square braces, and everything underneath it, down to the next group heading, gets assigned to that group. Machines can be in many groups at one time. Groups are used to allow you to configure many machines at once. You can use a group instead of a hostname as a host pattern in later examples, and Ansible will run the module on the entire group at once. In the following example, we have three machines in a group named webservers , namely site01 , site02 , and site01-dr . We also have a production group that consists of site01 , site02 , db01 , and bastion . [webservers] site01 site02 [production] site01 site02 db01 bastion
要管理设备,我们的Ansible首先要有一个设备清单。建立设备清单有很多自带的不同的插件,我们将在稍后介绍,现在我们先来建立一个简单的主机文件清单。默认的设备清单配置文件在/etc/ansible。python installation aborted他是一个类是ini的配置文件。其中,组名被方括号包裹,组名下面,在2个组名之间的配置是当前组的配置信息,一个主机可以同时属于多个组。组的设置可以让我们一次性配置管理多台主机。在稍后的例子里面,在pattern选项中,你可以使用组名来替代主机名,Ansible会一次在组内的所有主机上运行模块命令。在接下来的列子中,我们有3台机器在一个叫做webservers的组中,他们的名字分别是site01,site02 site01-dir。另外我们还有一个生产组,包括4台主机,分别是site01,site02,db01,bastion。
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/shouji/article-49614-3.html
你知道什么意思了吧
不可撼动