码迷,mamicode.com
首页 > 系统相关 > 详细

saltstack-memcached的安装

时间:2017-03-01 14:55:19      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:saltstack   memcached   脚步安装   

{% set memory = salt[‘pillar.get‘](‘initialization:memory‘,‘128‘) %}

{% set port = salt[‘pillar.get‘](‘initialization:port‘, ‘11211‘) %}

{% set maxconnect = salt[‘pillar.get‘](‘initialization:maxconnect‘, ‘1024‘) %}


groupadd: 

  group.present:  

     - name: memcached

     - gid: 1000


useradd:

  user.present:

    - name: memcached

    - fullname: memcached

    - shell: /sbin/nologin

    - uid: 1000

    - gid: 1000


memcached-datadir:

  cmd.run:

    - names:

       - mkdir -p /usr/local/memcached

    - unless: test -d /usr/local/memcached


libevent-datadir:

  cmd.run:

    - names:

       - mkdir -p /usr/local/libevent

    - unless: test -d /usr/local/libevent


libevent-source-install:

  file.managed:

    - name: /usr/local/src/libevent-2.0.22-stable.tar.gz

    - source: salt://memcached/files/libevent-2.0.22-stable.tar.gz

    - user: root

    - group: root

    - mode: 644

  cmd.run:

    - name: cd /usr/local/src && tar -zvxf libevent-2.0.22-stable.tar.gz  && cd libevent-2.0.22-stable && ./configure --prefix=/usr/local/libevent && make && make install


memcached-source-install:

  file.managed:

    - name: /usr/local/src/memcached-1.4.34.tar.gz

    - source: salt://memcached/files/memcached-1.4.34.tar.gz

    - user: root

    - group: root

    - mode: 644

  cmd.run:

    - name: cd /usr/local/src && tar -zvxf memcached-1.4.34.tar.gz && cd memcached-1.4.34 && ./configure --prefix=/usr/local/memcached --enable-64bit --with-libevent=/usr/local/libevent && make && make install


memcached-service:

  cmd.run:

    - name: /usr/local/memcached/bin/memcached -d -m {{ memory }} -p {{ port }} -c {{ maxconnect }} -u memcached

    - unless: netstat -lnpt |grep {{ port }}

    - require:

     - cmd: memcached-source-install

     - user: memcached


执行命令示例:salt ‘192.168.1.1‘ state.sls memcached.memcached-install saltenv="yeronghai-memcached"  pillar=‘{initialization:{"memory":"1024","port":"11200","maxconnect":"1024"}}‘

memcached.memcached-install:sls执行的文件
saltenv="yeronghai-memcached" : 分支名称
pillar=‘{initialization:{"memory":"1024","port":"11200","maxconnect":"1024"}}‘:自定义的

本文出自 “9383764” 博客,转载请与作者联系!

saltstack-memcached的安装

标签:saltstack   memcached   脚步安装   

原文地址:http://9393764.blog.51cto.com/9383764/1902220

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