ansible,


ansible 

 

 

 

Mr . Neo  Chan , 陈景峰(BG7NYT)

 

文档尚未完成,请勿转载!

版权 © 2008, 2009, 2010, 2011, 2012 Copyright Editor Groups, All Rights Reserved

版权声明

转载请与作者联系,转载时请务必标明文章原始出处和作者信息及本声明。

文档出处:
http://netkiller.sourceforge.net
http://netkiller.github.com

 

$Date: 2012-04-17 18:49:40 +0800 (Tue, 17 Apr 2012) $

下面是我多年积累下来的经验总结,整理成文档供大家参考:

 

Netkiller Architect 手札 Netkiller Linux 手札 Netkiller Developer 手札 Netkiller Security 手札
Netkiller Debian 手札 Netkiller CentOS 手札 Netkiller FreeBSD 手札 Netkiller Shell 手札
Netkiller Web 手札 Netkiller Monitoring 手札 Netkiller Storage 手札 Netkiller Mail 手札
Netkiller Database 手札 Netkiller PostgreSQL 手札 Netkiller MySQL 手札 Netkiller LDAP 手札
Netkiller Cryptography 手札 Netkiller Docbook 手札 Netkiller Version 手札 Netkiller Multimedia 手札
Netkiller Cisco IOS 手札 Netkiller Intranet 手札 Netkiller Management 手札 Netkiller Installation 手札

 

 

1. ansible

http://ansible.github.com/

Ansible is a radically simple model-driven configuration management, deployment, and command execution framework.

1.1. install

yum install ansible
			

1.2. Getting Started

Your first commands

/etc/ansible/hosts

# vim /etc/ansible/hosts

192.168.2.10
192.168.2.11
192.168.2.12
192.168.2.13
192.168.2.14
192.168.2.15
			

创建SSH公钥与私钥

ssh-keygen
			

将公钥文件复制到目标服务器

ssh-copy-id root@192.168.2.10
ssh-copy-id root@192.168.2.11
ssh-copy-id root@192.168.2.12
ssh-copy-id root@192.168.2.13
ssh-copy-id root@192.168.2.14
ssh-copy-id root@192.168.2.15
			

连接与验证测试 ansible all -m ping

# ansible all -m ping
192.168.2.10 | success >> {
    "module": "ping",
    "ping": "pong"
}

192.168.2.13 | success >> {
    "module": "ping",
    "ping": "pong"
}

192.168.2.14 | success >> {
    "module": "ping",
    "ping": "pong"
}

192.168.2.11 | success >> {
    "module": "ping",
    "ping": "pong"
}

192.168.2.15 | success >> {
    "module": "ping",
    "ping": "pong"
}

192.168.2.12 | success >> {
    "module": "ping",
    "ping": "pong"
}
			

1.3. ansible - run a command somewhere else

指定用户

# ansible all -m ping -u root

 

 

1.3. ansible - run a command somewhere else

指定用户

# ansible all -m ping -u root
			

1.4. ansible-playbook - run an ansible playbook

定义组

# cat /etc/ansible/hosts
[www]
192.168.2.23
			

创建yml文件

# cat test.yml
---
- hosts: www
  user: root
  tasks:
  - name: no selinux
    action: command /usr/sbin/setenforce 0

  - name: no iptables
    action: service name=iptables state=stopped

  - name: made up task just to show variables work here
    action: command /bin/echo release is $release
			

执行任务

# ansible-playbook test.yml -u root -T 1

PLAY [www] *********************

GATHERING FACTS *********************
ok: [192.168.2.23]

TASK: [no selinux] *********************
ok: [192.168.2.23]

TASK: [no iptables] *********************
ok: [192.168.2.23]

TASK: [made up task just to show variables work here] *********************
ok: [192.168.2.23]

PLAY RECAP *********************
192.168.2.23                   : ok=4    changed=2    unreachable=0    failed=0

相关内容

    暂无相关文章