In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
[root@localhost roles] # pwd
/ etc/ansible/roles
[root@localhost roles] # ls
Ansible_zabbix.tar.gz zabbix
[root@localhost roles] # ll zabbix/
Total dosage 16
Drwxr-xr-x. 2 root root 4096 May 25 17:15 group_vars
Drwxr-xr-x. 8 root root 4096 May 26 17:25 roles
-rw-r--r--. 1 root root 14 May 27 11:05 zabbix.retry
-rw-r--r--. 1 root root 140 May 27 15:29 zabbix.yaml
. Roles and inclusions
├── ansible_zabbix.tar.gz
└── zabbix
├── group_vars
│?? └── zabbix
├── roles
│?? ├── java
│?? │?? ├── files
│?? ├── java.sh
│?? └── jdk-8u101-linux-x64.tar.gz
│?? │?? ├── handlers
│?? └── main.yml
│?? │?? └── tasks
│?? │?? └── main.yml
│?? ├── mysql
│?? │?? ├── files
│?? ├── cmake-2.8.10.2.tar.gz
│?? └── mysql-5.6.24.tar.gz
│?? │?? ├── handlers
│?? └── main.yml
│?? │?? └── tasks
│?? │?? └── main.yml
│?? ├── nginx
│?? │?? ├── files
│?? ├── nginx
│?? ├── nginx-1.10.2.tar.gz
│?? ├── openssl-1.0.2f.tar.gz
│?? ├── pcre-8.38.tar.gz
│?? └── zlib-1.2.8.tar.gz
│?? │?? ├── handlers
│?? └── main.yml
│?? │?? ├── tasks
│?? └── main.yml
│?? │?? └── templates
│?? │?? └── nginx.conf.j2
│?? ├── php
│?? │?? ├── files
│?? ├── index.php
│?? ├── libiconv-1.13.1.tar.gz
│?? ├── libmcrypt-2.5.8.tar.gz
│?? ├── Makefile
│?? ├── mhash-0.9.9.9.tar.gz
│?? ├── php-5.6.29.tar.gz
│?? ├── php-fpm
│?? ├── php-fpm.conf
│?? ├── php.ini
│?? └── testdb.php
│?? │?? ├── handlers
│?? └── main.yml
│?? │?? └── tasks
│?? │?? └── main.yml
│?? ├── yum
│?? │?? ├── files
│?? └── CentOS-Base.repo
│?? │?? └── tasks
│?? │?? └── main.yml
│?? └── zabbix_server
│?? ├── files
│?? │?? ├── zabbix
│ │ ├── zabbix-3.0.4.tar.gz
│ │ ├── zabbix_agentd
│ │ ├── zabbix_server
│ │ └── zabbix_server.conf
│ ├── handlers
│ │ └── main.yml
│ ├── tasks
│ │ └── main.yml
│ └── templates
│ └── zabbix_agentd.conf.j2
├── zabbix.retry
└── zabbix.yaml
Define variable
[root@localhost roles] # cd zabbix/
[root@localhost zabbix] # cat group_vars/zabbix
Java_path: / etc/ansible/roles/zabbix/roles/java/files/
Nginx_path: / etc/ansible/roles/zabbix/roles/nginx/files/
Mysql_path: / etc/ansible/roles/zabbix/roles/mysql/files/
Php_path: / etc/ansible/roles/zabbix/roles/php/files/
Zabbix_server_path: / etc/ansible/roles/zabbix/roles/zabbix_server/files/
Zabbix_agent_path: / etc/ansible/roles/zabbix/roles/zabbix_agent/files/
Dest_path: / usr/local/src/
Master yaml file
[root@localhost zabbix] # cat zabbix.yaml
-
-hosts: zabbix
Roles:
-role: yum
-role: java
-role: nginx
-role: mysql
-role: php
-role: zabbix_server
The contents of the files in role
[root@localhost roles] # pwd
/ etc/ansible/roles/zabbix/roles
[root@localhost roles] # ll
Total dosage 24
Drwxr-xr-x. 5 root root 4096 May 23 18:14 java
Drwxr-xr-x. 5 root root 4096 May 23 11:46 mysql
Drwxr-xr-x. 6 root root 4096 May 25 21:39 nginx
Drwxr-xr-x. 5 root root 4096 May 24 10:25 php
Drwxr-xr-x. 4 root root 4096 May 19 05:32 yum
Drwxr-xr-x. 6 root root 4096 May 27 16:06 zabbix_server
Yum deployment
[root@localhost yum] # pwd
/ etc/ansible/roles/zabbix/roles/yum
[root@localhost yum] # tree
.
├── files
│ └── CentOS-Base.repo
└── tasks
└── main.yml
2 directories, 2 files
[root@localhost yum] # cat tasks/main.yml
-
# tasks file for yum
-name: copy the repo
Copy: src=CentOS-Base.repo dest=/etc/yum.repos.d/CentOS-Base.repo
-name: clean cache
Shell: yum clean all;yum makecache
-name: install software
Yum: name=gcc,gcc-c++,make,zlib-devel,ncurses-devel,libxml2,libxml2-devel,libjpeg-devel,libpng-devel,freetype,openldap-devel,openldap,openssl,openssl-devel,pcre,pcre-devel,curl-devel,freetype-devel,net-snmp-devel,mysql-devel state=latest
Java deployment
[root@localhost java] # tree
.
├── files
│ ├── java.sh
│ └── jdk-8u101-linux-x64.tar.gz
├── handlers
│ └── main.yml
└── tasks
└── main.yml
3 directories, 4 files
Root@localhost java] # cat tasks/main.yml
-
# tasks file for java
-name: jie ya jdk-8u101-linux-x64.tar.gz
Unarchive: src= `java_path `jdk-8u101-linux-x64.tar.gz dest= `dest_path `copy=yes
-name: move jdk
Shell: mv / usr/local/src/jdk1.8.0_101 / usr/local/jdk
-name: add bianliang
Copy: src=java.sh dest=/etc/profile.d/
# lineinfile: dest=/etc/profile line= `item `
# with_items:
#-export JRE_HOME=/usr/local/jdk
#-export JAVA_BIN=/usr/local/jdk/bin
#-export PATH=$JRE_HOME/bin:$PATH
#-export CLASSPATH=.:$JRE_HOME/lib/dt.jar:$JRE_HOME/lib/tools.jar
#-export JRE_HOME JAVA_BIN PATH CLASSPATH
-name: source profile
Shell: source / etc/profile.d/java.sh
# notify:
#-add bianliang
#-source profile
[root@localhost java] # cat handlers/main.yml
-
# handlers file for java
-name: add bianliang
Lineinfile: dest=/etc/profile line= `item `
With_items:
-export JRE_HOME=/usr/local/jdk
-export JAVA_BIN=/usr/local/jdk/bin
-export PATH=$JRE_HOME/bin:$PATH
-export CLASSPATH=.:$JRE_HOME/lib/dt.jar:$JRE_HOME/lib/tools.jar
-export JRE_HOME JAVA_BIN PATH CLASSPATH
-name: source profile
Shell: source / etc/profile
Nginx deployment
[root@localhost nginx] # tree
.
├── files
│ ├── nginx
│ ├── nginx-1.10.2.tar.gz
│ ├── openssl-1.0.2f.tar.gz
│ ├── pcre-8.38.tar.gz
│ └── zlib-1.2.8.tar.gz
├── handlers
│ └── main.yml
├── tasks
│ └── main.yml
└── templates
└── nginx.conf.j2
4 directories, 8 files
[root@localhost nginx] #
[root@localhost tasks] # pwd
/ etc/ansible/roles/zabbix/roles/nginx/tasks
[root@localhost tasks] # cat main.yml
-
-name: useradd www
User: name=www shell=/sbin/nologin createhome=no
-name: openssl-1.0.2f.tar.gz package
Unarchive: src= `nginx_path `openssl-1.0.2f.tar.gz dest= `dest_path `copy=yes
-name: pcre-8.38.tar.gz package
Unarchive: src= `nginx_path `pcre-8.38.tar.gz dest= `dest_path `copy=yes
-name: zlib-1.2.8.tar.gz
Unarchive: src= `nginx_path `zlib-1.2.8.tar.gz dest= `dest_path `copy=yes
-name: nginx-1.10.2.tar.gz package
Unarchive: src= `nginx_path `nginx-1.10.2.tar.gz dest= `dest_path `copy=yes
-name: nginx config
Shell: cd `dest_path `nginx-1.10.2 / configure-- prefix=/usr/local/nginx-- sbin-path=/usr/local/nginx/sbin/nginx-- conf-path=/usr/local/nginx/nginx.conf-- error-log-path=/var/log/nginx/error.log-- http-log-path=/var/log/nginx/access.log-- pid-path=/var/run/nginx.pid-- lock-path=/var/run/nginx.lock-- http-client-body-temp-path=/var/cache/nginx/ Client_temp-http-proxy-temp-path=/var/cache/nginx/proxy_temp-http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp-http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp-http-scgi-temp-path=/var/cache/nginx/scgi_temp-user=nginx-group=nginx-with-http_ssl_module-with-http_realip_module with-http_addition_module-with-http_sub_ Module-with-http_dav_module-with-http_flv_module-with-http_mp4_module-with-http_gunzip_module-with-http_gzip_static_module-with-http_random_index_module-with-http_secure_link_module-with-http_stub_status_module-with-http_auth_request_module-with-threads with-stream with-stream_ssl_module with-stream_ssl_module with-http_slice_module -- with-mail-- with-mail_ssl_module-- with-file-aio-- with-http_v2_module-- with-ipv6-- with-pcre= `dest_path `pcre-8.38-- with-zlib= `dest_path `zlib-1.2.8-- with-openssl= `dest_path `openssl-1.0.2f
-name: nginx make and install
Shell: cd `dest_path `nginx-1.10.2;make;make install
-name: create cache nginx
File: path=/var/cache/nginx state=directory owner=root group=root mode=0644
-name: copy config file
Template: src=nginx.conf.j2 dest=/usr/local/nginx/nginx.conf owner=root group=root mode=0644
-name: add nginx grant
Shell: cd / usr/local/nginx/;chown-R www:www *
-name: copy start file
Copy: src=nginx dest=/etc/init.d/ owner=root group=root mode=0755 backup=yes
Notify:
-start nginx service
Tags: nginx
[root@localhost handlers] # pwd
/ etc/ansible/roles/zabbix/roles/nginx/handlers
[root@localhost handlers] # cat main.yml
-
-name: start nginx service
Service: name=nginx state=restarted enabled=yes
[root@localhost templates] # pwd
/ etc/ansible/roles/zabbix/roles/nginx/templates
[root@localhost templates] # cat nginx.conf.j2
User www
Worker_processes `ansible_processor_cores `
Events {
Worker_connections 1024
}
Http {
Include mime.types
Default_type application/octet-stream
Sendfile on
Keepalive_timeout 65
Server {
Listen 80
Server_name localhost
Location / {
Root html
Index index.php index.html index.htm
}
Error_page 500 502 503 504 / 50x.html
Location = / 50x.html {
Root html
}
Location ~\ .php$ {
Root html
Fastcgi_pass 127.0.0.1:9000
Fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name
Include fastcgi_params
}
}
}
MySQL deployment
[root@localhost mysql] # pwd
/ etc/ansible/roles/zabbix/roles/mysql
[root@localhost mysql] # tree
.
├── files
│ ├── cmake-2.8.10.2.tar.gz
│ └── mysql-5.6.24.tar.gz
├── handlers
│ └── main.yml
└── tasks
└── main.yml
3 directories, 4 files
[root@localhost mysql] # cat tasks/main.yml
-
# tasks file for mysql
-name: mysql-5.6.24.tar.gz package
Unarchive: src= `mysql_path `mysql-5.6.24.tar.gz dest= `dest_path `copy=yes
-name: cmake-2.8.10.2.tar.gz package
Unarchive: src= `mysql_path `cmake-2.8.10.2.tar.gz dest= `dest_path `copy=yes
-name: install camke
Shell: cd `dest_path `cmake-2.8.10.2;./bootstrap-- prefix=/usr/local/cmake;make;make install
-name: add user
Shell: id mysql | | useradd-M-s / sbin/nologin mysql
-name: add quanxian
File: path=/tmp mode=777
-name: bianyi
Shell: cd `dest_path `mysql-5.6.24 / usr/local/cmake/bin/cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DSYSCONFDIR=/etc-DMYSQL_DATADIR=/usr/local/mysql/data-DMYSQL_TCP_PORT=3306-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysqld.sock-DMYSQL_USER=mysql-DWITH_READLINE=1-DWITH_SSL=system-DWITH_EMBEDDED_SERVER=1-DENABLED_LOCAL_INFILE=1-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1-DEXTRA_CHARSETS=all-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_DEBUG=0
-name: make and make install
Shell: cd `dest_path `mysql-5.6.24;make;make install
-name: shou quna
Shell: chown-R mysql:mysql / usr/local/mysql
-name: line
Shell: ln-s / usr/local/mysql/bin/ `item `/ usr/sbin/
With_items:
-innochecksum
-msql2mysql
-myisamchk
-myisam_ftdump
-myisamlog
-myisampack
-my_print_defaults
-mysql
-mysqlaccess
-mysqlaccess.conf
-mysqladmin
-mysqlbinlog
-mysqlbug
-mysqlcheck
-mysql_client_test
-mysql_client_test_embedded
-mysql_config
-mysql_config_editor
-mysql_convert_table_format
-mysqld
-mysqld_multi
-mysqld_safe
-mysqldump
-mysqldumpslow
-mysql_embedded
-mysql_find_rows
-mysql_fix_extensions
-mysqlhotcopy
-mysqlimport
-mysql_plugin
-mysql_secure_installation
-mysql_setpermission
-mysqlshow
-mysqlslap
-mysqltest
-mysqltest_embedded
-mysql_tzinfo_to_sql
-mysql_upgrade
-mysql_waitpid
-mysql_zap
-perror
-replace
-resolveip
-resolve_stack_dump
Tags:
-link
-name: copy mysql start script
Shell: cp `dest_path `mysql-5.6.24/support-files/mysql.server / etc/init.d/mysqld
-name: insert ld.so.conf
Lineinfile: dest=/etc/ld.so.conf line=/usr/local/mysql/lib/
-name: ldconfig
Shell: ldconfig
-name: chu shi hua
Shell: / usr/local/mysql/scripts/mysql_install_db-user=mysql-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data
-name: copy my.cnf
Shell: rm-rf / etc/my.cnf;mv / usr/local/mysql/my.cnf / etc/
-name: add max_connections
Lineinfile: dest=/etc/my.cnf line= "max_connections = 1000"
#-name: insert / var/lib/mysql/mysql.sock
# lineinfile: dest=/etc/my.cnf line= "socket = / var/lib/mysql/mysql.sock"
# tags:
#-socket
-name: start mysql service
Service: name=mysqld state=restarted enabled=yes
Tags:
-mysqlstart
-name: set mysql passwd
Shell: / usr/local/mysql/bin/mysqladmin-u root password 'mysql_dbpass'
Tags:
-mysqlpasswd
[root@localhost mysql] # cat handlers/main.yml
-
# handlers file for mysql
-name: start mysql service
Service: name=mysqld state=restarted enabled=yes
-name: set mysql passwd
Shell: / usr/local/mysql/bin/mysqladmin-u root password 'mysql_dbpass'
PHP deployment
[root@localhost php] # pwd
/ etc/ansible/roles/zabbix/roles/php
[root@localhost php] # tree
.
├── files
│ ├── index.php
│ ├── libiconv-1.13.1.tar.gz
│ ├── libmcrypt-2.5.8.tar.gz
│ ├── Makefile
│ ├── mhash-0.9.9.9.tar.gz
│ ├── php-5.6.29.tar.gz
│ ├── php-fpm
│ ├── php-fpm.conf
│ ├── php.ini
│ └── testdb.php
├── handlers
│ └── main.yml
└── tasks
└── main.yml
3 directories, 12 files
[root@localhost php] # cat tasks/main.yml
-
# tasks file for php
-name: mhash-0.9.9.9.tar.gz
Unarchive: src= `php_path `mhash-0.9.9.9.tar.gz dest= `dest_path `copy=yes
-name: libiconv-1.13.1.tar.gz
Unarchive: src= `php_path `libiconv-1.13.1.tar.gz dest= `dest_path `copy=yes
-name: libmcrypt-2.5.8.tar.gz
Unarchive: src= `php_path `libmcrypt-2.5.8.tar.gz dest= `dest_path `copy=yes
-name: php-5.6.29.tar.gz
Unarchive: src= `php_path `php-5.6.29.tar.gz dest= `dest_path `copy=yes
-name: config mhash
Shell: cd `dest_path `mhash-0.9.9.9;./configure;make;make install
-name: config libiconv
Shell: cd `dest_path `libiconv-1.13.1;./configure;make;make install
-name: config libmcrypt
Shell: cd `dest_path `libmcrypt-2.5.8;./configure;make;make install
-name: config libmcrypt-2.5.8/libltdl
Shell: cd `dest_path `libmcrypt-2.5.8/libltdl/;./configure-- with-gmetad-- enable-gexec-- enable-ltdl-install
-name: libmcrypt make and make install
Shell: cd `dest_path `libmcrypt-2.5.8/libltdl/;make;make install
-name: line libmcrypt*
File: src=/usr/local/lib/ `item`.`src `dest=/usr/lib/ `item`.`dest `state=link
With_items:
-{src: 'libmcrypt.so.4.4.8', dest:' libmcrypt.so.4.4.8'}
-{src: 'libmcrypt.so.4', dest:' libmcrypt.so.4'}
-{src: 'libmcrypt.so', dest:' libmcrypt.so'}
-{src: 'libmcrypt.la', dest:' libmcrypt.la'}
-{src: 'libmcrypt', dest:' libmcrypt'}
-{src: 'libmhash.a', dest:' libmhash.a'}
-{src: 'libmhash.la', dest:' libmhash.la'}
-{src: 'libmhash.so', dest:' libmhash.so'}
-{src: 'libmhash.so.2', dest:' libmhash.so.2'}
-{src: 'libmhash.so.2.0.1', dest:' libmhash.so.2.0.1'}
-name: ldconfig
Shell: ldconfig
-name: cp libladp*
File: src=/usr/lib64/ `item`.`src `dest=/usr/lib/ `item`.`dest `state=link
With_items:
-{src: 'libldap-2.4.so.2', dest:' libldap-2.4.so.2'}
-{src: 'libldap_r-2.4.so.2', dest:' libldap_r-2.4.so.2'}
-{src: 'libldap_r.so', dest:' libldap_r.so'}
-{src: 'libldap.so', dest:' libldap.so'}
-name: config php
Shell: cd `dest_path `php-5.6.29 . / configure-- prefix=/usr/local/php-- with-config-file-path=/usr/local/php/etc-- with-mysql=/usr/local/mysql-- with-mysqli=/usr/local/mysql/bin/mysql_config-- with-iconv-dir=/usr/local-- with-jpeg-dir-- with-png-dir-- with-zlib-- with-libxml-dir=/usr-- enable-xml-- disable-rpath-- enable-bcmath-- enable-shmop-- enable- Sysvsem-enable-inline-optimization-with-curl-enable-mbregex-enable-fpm-enable-mbstring-with-mcrypt-with-gd-enable-gd-native-ttf-with-openssl-with-mhash-enable-pcntl-enable-sockets-with-ldap--with-ldap-sasl-with-xmlrpc-enable-zip-enable-soap-with-freetype-dir-with-gettext-with-fpm-user=www-with-fpm-group=www
-name: copy Makefile
Copy: src=Makefile dest= `dest_path `php-5.6.29 owner=root group=root mode=0644 backup=yes
#-name: config Makefile
# shell: sed-I 's#EXTRA_LIBS =-lcrypt-lz-lcrypt-lrt-lmysqlclient-lmcrypt-lltdl-lldap-lpng-lz-ljpeg-lcurl-lz-lrt-lm-ldl-lnsl-lrt-lxml2-lz-lm-lssl-lcrypto-lcurl-lxml2-lz-lm-lfreetype-lmysqlclient-lm-lrt-lssl-lcrypto-lcrypto-ldl-lxml2-lz-lz-lxml2-lxml2-lxml2- Lcrypt#EXTRA_LIBS =-lcrypt-lz-lcrypt-lrt-lmysqlclient-lmcrypt-lltdl-lldap-lpng-lz-ljpeg-lcurl-lz-lrt-lm-ldl-lnsl-lrt-lxml2-lz-lm-lssl-lcrypto-lcurl-lxml2-lz-lm-lfreetype-lmysqlclient-lm-lrt-lssl-lcrypto-ldl-lxml2-lxml2-lz-lm-lm-lxml2-- lxml2-lm-lm
-name: make ZEND_EXTRA_LIBS='-liconv'
Shell: cd `dest_path `php-5.6.29;make ZEND_EXTRA_LIBS='-liconv'
-name: make install
Shell: cd `dest_path `php-5.6.29;make install
-name: copy file php.ini
Copy: src=php.ini dest=/usr/local/php/etc/ owner=root group=root mode=0644 backup=yes
-name: copy file php-fpm.conf
Copy: src=php-fpm.conf dest=/usr/local/php/etc/ owner=root group=root mode=0644 backup=yes
-name: copy php-fpm
Copy: src=php-fpm dest=/etc/init.d/ owner=root group=root mode=0755 backup=yes
-name: copy file index.php testdb.php
Copy: src= `item `dest=/usr/local/nginx/html/ owner=root group=root mode=0644 backup=yes
With_items:
-index.php
-testdb.php
Notify:
-start php
[root@localhost php] # cat handlers/main.yml
-
# handlers file for php
-name: start php
Service: name=php-fpm state=restarted enabled=yes
Zabbix deployment
[root@localhost zabbix_server] # pwd
/ etc/ansible/roles/zabbix/roles/zabbix_server
[root@localhost zabbix_server] # ls
Handlers tasks templates
[root@localhost zabbix_server] # tree
├── files
│ ├── zabbix
│ ├── zabbix-3.0.4.tar.gz
│ ├── zabbix_agentd
│ ├── zabbix_server
│ └── zabbix_server.conf
├── handlers
│ └── main.yml
├── tasks
│ └── main.yml
└── templates
└── zabbix_agentd.conf.j2
[root@localhost zabbix_server] # cat tasks/main.yml
-
# tasks file for zabbix_server
-name: add usergroup
Group: name=zabbix gid=201 system=yes
Tags:
-zabbix_1
-name: add user
User: name=zabbix uid=201 group=zabbix
Tags:
-zabbix_2
-name: unarchive zabbix-3.0.4.tar.gz
Unarchive: src= `zabbix_server_path `zabbix-3.0.4.tar.gz dest= `dest_path `copy=yes
Tags:
-zabbix_3
-name: config and make install
Shell: cd `dest_path `zabbix-3.0.4;./configure-- prefix=/usr/local/zabbix-- enable-java-- enable-server-- enable-proxy-- enable-agent-- with-mysql-- with-net-snmp-- with-libcurl-- with-libxml2;make install
Tags:
-zabbix_4
-name: add zabbix to services
Lineinfile: dest=/etc/services line= `item `
With_items:
-"zabbix-agent 10050/tcp # Zabbix Agent"
-"zabbix-agent 10050/udp # Zabbix Agent"
-"zabbix-server 10051/tcp # zabbix Trapper"
-"zabbix-server 10051/udp # zabbix Trapper"
Tags:
-zabbix_4_1
-name: create database user
Shell: mysql-uroot-pmysql_dbpass-e "create database zabbix default character set utf8;"
Tags:
-zabbix_5
-name: databases shou quan
Shell: mysql-uroot-pmysql_dbpass-e "grant all on zabbix.* to 'zabbix'@'localhost' identified by' zabbix';"
Tags:
-zabbix_6
-name: flush privileges
Shell: mysql-uroot-pmysql_dbpass-e "flush privileges;"
Tags:
-zabbix_7
-name: import databases
Shell: cd `dest_path `zabbix-3.0.4/database/mysql;mysql-uzabbix-pzabbix zabbix < schema.sql;mysql-uzabbix-pzabbix zabbix < proomwroompicpaths.sqlash MySQL-uzabbix-pzabbix zabbix < data.sql
Tags:
-zabbix_8
-name: create zabbix log directory
File: path=/data/logs/zabbix/ state=directory owner=zabbix group=zabbix
Tags:
-zabbix_9
-name: create / etc/ zabbix directory
File: path=/etc/zabbix/ state=directory
Tags:
-zabbix_10
-name: create / usr/local/zabbix/etc link
File: src=/usr/local/zabbix/etc/ `item`.`src `dest=/etc/zabbix/ `item`.`dest `state=link
With_items:
-{src: 'zabbix_agentd.conf', dest:' zabbix_agentd.conf'}
-{src: 'zabbix_proxy.conf', dest:' zabbix_proxy.conf'}
-{src: 'zabbix_server.conf', dest:' zabbix_server.conf'}
-{src: 'zabbix_agentd.conf.d', dest:' zabbix_agentd.conf.d'}
-{src: 'zabbix_proxy.conf.d', dest:' zabbix_proxy.conf.d'}
-{src: 'zabbix_server.conf.d', dest:' zabbix_server.conf.d'}
Tags:
-zabbix_11
-name: create / usr/local/zabbix/bin link
File: src=/usr/local/zabbix/bin/ `item`.`src `dest=/etc/zabbix/ `item`.`dest `state=link
With_items:
-{src: 'zabbix_get', dest:' zabbix_get'}
-{src: 'zabbix_sender', dest:' zabbix_sender'}
Tags:
-zabbix_12
-name: create / usr/local/zabbix/sbin link
File: src=/usr/local/zabbix/sbin/ `item`.`src `dest=/usr/sbin/ `item`.`dest `state=link
With_items:
-{src: 'zabbix_agentd', dest:' zabbix_agentd'}
-{src: 'zabbix_java', dest:' zabbix_java'}
-{src: 'zabbix_proxy', dest:' zabbix_proxy'}
-{src: 'zabbix_server', dest:' zabbix_server'}
Tags:
-zabbix_13
-name: copy zabbix start stop script
Copy: src= `item `dest=/etc/init.d owner=root group=root mode=0755 backup=yes
With_items:
-zabbix_server
-zabbix_agentd
Tags:
-zabbix_14
-name: copy zabbix_server.conf
# file: src= `item `dest=/usr/local/zabbix/etc/ owner=root group=root mode=0644 backup=yes
Synchronize: src= `item `dest=/usr/local/zabbix/etc/ mode=push
With_items:
-zabbix_server.conf
Tags:
-zabbix_15
-name: copy zabbix_agentd.conf
Template: src=zabbix_agentd.conf.j2 dest=/usr/local/zabbix/etc/zabbix_agentd.conf owner=root group=root mode=0644
Tags:
-zabbix_16
-name: copy zabbix wangzhan directory
Synchronize: src=zabbix dest=/usr/local/nginx/html/ mode=push
Tags:
-zabbix_17
#-name: change user
# file: dest=/usr/local/nginx/html/zabbix owner=www group=www backup=yes
-name: add / usr/local/lib
Lineinfile: dest=/etc/ld.so.conf line=/usr/local/lib
Tags:
-zabbix_19
#-name: add max_connections
# lineinfile: dest=/etc/my.cnf line= "max_connections = 1000"
-name: ldconfig
Shell: ldconfig
Tags:
-zabbix_20
Notify:
-start zabbix_server
-start zabbix_agentd
-stop iptables
-stop selinux
[root@localhost zabbix_server] # cat handlers/main.yml
-
# handlers file for zabbix_server
-name: start zabbix_server
Service: name=zabbix_server state=restarted enabled=yes
-name: start zabbix_agentd
Service: name=zabbix_agentd state=restarted enabled=yes
-name: stop iptables
Service: name=iptables state=stopped enabled=no
-name: stop selinux
Shell: setenforce 0
[root@localhost zabbix_server] # cat templates/zabbix_agentd.conf.j2
EnableRemoteCommands=1
UnsafeUserParameters=1
Server=127.0.0.1, `ansible_ eth0`.`ipv4`.`address `
ServerActive= `ansible_ eth0`.`ipv4`.`address `: 10051
Hostname= `ansible_hostname `
LogFile=/data/logs/zabbix/zabbix_agentd.log
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
Execute the Yaml master file
[root@localhost zabbix] # ls
Group_vars roles zabbix.retry zabbix.yaml
[root@localhost zabbix] # pwd
/ etc/ansible/roles/zabbix
[root@localhost zabbix] # ansible-playbook zabbix.yaml
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.