I would like to backup MySQL by Ansible.The MySQL password will be encrypted by ansible vault. My question is our company has 5 different passwords for Mysql. Is that possible to let Ansible try the password until mysqldump command was executed successfully (if password-2 works then stop trying password-3,4,5)
- name: Backup MySQL database in all VM
hosts: mysql-group
vars_files:
- /my_ansible_vault_secret
remote_user: ansible
become: true
tasks:
- name: Run mysqldump in the VM
ansible.builtin.shell:
cmd: mysqldump -u root -p{{ password-1 }} --all-databases > mybackup.sql
#### Vault File ###
cat /my_ansible_vault_secret
password-1: password-1
password-2: password-2
password-3: password-3
password-4: password-4
password-5: password-5
I am very new to Ansible, any help is appreciated!