salt源码安装软件和yum安装软件

salt源码安装软件和yum安装软件

上面简单列出了源码安装的sls文件书写思路.

涉及到一些固定的思路:如,

1,拷贝 解压安装时候需要依赖tar.gz存在

如果已安装则无需再次安装.

2,启动脚本 加入chk时候需要文件存在,如果已添加,则无需再次添加

3,服务管理 除了有启动脚本,还要watch配置文件.

 

晚上睡前早上起来多撸几遍基本的软件安装就可以自己写了.下面是源码安装nginx.涉及到基础依赖包安装(yum安装),以及pcre安装(源码安装)和nginx(源码安装)

其中有些坑,调整了老半天才搞好,甚是蛋疼,要注意图中的两点注意事项.

 

目录结构

[root@linux-node1 salt]# tree prod/

prod/

└── files

├── init.d.php-fpm

├── php-5.6.9.tar.gz

├── php-fpm.conf.default

└── php.ini-production

业务模块:

 

nginx.install

include:

– init.install

– pcre.install

 

nginx-source-install:

file.managed:

– name: /usr/local/src/nginx-1.9.1.tar.gz

– source: salt://nginx/files/nginx-1.9.1.tar.gz

– user: root

– group: root

除了配置文件644,其余的安装包和启动脚本, cmd.run:

– name: cd /usr/local/src && tar zxf nginx-1.9.1.tar.gz && cd nginx-1.9.1 && ./configure –prefix=/usr/local/nginx –user=www –group=www –with-http_ssl_module –with-http_stub_status_module –with-file-aio –with-http_dav_module –with-pcre=/usr/local/src/pcre-8.37 && make && make install

– unless: test -d /usr/local/nginx

– require:

– file: nginx-source-install

– pkg: pkg-init

– cmd: pcre-source-install

nginx-init:

file.managed:

– name: /etc/init.d/nginx

– source: salt://nginx/files/nginx-init

这里要写在usergroup前面,不然测了权限改不了 – user: root

– group: root

cmd.run:

– name: chkconfig –add nginx

– unless: chkconfig –list | grep nginx

– require:

– file: nginx-init

 

/usr/local/nginx/conf/nginx.conf:

file.managed:

– source: salt://nginx/files/nginx.conf

– user: root

– group: root

– mode: 644

 

nginx-service:

file.directory:

– name: /usr/local/nginx/conf/vhost

– require:

– cmd: nginx-source-install

service.running:

– name: nginx

– enable: True

– reload: True

– require:

– cmd: nginx-init

– watch:

– file: /usr/local/nginx/conf/nginx.conf

 

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2016年10月26日
下一篇 2016年10月26日

相关推荐