Ansible 2.7 – thesql_db : ngzip: stdout: Broken pipe\

ansible

Using the following instructions, fails the restoration of the database. As i read, archived not supports gz files, should i use a bash script?

- name: Restore database
        mysql_db:
          name: zabbixdb
          state: import
          target: /usr/share/doc/zabbix-server-mysql-4.0.3/create.sql.gz
        when: ansible_distribution == 'CentOS'

      - name: Restore database
        mysql_db:
          name: zabbixdb
          state: import
          target: /usr/share/doc/zabbix-server-mysql/create.sql.gz
        when: ansible_distribution == 'Debian'

result

fatal: [192.168.1.215]: FAILED! => {"changed": false, "msg": "\ngzip: stdout: Broken pipe\n"}

Best Answer

This sounds like (as of February 2019, umerged) PR 26504 Fixes #20196 broken pipe when special chars in mysql password.

Try (temporarily) setting the mysql password to something alphanumeric, avoiding special to the shell characters like !.

If you continue to get errors, set the playbook debugger on the problem task: debugger: on_failed. Then dump out the mysql command variable, which you can run manually in the shell to find the problem.