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) $

 

 

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
目录
相关文章
|
4月前
|
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格式)
30 0
|
4月前
|
运维 Shell Linux
ansible汇总(1)
公司的服务器越来越多, 维护一些简单的事情都会变得很繁琐。用shell脚本来管理少量服务器效率还行, 服务器多了之后, shell脚本无法实现高效率运维。这种情况下,我们需要引入自动化运维工具, 对多台服务器实现高效运维。
48 0
|
4月前
|
关系型数据库 MySQL PHP
ansible汇总(3)
roles介绍 roles(角色): 就是通过分别将variables, tasks及handlers等放置于单独的目录中,并可以便捷地调用它们的一种机制。
31 1
|
8月前
|
网络安全 开发工具
ansible-2
ansible-2
42 1
|
8月前
|
XML 关系型数据库 应用服务中间件
|
8月前
|
安全 Shell Linux
|
8月前
|
Unix 大数据 网络安全
Ansible详解(1)——认识ansible
Ansible详解(1)——认识ansible
114 0
|
9月前
|
存储 安全 Linux
ansible 初识
Ansible是一个开源配置管理工具,可以使用它来自动化任务,部署应用程序实现IT基础架构。Ansible可以用来自动化日常任务,比如,服务器的初始化配置、安全基线配置、更新和打补丁系统,安装软件包等。
81 1
|
运维 网络安全 开发工具
ansible使用
ansible使用
186 0
|
测试技术 Go Apache