Use Saltstack to build a lamp server

Source: Internet
Author: User
Tags saltstack

Deploying the lamp architecture with Saltstack

Steps:

(1) Install package pkg

(2) Modify the profile file

(3) Start service services

(1) PKG Module learning
Https://www.unixhot.com/docs/saltstack/ref/states/all/salt.states.pkg.html#module-salt.states.pkg

Note: Under an ID declaration, the status module cannot be reused

Pkg.installed #安装pkg. Latest #确保最新版本pkg. Remove #卸载pkg. Purge #卸载并删除配置文件 # Install multiple packages at the same time common_packages:pkg.installed: -pkgs:-Unzip-dos2unix-salt-minion:2015.8.5-1.el6
(2) File module
Official Address Https://www.unixhot.com/docs/saltstack/ref/states/all/salt.states.file.html#module-salt.states.file
/etc/http/conf/http.conf:file.managed:-Source:salt://apache/http.conf-user:root-group:root-mode: 644-template:jinja-defaults:custom_var: "Default value" other_var:123{% if grains[' os ' = = ' Ubu NTU '%}-Context:custom_var: "override" {% endif%}
(3) Services Module service
Official website Https://www.unixhot.com/docs/saltstack/ref/states/all/salt.states.service.html#module-salt.states.service
Redis:service.running:-Enable:true-reload:true-watch:-Pkg:redis
(4) Writing SLS file for installing lamp architecture
lamp-pkg:  pkg.installed:    - pkgs:      -  httpd      - php      - mariadb       - mariadb-server      - php-mysql       - php-cli      -  php-mbstringapache-config:  file.managed:    - name: /etc/httpd/conf/ httpd.conf    - source: salt://lamp/files/httpd.conf    -  user: root    - group: root    - mode:  644php-config:  file.managed:    - name: /etc/php.ini     - source: salt://lamp/files/php.ini    - user: root     - group: root    - mode: 644mysql-config:  file.managed:    -  name: /etc/my.cnf    - source: salt://lamp/files/my.cnf     - user: root    - group: root    -  mode: 644apache-service:  service.running:    - name: httpd     - enable: true    - reload: truemysql-service:   service.running:    - name: mariadb    -  Enable: true    - reload: true Note that:   salt://  is the root directory of the current environment, View the current environment as a base environment or PROD environment: vi /etc/salt/masterfile_roots:  base:    - /srv/ Salt so salt://lamp/files/httpd.conf is equivalent to/srv/salt/lamp/files/httpd.conf

Create a Directory

Mkdir/srv/salt/lampcd/srv/salt/lamp/vi Lamp.sls Copy the SLS content written above into the Lamp.sls file

After you finish writing the SLS file, you need to copy the configuration file to Salt://files

Creating the Files directory Mkdir/srv/salt/lamp/filescd/srv/salt/lamp/filescp/etc/httpd/conf/httpd.conf/srv/salt/lamp/filescp/etc /php.ini/srv/salt/lamp/filescp/etc/my.cnf/srv/salt/lamp/files Note: httpd.conf, php.ini, My.cnf these three files were first installed on a single host after the software was obtained, not from other places copy
(5) Installing lamp
Execute a single state file on Linux-node2: Salt ' linux-node2* ' State.sls lamp.lamp Note: It's easy to get into a circle here, the first lamp is the catalog, the second lamp is the SLS file we wrote

After the completion of the implementation of the error, it is completed the lamp architecture installation.

How to use Saltstack one-button installation lamp very cool!

This article is from "Jacky Xin" blog, please be sure to keep this source http://jackyxin.blog.51cto.com/1976631/1836306

Use Saltstack to build a lamp server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.