---
# file: roles/mysql-client/tasks/main.yml

- name: MySQL Client Role
  set_fact:
    role_mysql_client_started: yes
  tags:
    - always

- block:

    - name: MySQL Client | Install required packages
      apt:
        pkg: '{{ packages }}'
        state: present
      vars:
        packages:
          - mysql-client
          - mytop

    - name: MySQL Client | Config for easy access for admins
      template:
        src: admin_my_cnf
        dest: /home/{{ item }}/.my.cnf
        owner: '{{ item }}'
        group: root
        mode: 0644
      with_items: '{{ admins }}'

    - name: MySQL Client | Config for easy access for root
      template:
        src: admin_my_cnf
        dest: /root/.my.cnf
        owner: root
        group: root
        mode: 0644

  when: not excluded_roles or "mysql-client" not in excluded_roles
