标签:raw dns chm file open pat /dev/null alt nbsp
根据官方文档的安装说明,安装相关依赖包:
Salt可以运行在类Unix平台,安装时需要解决如下依赖:
msgpack-python - 高性能的消息交换格式
Jinja2 - 解析Salt States (在master配置文件中配置)
apache-libcloud - 与大量的主流云服务提供者进行交互时统一API的Python类
Depending on the chosen Salt transport, ZeroMQ or RAET, dependencies vary:
本文使用的操作系统为:
默认的 python 版本为:
https://pypi.python.org/pypi/msgpack-python/
msgpack-python-0.4.8.tar.gz
# tar zxvf msgpack-python-0.4.8.tar.gz # cd msgpack-python-0.4.8 # python setup.py install
http://pyyaml.org/
yaml-0.1.7.tar.gz
PyYAML-3.12.tar.gz
# tar zxvf yaml-0.1.7.tar.gz # cd yaml-0.1.7 # ./configure # make # make install
PyYAML 3.12
需要先安装相关依赖:
# yum install gcc libffi-devel python-devel openssl-devel
安装:
# tar zxvf PyYAML-3.12.tar.gz # cd PyYAML-3.12 # python setup.py --with-libyaml install
https://pypi.python.org/pypi/MarkupSafe
MarkupSafe-1.0.tar.gz
# tar zxvf MarkupSafe-1.0.tar.gz # cd MarkupSafe-1.0 # python setup.py install
https://pypi.python.org/pypi/Jinja2
# tar zxvf Jinja2-2.9.5.tar.gz # cd Jinja2-2.9.5 # python setup.py install
http://libcloud.apache.org/downloads.html
apache-libcloud-1.5.0.tar.gz
# tar zxvf apache-libcloud-1.5.0.tar.gz # cd apache-libcloud-1.5.0 # python setup.py install
http://docs.python-requests.org/en/latest/user/install/#install
kennethreitz-requests-v2.13.0-90-g993cbf5.tar.gz
# tar zxvf kennethreitz-requests-v2.13.0-90-g993cbf5.tar.gz # cd kennethreitz-requests-993cbf5 # python setup.py install
https://pypi.python.org/simple/backports-abc/
backports_abc-0.5.tar.gz
# tar zxvf backports_abc-0.5.tar.gz # cd backports_abc-0.5 # python setup.py install
https://pypi.python.org/simple/certifi/
certifi-1.0.0.tar.gz
# tar zxvf certifi-1.0.0.tar.gz # cd certifi-1.0.0 # python setup.py install
https://pypi.python.org/simple/singledispatch/
singledispatch-3.4.0.2.tar.gz
# tar zxvf singledispatch-3.4.0.2.tar.gz # cd singledispatch-3.4.0.2 # python setup.py install
https://pypi.python.org/pypi/tornado/4.4.2
tornado-4.4.2.tar.gz
# tar zxvf tornado-4.4.2.tar.gz # cd tornado-4.4.2 # python setup.py install
https://github.com/agronholm/pythonfutures
pythonfutures-master.zip
# unzip pythonfutures-master.zip # cd pythonfutures-master # python setup.py install
http://zeromq.org/intro:get-the-software
zeromq-4.2.1.tar.gz
# tar zxvf zeromq-4.2.1.tar.gz # cd zeromq-4.2.1 # ./configure # make # make install
https://pypi.python.org/pypi/Cython/
Cython-0.25.2.tar.gz
# tar zxvf Cython-0.25.2.tar.gz # cd Cython-0.25.2 # python setup.py install
https://github.com/zeromq/pyzmq
pyzmq-master.zip
# unzip pyzmq-master.zip # cd pyzmq-master # python setup.py install
https://www.dlitz.net/software/pycrypto/
pycrypto-2.6.1.tar.gz
# tar zxvf pycrypto-2.6.1.tar.gz # cd pycrypto-2.6.1 # python setup.py install
https://github.com/saltstack/salt
https://pypi.python.org/pypi/salt/
salt-develop.zip
# unzip salt-develop.zip # cd salt-develop # python setup.py install
执行以下命令:
# salt --versions-report
返回信息:
# mkdir /etc/salt # cd salt-develop/ # cp -a conf/master /etc/salt/ # cp -a pkg/suse/salt-master /etc/init.d/ # chmod +x /etc/init.d/salt-master # chkconfig --level 235 salt-master on
# vim /etc/salt/master
master 中的内容:
interface: 192.168.6.128 auto_accept: True
# service salt-master start
# netstat -ntlp
# ps aux | grep python
# mkdir /etc/salt # cd salt-develop # cp -a conf/minion /etc/salt/ # cp -a pkg/suse/salt-minion /etc/init.d/ # chmod +x /etc/init.d/salt-minion # chkconfig --level 235 salt-minion on
# vi /etc/salt/minion
minion 文件的内容:
master: 192.168.6.128 id: minion-192-168-6-128
# service salt-minion start
# ps aux | grep python
执行命令:
# salt-key -L
返回信息:
如果在 /etc/salt/master 的配置文件中没有配置自动接收 key,可以使用以下命令:
# salt-key -A
返回信息:
再次查看:
# salt ‘*‘ test.ping
# salt ‘*‘ cmd.run ‘uptime‘
# salt -G ‘os:Centos‘ test.ping
# salt ‘*‘ grains.item os
# salt ‘*‘ cmd.exec_code python ‘import sys; print sys.version‘
实现远程文件、目录的复制,以及下载URL文件等操作。
1)将主服务器 file_roots 指定位置下的目录复制到被控主机
# salt ‘*‘ cp.get_dir salt://hellotest /data
2)将主服务器file_roots指定位置下的文件复制到被控主机
# salt ‘*‘ cp.get_file salt://hellotest/rocketzhang /root/rocketzhang
3)下载指定URL内容到被控主机指定位置
# salt ‘*‘ cp.get_url http://xxx.xyz.com/download/0/files.tgz /root/files.tgz
实现远程的命令行调用执行
# salt ‘*‘ cmd.run ‘netstat -ntlp‘
实现被控主机的crontab操作
1)为指定的被控主机、root用户添加crontab信息
# salt ‘*‘ cron.set_job root ‘*/5‘ ‘*‘ ‘*‘ ‘*‘ ‘*‘ ‘date >/dev/null 2>&1‘
# salt ‘*‘ cron.raw_cron root
2)删除指定的被控主机、root用户的crontab信息
# salt ‘*‘ cron.rm_job root ‘date >/dev/null 2>&1‘
# salt ‘*‘ cron.raw_cron root
实现被控主机通用DNS操作
为被控主机添加指定的hosts主机配置项
# salt ‘*‘ dnsutil.hosts_append /etc/hosts 127.0.0.1 rocketzhang.qq.com
被控主机文件常见操作,包括文件读写、权限、查找、校验等
# salt ‘*‘ file.get_sum /etc/resolv.conf md5
# salt ‘*‘ file.stats /etc/resolv.conf
返回被控主机网络信息
# salt ‘*‘ network.ip_addrs
# salt ‘*‘ network.interfaces
被控主机程序包管理,如 yum、apt-get 等
# salt ‘*‘ pkg.install nmap
# salt ‘*‘ pkg.file_list nmap
被控主机程序包服务管理
# salt ‘*‘ service.enable crond
# salt ‘*‘ service.disable crond
# salt ‘*‘ service.status crond
# salt ‘*‘ service.stop crond
# salt ‘*‘ service.start crond
# salt ‘*‘ service.restart crond
# salt ‘*‘ service.reload crond
如:grains、pillar、states、modules、returner、runners、reactor等,以及模板配置的渲染、扩展模块的二次开发等。
标签:raw dns chm file open pat /dev/null alt nbsp
原文地址:http://www.cnblogs.com/RUReady/p/6641104.html