部署搭建 Saltstack(centos6.6)

SaltStack介绍

官网:https://docs.saltstack.com/en/latest/

中国saltstack用户组http://www.saltstack.cn/

下图是它的子系统和扩展插件:

工作流:

 

 

Saltstack 分服务端master和客户端minion,安装Saltstack前先安装epel

阿里源:mirrors.aliyun.com
epel安装介绍:http://mirrors.aliyun.com/help/epel

一、安装

1)安装master(服务端)
yum install -y salt-master

2)安装minion(客户端)
yum install -y salt-minion

3)开机启动master(服务端)
chkconfig salt-master on

4)开机启动minion(客户端)
chkconfig salt-minion on

 

二、配置

1)修改master配置文件
vim /etc/salt/master

  • 找到file_roots这行,放开注释

 备注:base前面2个空格,- /srv/salt 前面4个空格

  • 找到pillar_roots这行,放开注释

2)启动master

/etc/init.d/salt-master start

3)修改monion配置文件

vim /etc/salt/minion

找到master,将ip改成服务端地址

备注:冒号和ip地址间一定要有一个空格

找到id,将名称做个标识

4)启动minion

/etc/init.d/salt-minion start

 

三、配置认证

1)在master上执行salt-key

根据上图在Unaccepted Keys中可以看到minion配置的id信息

salt-key -A

允许Unaccepted Keys中所有的minion被信任

salt-key -a 10.10.83.163 ,指定10.10.83.163这台minion被信任

说明:-a :accept ,-A:accept-all,-d:delete,-D:delete-all

再次执行salt-key,可以从下图中看到2台minion被信任。

 

三、命令

目标 模块 返回

1)salt '*' test.ping 检查所有主机状态

salt '10.10.83.163' test.ping 检查10.10.83.163主机状态

2)salt '*' cmd.run 'df -h' 检查所有主机硬盘状态

备注:cmd是一个模块,run是一个方法(做过开发会容易理解)

3)mkdir /srv/{salt,piller}

Pillar是Salt用来分发全局变量到所有minions的一个接口。编写的管理文件需要以sls做后缀

cd /srv/salt/

创建host_files.sls文件,内容如下

 

统计files目录下创建123.txt,内容127.0.0.1 localhost

执行 salt '*' state.sls host_files

查看10.10.83.162和10.10.83.163两台主机下/etc/hosts已变更为123.txt中内容。

4)salt-cp '*' /etc/hosts /etc/

复制一个本地文件的拷贝到所有匹配的Salt Minion中给定的目标。

 

模块名

描述

aliases

管理aliases file信息

alternatives

salt.modules.alternatives

apache

管理apace模块

apt

APT(Advanced Packaging Tool)支持

archive

压缩(archive)支持

at

at支持

augeas_cfg

通过augeas管理配置文件

bluez

管理Bluetooth(使用Bluez)

brew

Mac OS X的Homebrew支持

butterkvm

指定butter云组件路由

cassandra

Cassandra NoSQL数据库模块

cmdmod

A module for shelling out

config

返回配置信息

cp

minion端salt-cp支持

cron

cron支持

daemontools

daemontools服务模块

data

管理minion本地持久化的数据结构

debconfmod

Debconf支持

debian_service

Debian系列系统服务支持

disk

管理磁盘信息

djangomod

管理django站点

dnsmasq

管理dnqmasq模块

dnsutil

dns通用管理工具

dpkg

用于支持DEB 分发版本的包管理

ebuild

另外一个包管理

eix

eix 支持

event

Fire events on the minion, events can be fired up to the master

extfs

管理ex2/3/4文件系统]]

file

管理minion的文件信息,设置或读取文件属组、权限等

fressbsdjail

管理FreeBSD jail环境

freebsdmod

管理FreeBSD 内核

freebsdpkg

FreeBSD package管理支持

freebsdservice

管理FreeBSD服务

freebsd_sysctl

FreeBSD sysctl管理支持

gem

管理ruby gem

gentoolkitmod

Gentoolkit支持

gentoo_service

管理gentoo服务

git

git SCM支持

glance

Module for handling openstack glance calls.

grains

grains数据控制

groupadd

管理Linux和OpenBSD组

