天天看點

php調取 zabbix實時資料_ansible-playbook實戰之自動化部署zabbix_server監控1、建立roles目錄2、roles基本配置3、安裝過程4、浏覽器驗證

1、建立roles目錄

mkdir -p ansible_install/{group_vars,roles}

mkdir -p ansible_install/roles/zabbix_server/{files,handlers,tasks,templates}

php調取 zabbix實時資料_ansible-playbook實戰之自動化部署zabbix_server監控1、建立roles目錄2、roles基本配置3、安裝過程4、浏覽器驗證

2、roles基本配置

#cat hosts

[zabbix_server]

192.168.52.17 ansible_ssh_user=root [email protected]

site.yml配置:

#cat site.yml

- name: 12.Install zabbix_server

gather_facts: false

hosts: zabbix_server

roles:

- zabbix_server

tags: zabbix_server

#cat roles/zabbix_server/files/zabbix.repo

[zabbix]

name=Zabbix Official Repository - $basearch

#baseurl=http://repo.zabbix.com/zabbix/4.0/rhel/7/$basearch/

baseurl=https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/$basearch/

#這裡我們換成清華的yum源

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-debuginfo]

name=Zabbix Official Repository debuginfo - $basearch

#baseurl=http://repo.zabbix.com/zabbix/4.0/rhel/7/$basearch/debuginfo/

baseurl=https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/$basearch/debuginfo/

#換了上面Zabbix的安裝源位址,其元件位址也要記得換!

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

gpgcheck=1

[zabbix-non-supported]

name=Zabbix Official Repository non-supported - $basearch

#baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/

baseurl=https://mirror.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/$basearch/

enabled=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX

gpgcheck=1

#cat roles/zabbix_server/tasks/main.yml

# 安裝部署LAMP環境,通過YUM子產品快速安裝

- name: install LAMP

yum: name={{item}} state=installed

with_items:

- httpd

- httpd-devel

- mariadb

- mariadb-server

- php

- php-mysql

- name: start httpd

shell: systemctl restart httpd

- name: start mariadb

shell: systemctl restart mariadb

# 下載下傳YUM源,更新EOEL源,安裝Zabbix

- name: clear YUM

shell: rm -rf /etc/yum.repos.dcreate.sql.gz | mysql -uzabbix -pzabbix zabbix

# 修改并拷貝配置檔案,給予權限

- name: edit zabbix dbhost

lineinfile:

dest: /etc/zabbix/zabbix_server.conf

regexp: '# DBHost=localhost'

line: 'DBHost=localhost'

- name: edit zabbix dbpasswd

lineinfile:

dest: /etc/zabbix/zabbix_server.conf

regexp: '# DBPassword='

line: 'DBPassword=zabbix'

- name: cp zabbix web

shell: cp -a /usr/share/zabbix/* /var/www/html/

- name: chmod web

shell: chmod 755 -R /var/www/html/*

- name: chown web

shell: chown apache.apache -R /var/www/html/*

- name: set php

shell: echo "date.timezone = Asia/Shanghai" >> /etc/php.ini

- name: set php

shell: echo "max_execution_time = 300" >> /etc/php.ini

- name: set php

shell: echo "max_input_time = 300" >> /etc/php.ini

- name: set php

shell: echo "post_max_size = 32M" >> /etc/php.ini

- name: set php

shell: echo "memory_limit = 128M" >> /etc/php.ini

- name: set php

shell: echo "mbstring.func_overload = 0" >> /etc/php.ini

- name: start http mysql zabbix

shell: systemctl restart httpd ; systemctl restart mariadb

- name: start http mysql zabbix

shell: systemctl restart zabbix-server ; systemctl restart zabbix-agent

- name: enabled http mysql zabbix

shell: systemctl enable httpd ; systemctl enable mariadb

- name: start http mysql zabbix

shell: systemctl enable zabbix-server ; systemctl enable zabbix-agent

配置檔案檢查:

ansible-playbook site.yml -i hosts --syntax-check

3、安裝過程

ansible-playbook site.yml -i hosts --tags "zabbix_server"

php調取 zabbix實時資料_ansible-playbook實戰之自動化部署zabbix_server監控1、建立roles目錄2、roles基本配置3、安裝過程4、浏覽器驗證

如上,安裝成功。

4、浏覽器驗證

http://192.168.52.17

php調取 zabbix實時資料_ansible-playbook實戰之自動化部署zabbix_server監控1、建立roles目錄2、roles基本配置3、安裝過程4、浏覽器驗證

繼續閱讀