简体   繁体   中英

zcat failing in ansible-playbook

I am trying to import the schema it is failing , please suggest me to solve this error

- name: Import the initial schema
  command: zcat /usr/share/doc/zabbix-server-mysql-3.2.5/create.sql.gz | mysql -uzabbix -p zabbix

TASK: [zabbix-server | Import the initial schema] *****************************
failed: [10.100.140.120] => {"changed": true, "cmd": ["zcat", "/usr/share/doc/zabbix-server-mysql-3.2.5/create.sql.gz", "|", "mysql", "-u", "zabbix", "-p", "zabbix",   "zabbix"], "delta": "0:00:00.003563", "end": "2017-05-01 11:03:46.004996", "rc": 1, "start": "2017-05-01 11:03:46.001433", "warnings": []}
stderr: gzip: invalid option -- 'u'
Try `gzip --help' for more information.

My log shows that zabbix.users does not exist

3862:20170501:112105.959 using configuration file: /etc/zabbix/zabbix_server.conf
  3862:20170501:112105.962 [Z3005] query failed: [1146] Table 'zabbix.users' doesn't exist [select userid from users limit 1]
  3862:20170501:112105.962 cannot use database "zabbix": database is not a Zabbix database
  3913:20170501:112116.213 Starting Zabbix Server. Zabbix 3.2.5 (revision 67445).

Ansible's command module does not support shell | pipes or things like it, only simple commands and arguments. You'd need to use the shell module or even better, copy the create.sql.gz file over to the host then use the mysql_db module which features state: import .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM