Skip to content

Commit

Permalink
Update conditions for MySQL removal in destroy role
Browse files Browse the repository at this point in the history
The conditions to execute the MySQL database and user removal tasks in the Ansible role have been updated. Now, these tasks will run not only when 'mysql.service' is present in ansible_facts.services, but also when 'app_mysql_database' or 'app_mysql_user' are defined. This ensures more robust removal when cleaning apps.
  • Loading branch information
nbejansen committed Jan 17, 2024
1 parent d2df148 commit 9b6ffa8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions roles/app/destroy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,19 @@
name: "{{ app_mysql_database }}"
state: absent
login_unix_socket: "{{ mysql_unix_socket }}"
when: "'mysql.service' in ansible_facts.services"
when:
- app_mysql_database
- "'mysql.service' in ansible_facts.services"

- name: Remove mysql database user.
community.mysql.mysql_user:
name: "{{ app_mysql_user }}"
state: absent
host: "%"
login_unix_socket: "{{ mysql_unix_socket }}"
when: "'mysql.service' in ansible_facts.services"
when:
- app_mysql_user
- "'mysql.service' in ansible_facts.services"

- name: Flush handlers.
ansible.builtin.meta: flush_handlers
Expand Down

0 comments on commit 9b6ffa8

Please sign in to comment.