因为在学习salt-gitfs过程中。需要安装salt-api。这里面好多坑,其实步骤很简单的!
把这个过程记录一下。
系统环境:centos6.5x86_64
python 2.6+
一、安装salt和依赖
cat /etc/redhat-release
安装epel源
yum install epel-release
安装依赖
yum -y install kernel-firmware kernel-headers perf e2fsprogs yum install libyaml yum install PyYAML
yum install salt-master salt-api
二、安装pip
在安装pip前,先安装setuptools
否则会报错:
Traceback (most recent call last):
File "setup.py", line 6, in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools
安装setuptools
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-12.0.3.tar.gz#md5=f07e4b0f4c1c9368fcd980d888b29a65
cd setuptools-12.3
python setup.py install
接下来可以安装pip了。
wget https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz#md5=01026f87978932060cc86c1dc527903e --no-check-certificate
tar -zxvf pip-* cd pip- python setup.py build && python setup.py install && pip freeze
#使用pip安装cherrypy: pip install cherrypy==3.2.3
三、配置openssl证书
1、
cd /etc/pki/tls/certs
umask 77 ; \
/usr/bin/openssl genrsa -aes128 2048 > /etc/pki/tls/private/localhost.key
Generating RSA private key, 2048 bit long modulus
........................................+++
...............+++
e is 65537 (0x10001)
Enter pass phrase:(此处输入一个test)
Verifying - Enter pass phrase:(再次确认你输入的)
/usr/bin/openssl req -utf8 -new -key /etc/pki/tls/private/localhost.key 也输入你上次输入那个
后面的提示都是可选择填的。。
此时你的../private/的文件夹中多了个localhost.key
openssl rsa -in localhost.key -out localhost_nopass.key Enter pass phrase for localhost.key:此处输入上次输入那个 writing RSA key 创建一个用户为api访问。但是不能登陆。 useradd -M -s /sbin/nologin test 重设密码: passwd test 四、配置salt-api
配置salt-master 修改/etc/salt/master
将default_include:选项去掉注释
mkdir -p /etc/salt/master.d
cd /etc/salt/master.d
vim api.conf
rest_cherrypy: port: 8000 ssl_crt: /etc/pki/tls/certs/localhost.crt ssl_key: /etc/pki/tls/private/localhost_nopass.key
vim eauth.conf
external_auth: pam: test: - .* - '@wheel' - '@runner' 重新启动salt-master和salt-api服务: [root@Gitlab-test ~]# service salt-master restart Stopping salt-master daemon: [FAILED] Starting salt-master daemon: [ OK ] [root@Gitlab-test ~]# service salt-api restart Stopping salt-api daemon: [FAILED] Starting salt-api daemon: [ OK ] 此时可以查看端口: [root@Gitlab-test ~]# netstat -an |grep :8000 tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:46591 127.0.0.1:8000 TIME_WAIT 说明salt-api服务正常启动。。 一般你可以查看/var/log/salt/master 日志去看salt-api的运行情况。
本文出自 “黎明前的黑暗” 博客,谢绝转载!