Saltstack Remote Installation Apache

Source: Internet
Author: User
Tags saltstack

############################################################
*
* saltstack Remote Installation Apache

############################################################

[Email protected] pillar]# tree/srv/salt/apache/
/srv/salt/apache/
└──apache-install.sls

[Email protected] salt]# mkdir-p/srv/salt/apache/

[Email protected] apache]# Cat/srv/salt/apache/apache-install.sls
Apache-install:
Pkg.installed:

    • Names
      • httpd
        httpd
        Service.running:
    • Enable:true
    • Reload:true

#服务端执行命令
Salt ' WEB0? ' State.sls Apache.apache-install

#服务端配置文件
[Email protected] salt]# Cat/srv/salt/top.sls
Base
‘*‘:

    • Apache.apache-install

#执行高级模块, suitable to detect the start-up program
[email protected] salt]# Salt ' WEB01 ' state.highstate

# # #grains
#查询grains值, grains is suitable for the collection of some static property values
[email protected] salt]# Salt ' LB02 ' grains.items

#通过grains值过滤IP
[email protected] salt]# Salt ' LB02 ' grains.get ip_interfaces:eth0
LB02:

    • 192.168.44.6
    • fe80::20c:29ff:fe3e:ec5b

#-g is the Execute CMD module that calls the grains value, the property value of CentOS, the Run method, the W command
[[email protected] salt]# salt-g os:centos cmd.run ' W '
WEB02:
10:23:25 up 1:46, 1 user, Load average:0.00, 0.00, 0.00
USER TTY from [email protected] IDLE jcpu PCPU
Root pts/1 192.168.44.1 08:37 1:45m 0.00s 0.00s-bash
LB02:
10:23:25 up 1:46, 1 user, Load average:0.00, 0.00, 0.00
USER TTY from [email protected] IDLE jcpu PCPU
Root pts/0 192.168.44.1 08:37 34:28 0.09s 0.09s-bash

Quick service code for #通过grains属性值, check service
[[email protected] salt]# Salt ' LB02 ' grains.get server_id|awk Nr==2|awk ' {print $} '
241255280

# # #pallar
#服务器端配置pillar, for sensitive data, to deal with variable variability
[Email protected] salt]# Vim/etc/salt/master
Pillar_opts:fales
Pillar_roots:
Base

    • /srv/pillar
      [Email protected] salt]#/etc/init.d/salt-master restart
      [Email protected] salt]# mkdir-p/srv/pillar

[Email protected] pillar]# Cat/srv/pillar/apache.sls
{% if grains[' os '] = = ' CentOS '%}
Apache:httpd
{% elif grains[' os '] = = ' Debian '%}
Apache:apache2
{% ENDIF%}
[Email protected] pillar]# Cat/srv/pillar/top.sls
Base
‘*‘:

    • Apache.apache-install

[[email protected] pillar]# Salt ' * ' Pillar.items

#如果取不到客户端数据就salt刷新一下
#报错 minion did not return. [No response], refresh a bit
[[email protected] pillar]# Salt ' * ' saltutil.refresh_pillar

#判断grains的类型os的结果为CentOS
[Email protected] pillar]# salt-i ' apache:httpd ' test.ping
LB02:
True

#windows客户端安装
Https://repo.saltstack.com/windows/Salt-Minion-2018.3.0-Py3-AMD64-Setup.exe
Note: When installing, point to the server address.

#查看win主机的ip, you need to use the commands of Windows itself
[[email protected] pillar]# Salt ' windowshost ' cmd.run ' ipconfig '

#授权user用户有test. Permissions for Ping and network.*
[Email protected] pillar]# Cat/etc/salt/master
Client_acl:
User

    • Test.ping
    • network.*

[Email protected] pillar]# chmod 755/var/cache/salt/var/cache/salt/master/var/cache/salt/master/jobs/var/run/salt /var/run/salt/master

Saltstack Remote Installation Apache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.