码迷,mamicode.com
首页 > 其他好文 > 详细

saltstack 安装部署及ntp服务批量部署过程实例

时间:2015-11-12 18:21:15      阅读:454      评论:0      收藏:0      [点我收藏+]

标签:安装   部署   批量安装   ntp服务   saltstack   

服务端安装salt-master 

yum install salt-master -y


客户端安装salt-minion

 yum install salt-minion -y


启动服务:

服务端启动方式:

/etc/init.d/salt-master start


客户端启动方式:

/etc/init.d/salt-minion start

master端 配置文件:

cat /etc/salt/master | egrep -v ‘^#|^$‘
worker_threads: 60
cachedir: /data1/var/cache/salt/master
timeout: 30
open_mode: True
auto_accept: True
autosign_timeout: 0
modules:
  - cmd
runner_dirs: []
file_roots:
  base:
    - /srv/salt/
  dev:
    - /srv/salt/dev/services
    - /srv/salt/dev/states
  prod:
    - /srv/salt/prod/services
    - /srv/salt/prod/states
pillar_roots:
  base:
    - /srv/pillar
log_level: info
log_level_logfile: info

minion端配置文件:

cat /etc/salt/minion | egrep -v ‘^#|^$‘
master: 10.77.23.34
id: 10.77.23.24
cachedir: /data1/var/cache/salt/minion
random_reauth_delay: 600
auth_timeout: 160
auth_tries: 5
recon_default: 6000
recon_max: 590000
recon_randomize: True

每个参数的意义就不多说了,需要了解的可以去查

测试一下master与minion端的通信状态是否正常:

salt-key  -L | grep ‘10.77.23.24‘
10.77.23.24
salt ‘10.77.23.24‘ test.ping
10.77.23.24:
    True

master端目录说明:

tree /srv/salt/ ##master base目录
/srv/salt/
├── dev
├── ntp #ntp服务目录
│   ├── conf #ntp服务各种配置文件存放目录
│   │   ├── ntp.conf
│   │   ├── ntpd
│   │   └── step-tickers
│   └── init.sls #ntp服务安装的state文件
└── top.sls #入口文件
3 directories, 5 files
cat top.sls 
base:
 ‘*‘:
  - ntp.init 
  
cat init.sls 
#Name ntpd install
ntpd: ##检查ntp是否处于安装状态,如果未安装,则安装
  pkg:
    - name: ntp
    - installed
  service:
    - running
    - require: #在启动ntp服务之前必须确保ntp服务已经安装成功
      - pkg: ntpd
    - watch: #监控/etc/ntp.conf文件,如果有变动,则重启ntp服务
      - file: /etc/ntp.conf
/etc/ntp.conf: ##客户端文件路径及名称
  file.managed: #文件管理
    - source: salt://ntp/conf/ntp.conf ##同步文件源为master上的文件及路径
    - user: root #所属用户
    - group: root #所属用户组
    - mode: 644   #权限设置
/etc/ntp/step-tickers:
  file.managed:
    - source: salt://ntp/conf/step-tickers
    - user: root
    - group: root
    - mode: 644
/etc/ntp/ntpd:
  file.managed:
    - source: salt://ntp/conf/ntpd
    - user: root
    - group: root
    - mode: 644

以上都ok之后,在master端执行命令:

salt ‘10.77.23.24‘ state.highstate

就会看到安装过程,如

10.77.23.24:
----------
          ID: ntpd
    Function: pkg.installed
        Name: ntp
      Result: True
     Comment: Package ntp is already installed.
     Started: 16:25:15.084590
    Duration: 670.173 ms
     Changes:   
----------
          ID: /etc/ntp.conf
    Function: file.managed
      Result: True
     Comment: File /etc/ntp.conf updated
     Started: 16:25:15.759416
    Duration: 13.097 ms
     Changes:   
              ----------
              diff:
                 ##这里会显示同步之后和之前的配置文件区别
----------
          ID: ntpd
    Function: service.running
      Result: True
     Comment: Started Service ntpd
     Started: 16:25:15.772810
    Duration: 127.218 ms
     Changes:   
              ----------
              ntpd:
                  True
----------
          ID: /etc/ntp/step-tickers
    Function: file.managed
      Result: True
     Comment: File /etc/ntp/step-tickers updated
     Started: 16:25:15.900406
    Duration: 15.072 ms
     Changes:   
              ----------
----------
          ID: /etc/ntp/ntpd
    Function: file.managed
      Result: True
     Comment: File /etc/ntp/ntpd updated
     Started: 16:25:15.915669
    Duration: 11.367 ms
     Changes:   
              ----------
              diff:
                  New file
              mode:
                  0644

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


本文出自 “python散记” 博客,请务必保留此出处http://6252961.blog.51cto.com/6242961/1712238

saltstack 安装部署及ntp服务批量部署过程实例

标签:安装   部署   批量安装   ntp服务   saltstack   

原文地址:http://6252961.blog.51cto.com/6242961/1712238

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!