-
Notifications
You must be signed in to change notification settings - Fork 159
准备控制机
ftao edited this page Jan 3, 2016
·
4 revisions
for Ubuntu
sudo apt-get install python-pip
sudo pip install -U ansible
git clone https://github.com/ftao/vpn-deploy-playbook.git
cd vpn-deploy-playbook
ansible-galaxy install --force -r requirements.yml
inventory 中定义了所有被管理的服务器,以及它们的分组。 从示例文件复制出一份inventory 。
cp ansible_hosts.example ansible_hosts
使用你熟悉的编辑器打开 ansible_hosts
, 在里面加入服务器信息。
关于该文件的语法和格式请阅读ansible 的文档。
http://docs.ansible.com/intro_inventory.html
添加一台服务器,加入类似下面的信息。
hostname.example.com ansible_ssh_host=ip.of.server ansible_ssh_user=some-user
如果只需要管理一台机器,你可以直接把这台机器作为控制机,ansible_hosts
中就可以这么写
localhost ansible_connection=local
将服务器加入某一个组,比如说如果该服务器提供PPTP 服务, 可以使用下面的写法,将它加入到PPTP 组中。
[pptp]
servername.example.com
#localhost
大部分情况下面,某个组的变量都会有默认值, 定义在group_vars/groupname.yml.example
中, 请将该文件复制到
group_vars/groupname.yml
, 然后在该文件中修改。
如果你需要针对某台服务器修改某个变量, 你可以建立一个文件 host_vars/hostname.yml
, 并且在里面加入对应的变量。