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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值