ansible部署zabbix

--- 
- name: copy epel yum source
  copy: src={{ item.src }} dest={{ item.dest }} owner=root group=root mode=644
  with_items:
  - {src: mariadb.repo, dest: /etc/yum.repos.d/mariadb.repo}


- name: copy rpm package dcs
  copy: src={{ item.src }} dest={{ item.dest }} owner=root group=root mode=644
  with_items:
  - {src: MariaDB-10.2.13-centos73-x86_64-server.rpm,dest: /tmp/MariaDB-10.2.13-centos73-x86_64-server.rpm}
  - {src: MariaDB-10.2.13-centos73-x86_64-client.rpm,dest: /tmp/MariaDB-10.2.13-centos73-x86_64-client.rpm}


- name: yum install Mariadb
  shell: yum -y localinstall /tmp/*.rpm




                                 
- name: 关闭Selinux
  shell: sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
- name: 临时关闭SELINUX
  shell: setenforce 0


- name: 安装httpd
  yum: name={{ item }} state=present
  with_items:
  - httpd
  - httpd-devel




#安装前先不用安装php,zabbix应该是php5.4
- name: install zabbix repo
  shell: rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm


- name: yum install zabbix server
  yum: name={{ item }} state=present
  with_items:
  - zabbix-server-mysql
  - zabbix-web-mysql
  - zabbix-agent


- name: start mysqld
  service: name=mysqld state=started enabled=yes


- name: Set mysql admin password
  shell: /usr/bin/mysqladmin -uroot password '123456'


- name: Create zabbix master databases
  shell: mysql -uroot -p123456 -e 'create database zabbix_master character set utf8 collate utf8_bin;'


- name: Set Zabbix Master databases grant
  shell: mysql -uroot -p123456 -e 'grant all privileges on zabbix_master.* to zabbix@localhost identified by "master";'


- name: Import zabbix initial data (schema.sql)
  shell: zcat /usr/share/doc/zabbix-server-mysql-3.4.7/create.sql.gz | mysql -uzabbix -pmaster zabbix_master


- name: cop zabbix_server.conf
  copy: src=zabbix_server.conf dest=/etc/zabbix/zabbix_server.conf owner=root group=root mode=644


- name: 设置时区
  shell: sed -i 'N;14a\        php_value date.timezone Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf


- name: start zabbix-server and httpd
  service: name={{ item }} state=started enabled=yes
  with_items:
  - zabbix-server
  - httpd
  

你可能感兴趣的:(ansible部署zabbix)