警告
Halite is deprecated
The Halite project is retired. The code will remain available on GitHub.
在此教程我们将简要介绍Halite的安装和初始化。当前版本的Halite为初期测试版,并只支持“v2014.1.0”及更高版本的Salt。更多的信息请移步GitHub:https://github.com/saltstack/halite
在进行本教程前, 请确保已经安装了salt-master. 想了解如何安装salt-master, 请访问安装文档: http://docs.saltstack.com/topics/installation/index.html
注解
Halite只支持2014.1.0及更高版本的Salt。
在CentOS, RHEL或Fedora中:
$ yum install python-halite
注解
默认python-halite只会安装CherryPy。 如果你想使用其他web框架, 请浏览下面内容,安装pip及你想运行的框架。 该包并不会修改master的配置文件“/etc/salt/master”。
在使用PyPI源安装Halite之前,你需要安装pip。Salt包和bootstrap脚本默认并不会安装pip。
在CentOS, RHEL或Fedora中:
$ yum install python-pip
在Debian上:
$ apt-get install python-pip
如果你已安装pip, 可以使用pip来安装halite:
$ pip install -U halite
你需要安装你想用来运行halite的web框架。 在RHEL系列发行版上, 可以通过如下方式安装:
$ pip install cherrypy
$ pip install paste
$ yum install python-devel
$ yum install gcc
$ pip install gevent
$ pip install pyopenssl
在Debian系列发行版上:
$ pip install CherryPy
$ pip install paste
$ apt-get install gcc
$ apt-get install python-dev
$ apt-get install libevent-dev
$ pip install gevent
$ pip install pyopenssl
配置Halite访问权限非常简单. 默认你只需要配置 @runner. 在 /etc/salt/master
文件中, 取消注释并修改如下内容:
external_auth:
pam:
testuser:
- .*
- '@runner'
注解
你不能在pam登陆中使用root用户; 它会导致认证失败.
Halite使用runner的manage.present函数来获取minions状态,因此需要拥有runner权限,例如:
external_auth:
pam:
mytestuser:
- .*
- '@runner'
- '@wheel'
当前Halite允许但不强制要求wheel模块.
Once you've configured the permissions for Halite, you'll need to set up the Halite settings in the /etc/salt/master file. Halite supports CherryPy, Paste, and Gevent out of the box.
如果想配置cherrypy, 请在/etc/salt/master文件底部增加如下内容:
halite:
level: 'debug'
server: 'cherrypy'
host: '0.0.0.0'
port: '8080'
cors: False
tls: True
certpath: '/etc/pki/tls/certs/localhost.crt'
keypath: '/etc/pki/tls/certs/localhost.key'
pempath: '/etc/pki/tls/certs/localhost.pem'
如果你想使用paste:
halite:
level: 'debug'
server: 'paste'
host: '0.0.0.0'
port: '8080'
cors: False
tls: True
certpath: '/etc/pki/tls/certs/localhost.crt'
keypath: '/etc/pki/tls/certs/localhost.key'
pempath: '/etc/pki/tls/certs/localhost.pem'
使用gevent:
halite:
level: 'debug'
server: 'gevent'
host: '0.0.0.0'
port: '8080'
cors: False
tls: True
certpath: '/etc/pki/tls/certs/localhost.crt'
keypath: '/etc/pki/tls/certs/localhost.key'
pempath: '/etc/pki/tls/certs/localhost.pem'
"cherrypy"及"gevent"框架以tls/ssl方式运行时需要指定证书路径及私钥文件路径。.crt文件是公共证书,,.key文件是私钥。 "paste"中间件需要指定单个.pem文件,,其包含证书和私钥.。可以通过如下方式创建.crt及.key文件。
如果你想使用自签名证书, 可以使用salt的tls模块来创建:
注解
在salt master上需要运行以下命令:
salt-call tls.create_self_signed_cert tls
注意,上述命令创建的证书位于目录“/etc/pki/tls/certs/”。使用自签名证书时,浏览器在接受证书前需要进行批准。如果浏览器已经缓存了该web应用之前的非HTTPS版本,那么需要清空浏览器缓存,以便识别和提示接受这个自签名证书。
Once you've configured the halite section of your /etc/salt/master, you can restart the salt-master service, and your halite instance will be available. Depending on your configuration, the instance will be available either at https://localhost:8080/app, https://domain:8080/app, or https://123.456.789.012:8080/app .
注解
halite需要一个兼容HTML 5的浏览器.
所有halite相关的日志将默认记录在/var/log/salt/master文件中.