diff --git a/tasks/main.yml b/tasks/main.yml index c5352c0..f33c286 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -25,6 +25,10 @@ - include: setup-Debian.yml when: ansible_os_family == 'Debian' +- name: Check if MySQL packages were installed. + set_fact: + mysql_install_packages: "{{ rh_mysql_install_packages.changed or deb_mysql_install_packages.changed }}" + # Configure MySQL. - include: configure.yml - include: secure-installation.yml diff --git a/tasks/secure-installation.yml b/tasks/secure-installation.yml index b8a786a..0fa98d9 100644 --- a/tasks/secure-installation.yml +++ b/tasks/secure-installation.yml @@ -11,7 +11,7 @@ mysql -u root -NBe 'SET PASSWORD FOR "{{ mysql_root_username }}"@"{{ item }}" = PASSWORD("{{ mysql_root_password }}");' with_items: mysql_root_hosts.stdout_lines - when: mysql_install_packages.changed or mysql_root_password_update + when: mysql_install_packages or mysql_root_password_update # Has to be after the root password assignment, for idempotency. - name: Copy .my.cnf file with root password credentials. @@ -35,4 +35,4 @@ with_items: mysql_anonymous_hosts.stdout_lines - name: Remove MySQL test database. - mysql_db: "name='test' state=absent" \ No newline at end of file + mysql_db: "name='test' state=absent" diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index bf13a30..fb050ed 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -13,7 +13,7 @@ - name: Ensure MySQL packages are installed. apt: "name={{ item }} state=installed" with_items: mysql_packages - register: mysql_install_packages + register: deb_mysql_install_packages # Because Ubuntu starts MySQL as part of the install process, we need to stop # mysql and remove the logfiles in case the user set a custom log file size. diff --git a/tasks/setup-RedHat.yml b/tasks/setup-RedHat.yml index b4ee1a9..5125ce2 100644 --- a/tasks/setup-RedHat.yml +++ b/tasks/setup-RedHat.yml @@ -5,4 +5,4 @@ - name: Ensure MySQL packages are installed. yum: "name={{ item }} state=installed enablerepo={{ mysql_enablerepo }}" with_items: mysql_packages - register: mysql_install_packages + register: rh_mysql_install_packages