From d53004c16cc9b6c5e09e64b752ae02900f9913eb Mon Sep 17 00:00:00 2001 From: handreas <andreas.hamacher@monash.edu> Date: Tue, 19 Jan 2021 05:24:44 +0000 Subject: [PATCH] well it does not get more ugly than his :( I don't have a reliable way of getting this working so I am leaving residuals of debbuging and workaround code --- roles/mysql/tasks/CentOS_7_mysql_server.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/roles/mysql/tasks/CentOS_7_mysql_server.yml b/roles/mysql/tasks/CentOS_7_mysql_server.yml index b01abeb4..f129eccf 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] -- GitLab