--- - name: set fact tls_enabled command: "{{ mysql_command }} \"-e SHOW VARIABLES LIKE 'have_ssl';\"" register: result - set_fact: tls_enabled: "{{ 'YES' in result.stdout | bool | default('false', true) }}" - vars: mysql_parameters: &mysql_params login_user: '{{ mysql_user }}' login_password: '{{ mysql_password }}' login_host: 127.0.0.1 login_port: '{{ mysql_primary_port }}' when: tls_enabled block: # ============================================================ - name: get server certificate copy: content: "{{ lookup('pipe', \"openssl s_client -starttls mysql -connect localhost:3307 -showcerts 2>/dev/null = 0.7.11 is required' in result.msg - name: Drop mysql user mysql_user: <<: *mysql_params name: '{{ item }}' host: 127.0.0.1 state: absent with_items: - "{{ user_name_1 }}" - "{{ user_name_2 }}"