ansible

简介:

ansible 

 

 

 

Mr . Neo  Chan , 陈景峰(BG7NYT)

 

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

版权声明

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

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

 

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

 

 

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
目录
相关文章
|
11月前
|
Kubernetes Docker 容器
ansible汇总(2)
playbook(剧本): 是ansible用于配置,部署,和管理被控节点的剧本。用于ansible操作的编排。 参考:https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html 使用的格式为yaml格式(saltstack,elk,docker,docker-compose,kubernetes等也都会用到yaml格式)
52 0
|
网络安全 开发工具
ansible-2
ansible-2
58 1
|
运维 网络安全 Python
ansible-1
ansible-1
54 0
|
运维 Shell 网络安全
ansible(1)
Ansible概述:是一个配置管理系统(configuration management system),当下最流行的批量自动化运维工具之一.
|
XML 关系型数据库 应用服务中间件
|
Unix 大数据 网络安全
Ansible详解(1)——认识ansible
Ansible详解(1)——认识ansible
160 0
|
运维 网络安全 开发工具
ansible使用
ansible使用
205 0
|
测试技术 Go Apache
|
存储 Ubuntu Shell
|
Shell Apache 数据安全/隐私保护