saltstack 远程安装配置httpd,keepalive,nginx

来源:互联网 发布:centos下载教程 编辑:程序博客网 时间:2024/06/05 04:43

//安装:httpd

 

apache-install:

  pkg.installed:

    - pkgs:

      - httpd

      - php

 

/etc/httpd/conf/httpd.conf:

  file.managed:

    - source: salt://httpd/files/httpd.conf

    - template: jinja

    - context:

      ip: {{grains['ipv4'][0]}}

      prot: 80

 

apache-service:

  service.running:

    - name: httpd

    - enable: true

    - watch:

      - file: /etc/httpd/conf/httpd.conf

    - require:

      - pkg: apache-install

 

 

 

//安装:keepalived

include:

  - pkg.install

 

 

/mnt/keepalived-1.3.5.tar.gz:

  file.managed:

    - source: salt://keepalived/files/keepalived-1.3.5.tar.gz

 

keepalived-install:

  cmd.run:

    - name: cd /mnt && tar zxf keepalived-1.3.5.tar.gz && cd keepalived-1.3.5 &&./configure --prefix=/usr/local/keepalived/ --disable-fwmark --with-init=SYSV && make && make install

    - creates: /usr/local/keepalived/

    - require:

      - file: /mnt/keepalived-1.3.5.tar.gz

      - pkg: make

 

/etc/keepalived:

  file.directory:

    - mode: 755

 

/sbin/keepalived:

  file.symlink:

    - target: /usr/local/keepalived/sbin/keepalived

 

/etc/init.d/keepalived:

  file.managed:

    - source: salt://keepalived/files/keepalived.init

    - mode: 755

 

/etc/sysconfig/keepalived:

  file.managed:

- source: salt://keepalived/files/keepalived.sys

 

 

//安装Nginx

include:

  - pkg.install

  

nginx:

  group.present:

    - gid: 888

 

nginx-user:

  user.present:

    - name: nginx

    - shell: /sbin/nologin

    - uid: 888

    - gid: 888

    - home: /usr/local/nginx

    - createhome: False

 

nginx-source:

  file.managed:

    - name: /mnt/nginx-1.12.0.tar.gz

    - source: salt://nginx/files/nginx-1.12.0.tar.gz

    - user: nginx

    - group: nginx

    - mode: 666

 

 

nginx-install:

  cmd.run:

    - name: cd /mnt && tar zxf nginx-1.12.0.tar.gz &&  cd nginx-1.12.0 && sed -i.bak 's/CFLAGS="$CFLAGS -g"/#CFLAGS="$CFLAGS -g"/g' auto/cc/gcc && ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module && make && make install

    - creates: /usr/local/nginx

    - require:

      - user: nginx-user

      - pkg: make

      - file: nginx-source

 

nginx-config:

  file.managed:

    - name: /usr/local/nginx/conf/nginx.conf

    - source: salt://nginx/files/nginx.conf

 

/etc/init.d/nginx:

  file.managed:

    - source: salt://nginx/files/nginx

 

nginx-service:

  service.running:

    - name: nginx

    - enable: True

    - reload: True

    - require:

      - cmd: nginx-install

      - file: /etc/init.d/nginx

    - watch:

      - file: nginx-config




Pkg 文件:

make:

  pkg.installed:

    - pkg:

      - gcc

      - openssl-devel

      - pcre-devel




原创粉丝点击