SaltStack 之 在从机上安装nginx软件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SaltStack 之 在从机上安装nginx软件相关的知识,希望对你有一定的参考价值。

SaltStack 之 在从机上安装nginx软件

一、在salt目录下创建参数文件

[[email protected] salt]# vi install_nginx.sls
nginx-install:                      #文件标识
     pkg.installed:                  #pak:模块     installed:方法
         - names:                       #names:所需安装的软件,在下面可列多个
             - nginx                        #安装的软件名
     service.running:             #service:模块      running:方法     #用于服务启动
         - names:                      #names:所需安装的软件,在下面可列多个
             - nginx                       #要启动的软件名可多个

二、在master主机上为BackupServer安装nginx

[[email protected] salt]# salt ‘BackupServer‘ state.sls install_nginx
BackupServer:
                    ID: nginx-install
        Function: pkg.installed
                Name: nginx
            Result: True
         Comment: The following packages were installed/updated: nginx
         Started: 20:47:29.068431
        Duration: 20994.535 ms
         Changes:   
                            ----------
                            GeoIP:
                                    ----------
                                    new:
                                            1.6.5-1.el6
                                    old:
                            GeoIP-GeoLite-data:
                                    ----------
                                    new:
                                            2018.04-1.el6
                                    old:
                            GeoIP-GeoLite-data-extra:
                                    ----------
                                    new:
                                            2018.04-1.el6
                                    old:
                            gd:
                                    ----------
                                    new:
                                            2.0.35-11.el6
                                    old:
                            geoipupdate:
                                    ----------
                                    new:
                                            2.2.1-2.el6
                                    old:
                            libXpm:
                                    ----------
                                    new:
                                            3.5.10-2.el6
                                    old:
                            nginx:
                                    ----------
                                    new:
                                            1.10.2-1.el6
                                    old:
                            nginx-all-modules:
                                    ----------
                                    new:
                                            1.10.2-1.el6
                                    old:
                            nginx-filesystem:
                                    ----------
                                    new:
                                            1.10.2-1.el6
                                    old:
                            nginx-mod-http-geoip:
                                    ----------
                                    new:
                                            1.10.2-1.el6
                                    old:
                            nginx-mod-http-image-filter:
                                    ----------
                                    new:
                                            1.10.2-1.el6
                                    old:
                            nginx-mod-http-perl:
                                    ----------
                                    new:
                                            1.10.2-1.el6
                                    old:
                            nginx-mod-http-xslt-filter:
                                    ----------
                                    new:
                                            1.10.2-1.el6
                                    old:
                            nginx-mod-mail:
                                    ----------
                                    new:
                                            1.10.2-1.el6
                                    old:
                            nginx-mod-stream:
                                    ----------
                                    new:
                                            1.10.2-1.el6
                                    old:
----------
                    ID: nginx-install
        Function: service.running
                Name: nginx
            Result: True
         Comment: Started Service nginx
         Started: 20:47:50.065061
        Duration: 240.281 ms
         Changes:   
                            ----------
                            nginx:
                                    True

Summary
------------
Succeeded: 2 (changed=2)
Failed:    0
------------
Total states run:     2

三、查看BackupServer 是否安装了nginx,并启动成功

[[email protected] salt]# curl -I BackupServer
HTTP/1.1 200 OK

以上是关于SaltStack 之 在从机上安装nginx软件的主要内容,如果未能解决你的问题,请参考以下文章

SaltStack之salt-ssh

SaltStack入门

运维工具之saltstack

SaltStack之编译安装LNMP环境

SaltStack之salt-ssh

SaltStack之salt-ssh