diff --git a/roles/mysql/tasks/CentOS_7_mysql_server.yml b/roles/mysql/tasks/CentOS_7_mysql_server.yml index b01abeb4b68068df19e8928fe64f57eac15f7353..f129eccf328aeb79e5cb75b09e281511bbe2b1a0 100644 --- a/roles/mysql/tasks/CentOS_7_mysql_server.yml +++ b/roles/mysql/tasks/CentOS_7_mysql_server.yml @@ -52,7 +52,16 @@ mysql_user: name={{ mysql_user_name }} host={{ mysql_user_host }} password={{ mysql_user_password }} login_user=root login_password={{ mysql_root_password }} priv={{ mysql_user_db_name }}.*:ALL,GRANT state=present when: mysql_user_host is defined -- name: "Giving priviliges to user with fqdn" +- name: "Giving priviliges to user with shortname" + mysql_user: name={{ mysql_user_name }} host={{ item }} password={{ mysql_user_password }} login_user=root login_password={{ mysql_root_password }} priv={{ mysql_user_db_name }}.*:ALL,GRANT state=present + with_items: "{{ mysql_user_hosts_group }}" + when: mysql_user_hosts_group is defined + +- name: "Giving priviliges to user with hardcoded hostname" + mysql_user: name={{ mysql_user_name }} host='HARDCODE YOUR HOSTNAME' password={{ mysql_user_password }} login_user=root login_password={{ mysql_root_password }} priv={{ mysql_user_db_name }}.*:ALL,GRANT state=present + tags: [never] + +- name: "Giving priviliges to user with fdqn works only when run with --limit=ManagementNodes,SQLNodes" mysql_user: name={{ mysql_user_name }} host={{ hostvars[item].ansible_fqdn }} password={{ mysql_user_password }} login_user=root login_password={{ mysql_root_password }} priv={{ mysql_user_db_name }}.*:ALL,GRANT state=present with_items: "{{ mysql_user_hosts_group }}" when: mysql_user_hosts_group is defined @@ -65,3 +74,8 @@ - name: "Giving priviliges to user with item.domain" mysql_user: name={{ mysql_user_name }} host="{{ item }}.{{ domain }}" password={{ mysql_user_password }} login_user=root login_password={{ mysql_root_password }} priv={{ mysql_user_db_name }}.*:ALL,GRANT state=present with_items: "{{ mysql_user_hosts_group }}" + +- debug: + msg: "{{ hostvars[item].ansible_fqdn }}" + with_items: "{{ mysql_user_hosts_group }}" + tags: [never]