首页 > 代码库 > saltstack-memcached的安装

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的安装