Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Configuration Management of SaltStack practice-LAMP Automation deployment

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Configuration Management of SaltStack practice-LAMP Automation deployment

Learning SaltStack

Configuration Management of SaltStack practice-LAMP Automation deployment

1. Deployment idea

two。 Write lamp.sls

1. Deployment idea

Divide lamp into three parts: software packages, configuration files, and services

Confirm the installed package name, configuration file path, service name, etc.

Write the yaml file according to the above information

two。 Write lamp.sls [root @ salt-master112 salt] # pwd

/ srv/salt

[root@salt-master112 salt] # ls

Dev init prod test top.sls

[root@salt-master112 salt] # cat dev/lamp.sls

Lamp-pkg-install:

Pkg.installed:

-names:

-httpd

-php

-php-fpm

-mysql

-mysql-server

-php-mysql

-php-pdo

Apache-service:

File.managed:

-name: / etc/httpd/conf/httpd.conf

-source:

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

-user: root

-group: root

-mode: 644

Service.running:

-name: httpd

-enable: True

Mysql-service:

File.managed:

-name: / etc/my.cnf

-source:

-salt://dev/files/my.cnf

-user: root

-group: root

-mode: 644

Service.running:

-name: mysqld

-enable: True

Php-fpm-service:

Service.running:

-name: php-fpm

-enable: True

[root@salt-master112 salt] # cat top.sls

Base:

'*':

-init.dns

Dev:

'node*.test.com':

-lamp

[root@salt-master112 salt] # ls dev/

Files lamp.sls

[root@salt-master112 salt] # ls dev/files/

Httpd.conf my.cnf

[root@salt-master112 salt] #

Execute salt'* 'state.highstate to view the results:

[root@salt-master112 salt] # salt-key-L

Accepted Keys:

Master.test.com

Node1.test.com

Node2.test.com

Denied Keys:

Unaccepted Keys:

Rejected Keys:

[root@salt-master112 salt] # salt'* 'state.highstate

Master.test.com:

-

ID: / etc/resolv.conf

Function: file.managed

Result: True

Comment: File / etc/resolv.conf is in the correct state

Started: 23:20:50.495770

Duration: 23.706 ms

Changes:

Summary for master.test.com

-

Succeeded: 1

Failed: 0

-

Total states run: 1

Total run time: 23.706 ms

Node1.test.com:

-

ID: / etc/resolv.conf

Function: file.managed

Result: True

Comment: File / etc/resolv.conf is in the correct state

Started: 15:23:33.990342

Duration: 32.918 ms

Changes:

-

ID: lamp-pkg-install

Function: pkg.installed

Name: httpd

Result: True

Comment: Package httpd is already installed

Started: 15:23:34.603609

Duration: 649.913 ms

Changes:

-

ID: lamp-pkg-install

Function: pkg.installed

Name: php-pdo

Result: True

Comment: Package php-pdo is already installed

Started: 15:23:35.253716

Duration: 0.539 ms

Changes:

-

ID: lamp-pkg-install

Function: pkg.installed

Name: php-fpm

Result: True

Comment: Package php-fpm is already installed

Started: 15:23:35.254347

Duration: 0.359 ms

Changes:

-

ID: lamp-pkg-install

Function: pkg.installed

Name: mysql-server

Result: True

Comment: Package mysql-server is already installed

Started: 15:23:35.254807

Duration: 0.346 ms

Changes:

-

ID: lamp-pkg-install

Function: pkg.installed

Name: php-mysql

Result: True

Comment: Package php-mysql is already installed

Started: 15:23:35.255233

Duration: 0.367 ms

Changes:

-

ID: lamp-pkg-install

Function: pkg.installed

Name: mysql

Result: True

Comment: Package mysql is already installed

Started: 15:23:35.255688

Duration: 0.355 ms

Changes:

-

ID: lamp-pkg-install

Function: pkg.installed

Name: php

Result: True

Comment: Package php is already installed

Started: 15:23:35.256129

Duration: 0.348 ms

Changes:

-

ID: apache-service

Function: file.managed

Name: / etc/httpd/conf/httpd.conf

Result: False

Comment: Unable to manage file: none of the specified sources were found

Started: 15:23:35.256569

Duration: 6.275 ms

Changes:

-

ID: apache-service

Function: service.running

Name: httpd

Result: False

Comment: Service httpd has been enabled, and is dead

Started: 15:23:35.275736

Duration: 230.013 ms

Changes:

-

Httpd:

True

-

ID: mysql-service

Function: file.managed

Name: / etc/my.cnf

Result: False

Comment: Unable to manage file: none of the specified sources were found

Started: 15:23:35.505956

Duration: 6.35 ms

Changes:

-

ID: mysql-service

Function: service.running

Name: httpd

Result: False

Comment: Service httpd is already enabled, and is dead

Started: 15:23:35.512412

Duration: 134.002 ms

Changes:

-

ID: php-fpm-service

Function: service.running

Name: php-fpm

