salt搭建lamp架构

install_httpd:
  pkg.installed:
    - name: httpd


httpd_running:
  service.running:
    - name: httpd
    - enable: True
    - require:
      - pkg: install_httpd
    - watch:
      - file: httpd_conf
      - file: php_conf

httpd_conf:
  file.managed:
    - name: /etc/httpd/conf/httpd.conf
    - source: salt://httpd.conf
    - user: root
    - group: root
    - mode: 600

install_php:
  pkg.installed:
    - name: php_all
    - pkgs:
      - php
      - php-mysql
      - php-common
      - php-gd
      - php-mbstring
      - php-mcrypt
      - php-devel
      - php-xml
    - require:
      - pkg: install_httpd


php_conf:
  file.managed:
    - name: /etc/php.ini
    - source: salt://php.ini
    - user: root
    - group: root
    - mode: 600

install_mysql:
  pkg.installed:
    - name: mysql
    - pkgs:
      - mariadb
      - mariadb-server
      - mariadb-devel

mysql_running:
  service.running:
    - name: mysqld

mysql_conf:
  file.managed:
    - name: /etc/my.cnf
    - source: salt://my.cnf
    - user: root
    - group: root
    - mode: 600

discuz_distribute:
  file.managed:
    - name: /var/www/html/Discuz.zip
    - source: salt://Discuz.zip
unzip_discuz:
  cmd.run:
    - name: unzip /var/www/html/Discuz.zip

 源码安装haproxy示例:

haproxy-install:
file.managed:
- name: /usr/local/src/haproxy-1.5.3.tar.gz
- source: salt://haproxy/files/haproxy-1.5.3.tar.gz
- mode: 755
- user: root
- group: root
cmd.run:
- name: cd /usr/local/src && tar zxf haproxy-1.5.3.tar.gz && cd haproxy-1.5.3 && make TARGET=linux26 PREFIX=/usr/local/haproxy && make install PREFIX=/usr/local/haproxy
- unless: test -d /usr/local/haproxy
- require:
- file: haproxy-install

/etc/init.d/haproxy:
file.managed:
- source: salt://haproxy/files/haproxy.init
- mode: 755
- user: root
- group: root
- require:
- cmd: haproxy-install

net.ipv4.ip_nonlocal_bind:
sysctl.present:
- value: 1

haproxy-config-dir:
file.directory:
- name: /etc/haproxy
- mode: 755
- user: root
- group: root

haproxy-init:
cmd.run:
- name: chkconfig --add haproxy
- unless: chkconfig --list | grep haproxy
- require:
- file: /etc/init.d/haproxy

 

posted @ 2017-02-04 17:20  梦轻尘  阅读(329)  评论(0编辑  收藏  举报