3

I'm trying to ignore a particular error message in playbook output is having below error message.

fatal: [192.168.0.1]: FAILED! => {"changed": false, "failed": true, "msg": "Sending passwords in plain text without SSL/TLS is extremely insecure.. Query == CHANGE MASTER TO ['MASTER_HOST=%(master_host)s', 'MASTER_USER=%(master_user)s', 'MASTER_PASSWORD=%(master_password)s', 'MASTER_LOG_FILE=%(master_log_file)s', 'MASTER_LOG_POS=%(master_log_pos)s']"}

> Task: 
> - name: Setup Replication   
    become: true   
    mysql_replication:
>      login_host: "{{ slave_ip }}"
>      login_user: "user"
>      login_password: "***"
>      mode: changemaster
>      master_host: "{{ master_ip }}"
>      master_log_file: mysql-bin.000001
>      master_log_pos: 107
>      master_user: "{{ mysql_replicator_user }}"
>      master_password: "{{ mysql_replicator_password }}"

Any luck? how to achieve this?

EDITED: Reply to Marco Answer - well that is the problem here, I would not know what error I might get. But I'm sure that if err msg contains "Sending passwords in plain text without SSL" then ignore if not and anyother error then don't ignore. To explain in simple "Throw exception if error msg doesn't contain -> 'null' or SSL."

6

There are a couple of options regarding error handling in Ansible. You could use ignore_errors: yes attribute on your task. If you don't want to ignore all errors, you can specify what exactly constitutes an error using something like:

- name: task name
  module: arguments ...
  register: out
  failed_when: 'error message' in out.stderr 

If you want to add more complex failure checks, you can split error handling off into separate task like this:

- name: test
  shell: echo error; exit 123
  register: out
  ignore_errors: yes

- fail: msg="{{ out.stdout }}"
  when: "out.rc != 0 and 'error' not in out.stdout"

In this example first task fails with return code 123 and prints "error" on it's standard output. This will be registered, but ignored. Second task analyzes output values and fails only if return code is different than zero AND standard output does NOT contain string "error".

You can read more details in Ansible documentation: https://docs.ansible.com/ansible/playbooks_error_handling.html

  • well that is the problem here, I would not know what error I might get. But I'm sure that if err msg contains "Sending passwords in plain text without SSL" then ignore if not and anyother error then don't ignore. To explain in simple "Throw exception if error msg doesn't contain -> 'null' or SSL." – mannoj Apr 4 '17 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.