lamp自动部署工具_salt实现lamp自动化部署
三個文件夾:
pkg 安裝軟件包
file ?管理配置文件
service ? 服務管理
思路: lamp需要安裝的軟件包有 ?httpd, php, mysql, mysql-server, php-mysql, php-pdo
cd ?/srv/salt/dev/
mkdir ? /srv/salt/dev/files/ ? ? ?##放配置文件
vim ?/srv/salt/dev/lamp.sls
lamp配置文件如下:
lamp-pkg-install:
pkg.installed:
- names:
- php
- mysql
- php-cli
- php-common
- php-mysql
- php-pdo
apache-service:
pkg.installed:
- name: httpd
file.managed:
- name: /etc/httpd/conf/httpd.conf
- source: salt://files/httpd.conf
- user: root
- group: root
- mode: 644
- require:
- pkg: apache-service
service.running:
- name: httpd
- enable: True
- reload: True
- watch:
- file: apache-service
mysql-service:
pkg.installed:
- name: mysql-server
- require_in:
- file: mysql-service
file.managed:
- name: /etc/my.cnf
- source: salt://files/my.cnf
- user: root
- group: root
- mode: 644
- watch_in:
- service: mysql-service
service.running:
- name: mysqld
- enable: True
vim ?/srv/salt/top.sls
dev:
'web2.coohx.com':
- lamp
執行:
salt 'web2*' state.highstate
[root@web1 salt]# salt 'web2*' state.highstate
web2.coohx.com:
....
...
----------
ID: apache-service
Function: file.managed
Name: /etc/httpd/conf/httpd.conf
Result: True
Comment: File /etc/httpd/conf/httpd.conf updated
Started: 19:22:16.063742
Duration: 56.123 ms
Changes:
----------
diff:
---
+++
@@ -273,7 +273,7 @@
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
#
-#ServerName www.example.com:80
+ServerName www.coohx.com:80
#
# UseCanonicalName: Determines how Apache constructs self-referencing
----------
ID: apache-service
Function: service.running
Name: httpd
Result: True
Comment: Service reloaded
Started: 19:22:16.189186
Duration: 267.497 ms
Changes:
----------
httpd:
True
----------
ID: mysql-service
Function: pkg.installed
Name: mysql-server
Result: True
Comment: Package mysql-server is already installed.
Started: 19:22:16.457774
Duration: 4.411 ms
Changes:
----------
ID: mysql-service
Function: file.managed
Name: /etc/my.cnf
Result: True
Comment: File /etc/my.cnf updated
Started: 19:22:16.463750
Duration: 25.095 ms
Changes:
----------
diff:
---
+++
@@ -13,6 +13,8 @@
# If you want to know which options a program supports, run the program
# with the "--help" option.
+#web2.coohx.com
+
# The following options will be passed to all MySQL clients
[client]
#password ? ?= your_password
@@ -24,7 +26,7 @@
# The MySQL server
[mysqld]
port ? ? ? ? = 3306
-socket ? ? ? ? ? ? ? = /var/lib/mysql/mysql.sock
+socket ? ? ? ? ? ? ? = /tmp/mysql.sock
character_set_server = utf8
skip-locking
key_buffer_size = 256M
----------
ID: mysql-service
Function: service.running
Name: mysqld
Result: False
Comment: Failed to restart the service
Started: 19:22:16.548901
Duration: 2260.008 ms
Changes:
----------
mysqld:
False
Summary
-------------
Succeeded: 11 (changed=4)
Failed: ? ? 1
-------------
Total states run: ? ? 12
本文轉自鐵騎傳說51CTO博客,原文鏈接:?http://blog.51cto.com/ybzbfs/1954937,如需轉載請自行聯系原作者
總結
以上是生活随笔為你收集整理的lamp自动部署工具_salt实现lamp自动化部署的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: aosp 为什么某些目录没有编译_编译A
- 下一篇: rust腐蚀几人组队_直播圈近几年爆火的