Result: True

Comment: Service php-fpm is already enabled, and is running

Started: 15:23:35.646635

Duration: 196.639 ms

Changes:

-

Php-fpm:

True

Summary for node1.test.com

-

Succeeded: 9 (changed=2)

Failed: 4

-

Total states run: 13

Total run time: 1.258 s

Node2.test.com:

-

ID: / etc/resolv.conf

Function: file.managed

Result: True

Comment: File / etc/resolv.conf is in the correct state

Started: 15:23:34.682679

Duration: 103.617 ms

Changes:

-

ID: lamp-pkg-install

Function: pkg.installed

Name: httpd

Result: True

Comment: The following packages were installed/updated: httpd

Started: 15:23:38.021487

Duration: 46521.648 ms

Changes:

-

Apr:

-

New:

1.3.9-5.el6_2

Old:

Apr-util:

-

New:

1.3.9-3.el6_0.1

Old:

Apr-util-ldap:

-

New:

1.3.9-3.el6_0.1

Old:

Httpd:

-

New:

2.2.15-59.el6.centos

Old:

Httpd-tools:

-

New:

2.2.15-59.el6.centos

Old:

Mailcap:

-

New:

2.1.31-2.el6

Old:

-

ID: lamp-pkg-install

Function: pkg.installed

Name: php-pdo

Result: True

Comment: The following packages were installed/updated: php-pdo

Started: 15:24:24.562565

Duration: 8749.133 ms

Changes:

-

Php-common:

-

New:

5.3.3-49.el6

Old:

Php-pdo:

-

New:

5.3.3-49.el6

Old:

-

ID: lamp-pkg-install

Function: pkg.installed

Name: php-fpm

Result: True

Comment: The following packages were installed/updated: php-fpm

Started: 15:24:33.336866

Duration: 8477.529 ms

Changes:

-

Php-fpm:

-

New:

5.3.3-49.el6

Old:

-

ID: lamp-pkg-install

Function: pkg.installed

Name: mysql-server

Result: True

Comment: The following packages were installed/updated: mysql-server

Started: 15:24:41.843441

Duration: 28414.553 ms

Changes:

-

Mysql:

-

New:

5.1.73-8.el6_8

Old:

Mysql-libs:

-

New:

5.1.73-8.el6_8

Old:

Mysql-server:

-

New:

5.1.73-8.el6_8

Old:

Perl-DBD-MySQL:

-

New:

4.013-3.el6

Old:

Perl-DBI:

-

New:

1.609-4.el6

Old:

-

ID: lamp-pkg-install

Function: pkg.installed

Name: php-mysql

Result: True

Comment: The following packages were installed/updated: php-mysql

Started: 15:25:10.289755

Duration: 8122.46 ms

Changes:

-

Php-mysql:

-

New:

5.3.3-49.el6

Old:

-

ID: lamp-pkg-install

Function: pkg.installed

Name: mysql

Result: True

Comment: Package mysql is already installed

Started: 15:25:18.458202

Duration: 1.519 ms

Changes:

-

ID: lamp-pkg-install

Function: pkg.installed

Name: php

Result: True

Comment: The following packages were installed/updated: php

Started: 15:25:18.459996

Duration: 14374.708 ms

Changes:

-

Php:

-

New:

5.3.3-49.el6

Old:

Php-cli:

-

New:

5.3.3-49.el6

Old:

-

ID: apache-service

Function: file.managed

Name: / etc/httpd/conf/httpd.conf

Result: False

Comment: Unable to manage file: none of the specified sources were found

Started: 15:25:32.846614

Duration: 38.9 ms

Changes:

-

ID: apache-service

Function: service.running

Name: httpd

Result: False

Comment: Service httpd has been enabled, and is dead

Started: 15:25:32.916084

Duration: 674.943 ms

Changes:

-

Httpd:

True

-

ID: mysql-service

Function: file.managed

Name: / etc/my.cnf

Result: False

Comment: Unable to manage file: none of the specified sources were found

Started: 15:25:33.591498

Duration: 23.162 ms

Changes:

-

ID: mysql-service

Function: service.running

Name: httpd

Result: False

Comment: Service httpd is already enabled, and is dead

Started: 15:25:33.614954

Duration: 357.977 ms

Changes:

-

ID: php-fpm-service

Function: service.running

Name: php-fpm

Result: True

Comment: Service php-fpm is already enabled, and is running

Started: 15:25:33.973402

Duration: 512.95 ms

Changes:

-

Php-fpm:

True

Summary for node2.test.com

-

Succeeded: 9 (changed=8)

Failed: 4

-

Total states run: 13

Total run time: 116.373 s

ERROR: Minions returned with non-zero exit code

[root@salt-master112 salt] #

There are errors in the above results.

Unable to manage file: none of the specified sources were found

You need to modify the path to get rid of dev. Because lamp is defined under dev in the top.sls configuration file, salt:// should start from the dev directory.

-salt://files/httpd.conf

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report