编写状态文件
[root@master prod]
.
├── modules
│ ├── application
│ │ └── php7
│ │ ├── files
│ │ │ ├── install.sh
│ │ │ ├── oniguruma-devel-6.8.2-2.el8.x86_64.rpm
│ │ │ ├── php-7.4.24.tar.gz
│ │ │ ├── php-fpm
│ │ │ ├── php-fpm.conf
│ │ │ ├── php-fpm.service
│ │ │ └── www.conf
│ │ └── install.sls
│ ├── database
│ │ └── mysql
│ │ ├── files
│ │ │ ├── install.sh
│ │ │ ├── mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
│ │ │ ├── mysqld.service
│ │ │ └── mysql.server
│ │ └── install.sls
│ └── web
│ └── apache
│ ├── files
│ │ ├── apr-1.7.0.tar.gz
│ │ ├── apr-util-1.6.1.tar.gz
│ │ ├── httpd-2.4.49.tar.gz
│ │ ├── httpd.conf
│ │ ├── httpd.service
│ │ └── install.sh
│ └── install.sls
└── zabbix
├── apache.sls
├── files
│ ├── index.php
│ ├── my.cnf
│ ├── mysql.conf
│ ├── php.ini
│ ├── vhosts.conf
│ ├── zabbix-5.4.4.tar.gz
│ ├── zabbix_server.conf
│ └── zabbix.sh
├── install.sls
├── main.sls
└── mysql.sls
12 directories, 32 files
[root@master prod]
[root@master prod]
apache-dep-package:
pkg.installed:
- pkgs:
- openssl-devel
- pcre-devel
- expat-devel
- libtool
- gcc
- gcc-c++
- make
apache:
user.present:
- shell: /sbin/nologin
- createhome: false
- system: true
apache-download:
file.managed:
- names:
- /usr/src/apr-1.7.0.tar.gz:
- source: salt://modules/web/apache/files/apr-1.7.0.tar.gz
- /usr/src/apr-util-1.6.1.tar.gz:
- source: salt://modules/web/apache/files/apr-util-1.6.1.tar.gz
- /usr/src/httpd-2.4.49.tar.gz:
- source: salt://modules/web/apache/files/httpd-2.4.49.tar.gz
/usr/lib/systemd/system/httpd.service:
file.managed:
- source: salt://modules/web/apache/files/httpd.service
- user: root
- group: root
- mode: '0644'
salt://modules/web/apache/files/install.sh:
cmd.script
/usr/local/httpd/conf/httpd.conf:
file.managed:
- source: salt://modules/web/apache/files/httpd.conf
- user: root
- group: root
- mode: '0644'
[root@master prod]
[root@master prod]
ncurses-compat-libs:
pkg.installed
create-mysql-user:
user.present:
- name: mysql
- system: true
- createhome: false
- shell: /sbin/nologin
create-datadir:
file.directory:
- name: /opt/data
- user: mysql
- group: mysql
- mode: '0755'
- makedirs: true
/usr/src/mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz:
file.managed:
- source: salt://modules/database/mysql/files/mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
- user: root
- group: root
- mode: '0644'
salt://modules/database/mysql/files/install.sh:
cmd.script
trasfer-files:
file.managed:
- names:
- /usr/local/mysql/support-files/mysql.server:
- source: salt://modules/database/mysql/files/mysql.server
- /usr/lib/systemd/system/mysqld.service:
- source: salt://modules/database/mysql/files/mysqld.service
[root@master prod]
[root@master prod]
php-dep-packages:
pkg.installed:
- pkgs:
- libxml2
- libxml2-devel
- openssl
- openssl-devel
- bzip2
- bzip2-devel
- libcurl
- libcurl-devel
- libicu-devel
- libjpeg-turbo
- libjpeg-turbo-devel
- libpng
- libpng-devel
- openldap-devel
- pcre-devel
- freetype
- freetype-devel
- gmp
- gmp-devel
- libmcrypt
- libmcrypt-devel
- readline
- readline-devel
- libxslt
- libxslt-devel
- mhash
- mhash-devel
- libsqlite3x-devel
- php-mysqlnd
- libzip-devel
- gcc
- gcc-c++
- make
/usr/src/oniguruma-devel-6.8.2-2.el8.x86_64.rpm:
file.managed:
- source: salt://modules/application/php7/files/oniguruma-devel-6.8.2-2.el8.x86_64.rpm
- user: root
- group: root
- mode: '0644'
cmd.run:
- name: yum -y install /usr/src/oniguruma-devel-6.8.2-2.el8.x86_64.rpm
/usr/src:
archive.extracted:
- source: salt://modules/application/php7/files/php-7.4.24.tar.gz
salt://modules/application/php7/files/install.sh:
cmd.script
copysoft:
file.managed:
- names:
- /etc/init.d/php-fpm:
- source: salt://modules/application/php7/files/php-fpm
- user: root
- group: root
- mode: '0755'
- /usr/local/php7/etc/php-fpm.conf:
- source: salt://modules/application/php7/files/php-fpm.conf
- /usr/local/php7/etc/php-fpm.d/www.conf:
- source: salt://modules/application/php7/files/www.conf
- /usr/lib/systemd/system/php-fpm.service:
- source: salt://modules/application/php7/files/php-fpm.service
php-fpm.service:
service.running:
- enable: true
[root@master prod]
[root@master prod]
"Development Tools":
pkg.group_installed
/usr/include/httpd:
file.symlink:
- target: /usr/local/httpd/include
create-testdir:
file.directory:
- name: /usr/local/httpd/htdocs/zabbix
- user: root
- group: root
- mode: '0755'
/usr/local/httpd/htdocs/zabbix/index.php:
file.managed:
- source: salt://zabbix/files/index.php
- user: root
- group: root
- mode: '0644'
/usr/local/httpd/conf/extra/vhosts.conf:
file.managed:
- source: salt://zabbix/files/vhosts.conf
- user: root
- group: root
- mode: '0644'
zabbix-apache-service:
service.running:
- name: httpd
- enable: true
[root@master prod]
[root@master prod]
lamp-dep-package:
pkg.installed:
- pkgs:
- ncurses-devel
- openssl-devel
- openssl
- cmake
- mariadb-devel
include:
- modules.database.mysql.install
provides-mysql-file:
file.managed:
- user: root
- group: root
- mode: '0644'
- names:
- /etc/my.cnf:
- source: salt://zabbix/files/my.cnf
- /etc/ld.so.conf.d/mysql.conf:
- source: salt://zabbix/files/mysql.conf
/usr/local/include/mysq:
file.symlink:
- target: /usr/local/include/mysq/include
mysqld.service:
service.running:
- enable: true
mysqld-set-password:
cmd.run:
- name: /usr/local/mysql/bin/mysql -e "set password = password('1');"
[root@master prod]
[root@master prod]
include:
- zabbix.apache
[root@master prod]
[root@master prod]
lamp-dep-package:
pkg.installed:
- pkgs:
- ncurses-devel
- openssl-devel
- openssl
- cmake
- mariadb-devel
include:
- modules.database.mysql.install
provides-mysql-file:
file.managed:
- user: root
- group: root
- mode: '0644'
- names:
- /etc/my.cnf:
- source: salt://zabbix/files/my.cnf
- /etc/ld.so.conf.d/mysql.conf:
- source: salt://zabbix/files/mysql.conf
/usr/local/include/mysq:
file.symlink:
- target: /usr/local/include/mysq/include
mysqld.service:
service.running:
- enable: true
mysqld-set-password:
cmd.run:
- name: /usr/local/mysql/bin/mysql -e "set password = password('1');"
[root@master prod]
include:
- zabbix.apache
[root@master prod]
zabbix-dep-packages:
pkg.installed:
- pkgs:
- net-snmp-devel
- libevent-devel
/usr/src:
archive.extracted:
- source: salt://zabbix/files/zabbix-5.4.4.tar.gz
zabbix:
user.present:
- shell: /sbin/nologin
- createhome: false
- system: true
salt://zabbix/files/zabbix.sh:
cmd.script
/usr/local/etc/zabbix_server.conf:
file.managed:
- source: salt://zabbix/files/zabbix_server.conf
cmd.run:
- name: "zabbix_server ; zabbix_agentd "
create-testdir:
file.directory:
- name: /usr/local/httpd/htdocs/zabbix
- user: root
- group: root
- mode: '0755'
cmd.run:
- name: " cp -r /usr/src/zabbix-5.4.4/ui/* /usr/local/httpd/htdocs/zabbix/ "
/usr/local/httpd/conf/extra/vhosts.conf:
file.managed:
- source: salt://zabbix/files/vhosts.conf
/etc/php.ini:
file.managed:
- source: salt://zabbix/files/php.ini
zabbix-zabbix-service:
service.running:
- names:
- php-fpm
- httpd
- restart: true
[root@master prod]
验证效果
[root@node1 ~]
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 80 *:3306 *:*
[root@node1 ~]
|