saltstack安装redis

top.sls

[root@node110 states]# ls
init  jdk  php  prod  redis  tomcat  top.sls
[root@node110 states]# pwd
/etc/salt/states

[root@node110 states]# cat top.sls
base:
  '*':
    - redis.install
    - redis.config
    - redis.service


install.sls

[root@node110 redis]# pwd
/etc/salt/states/redis
[root@node110 redis]# ls
config.sls  files  install.sls  install.sls.bak  service.sls

[root@node110 redis]# ls
config.sls  files  install.sls  install.sls.bak  service.sls
[root@node110 redis]# cat install.sls
redis-install:
  file.managed:
    - name: /usr/local/src/redis-3.2.6.tar.gz
    - source: salt://redis/files/redis-3.2.6.tar.gz
    - user: root
    - group: root
    - mode: 755
  cmd.run:
    - name: cd /usr/local/src && tar zxf redis-3.2.6.tar.gz && cd redis-3.2.6 && make PREFIX=/usr/local/redis326 install
    - unless: test -d /usr/local/redis326
    - require:
      - file: redis-install


config.sls

[root@node110 redis]# pwd
/etc/salt/states/redis
[root@node110 redis]# ls
config.sls  files  install.sls  install.sls.bak  service.sls

[root@node110 redis]# ls
config.sls  files  install.sls  install.sls.bak  service.sls
[root@node110 redis]# cat config.sls
redis-config:
  file.managed:
    - name: /etc/redis326/6379.conf
    - source: salt://redis/files/6379.conf
    - user: root
    - group: root
    - mode: 644
    - unless: test f /etc/redis326/6379.conf

service.sls

[root@node110 redis]# pwd
/etc/salt/states/redis
[root@node110 redis]# ls
config.sls  files  install.sls  install.sls.bak  service.sls

[root@node110 redis]# ls
config.sls  files  install.sls  install.sls.bak  service.sls
[root@node110 redis]# cat service.sls
salt-service:
  file.managed:
    - name: /etc/init.d/redis
    - source: salt://redis/files/redis_init_script
    - user: root
    - group: root
    - mode: 755
  cmd.run:
    - name: chkconfig  redis on
    - unless: chkconfig --list| grep redis
  service.running:
    - name: redis
    - enable: True


分割线
感谢打赏
江西数库信息技术有限公司
YWSOS.COM 平台代运维解决方案
 评论
 发表评论
姓   名:

Powered by AKCMS