grub_legacy

GRUB Legacy支持

guestfs

通过libguestfs管理虚拟机镜像

hg

Mercurial SCM支持

hosts

管理hosts文件

img

虚拟机镜像管理

iptables

iptables支持

keyboard

posix-like系统键盘管理模块

key

minion key信息支持

keystone

openstack keystone调用管理

kmod

Linux内核管理模块

kvm_hyper

Provide the hyper module for kvm hypervisors

launchctl

Mac OSX launchd/launchctl管理支持

layman

Layman支持

ldapmod

ldap管理支持

linux_acl

Linux文件访问控制支持

lvm

Linux LVM2支持

linux_sysctl

Linux sysctl管理支持

locale

posix-like系统locale支持

locate

locate工具管理

logrotate

logrotate管理支持

makeconf

Support for modifying make.conf under Gentoo

mdadm

使用mdadm工具管理RAID arrary

mongodb

mongodb管理支持

monit

monit模块

moosefs

moosefs管理支持

mount

管理UNIX mount及fstab文件

muniu

Run munin plugins/checks from salt and format the output as data

mysql

mysql管理支持

network

收集和管理网络信息

nfs3

NFS3管理模块

nginx

nginx管理

nova

openstack nova调用管理

npm

Manage and query NPM packages

nzbget

nzbget支持

openbsdpkg

OpenBSD包管理

openbsdservice

OpenBSD服务管理

osxdesktop

Mac OS X implementations of various commands in the "desktop" interface

pacman

Arch pacman管理

pam

pam管理

parted

posix-like系统分区管理parted支持

pecl

PHP pecl扩展支持

pillar

minion pillar数据管理

pip

系统python或virtualenv pip管理

pkgng

pkgng支持

pkg_resource

Resources needed by pkg providers

pkgutil

Solaris Pkgutil支持

postgres

Postgres数据库管理支持

poudriere

poudriere支持

ps

A salt interface to psutil, a system and process library

publish

Publish a command from a minion to a target

puppet

puppet管理支持

pw_group

FreeBSD组管理

pw_user

FreeBSD用户管理

qemu_img

qemu镜像命令管理

qemu_nbd

qemu命令管理

quotaposix-like系统quota管理

rabbitmq

rabbitmq管理

reg

Windows注册表管理

ret

Module to integrate with the returner system and retrieve data sent to a salt

rh_ip

RHEL/Fedora网络管理

rh_service

类RHEL服务管理

rpm

rpm支持

rvm

Manage ruby installations and gemsets with RVM, the Ruby Version Manager

s3

Amazon S3支持

saltutil

The Saltutil module is used to manage the state of the salt minion itself

selinux

selinux调用管理

service

服务管理

shadow

管理shadow文件

smf

Solaris 10和11服务管理模块

solaris_group

Solaris组管理

solarispkg

Solaris包管理

solaris_shadow

Solaris shadow文件管理

solaris_user

Solaris用户管理

solr

solr模块支持

sqlite3

SQLite3支持

ssh

管理ssh客户端

state

管理minion state

status

返回minion各种状态

supervisord

Provide the service module for supervisord

svn

Subversion SCM

sysbench

sysbench支持

sysmod

he sys module provides information about the available functions on the minion

systemd

systemd服务管理

system

支持关机、重启等

test

Module for running arbitrary tests

timezone

posix-like系统timezone管理

tls

SSL/TLS模块

tomcat

tomcat支持

upstart

Module for the management of upstart systems

virt

libvirt管理支持

virtualenv

创建python virtualenv环境

win_disk

收集Windows磁盘信息

win_file

管理Windows minion文件信息

win_groupadd

管理Windows组

win_network

管理Windows网络信息

win_pkg

Windows包管理

win_service

Windows服务管理

win_shadow

Windows shadow管理

win_status

返回Windows minion各种信息

win_useradd

Windows用户管理

yumpkg5

YUM支持

yumpkg

YUM支持

zpool

ZFS支持

zypper

OpenSUSE zypper包管理支持

 

部署搭建参考:http://msiyuetian.blog.51cto.com/8637744/1745785

posted @ 2016-05-18 14:06  shhnwangjian  阅读(854)  评论(0编辑  收藏  举报