Hi everyone I have a question. How does we set a variable for database in mysql_ . . .

Nguyễn Vi:
Hi everyone
I have a question. How does we set a variable for database in mysql_user module? Because I can’t see any database when I login mysql with user demo

---
    - hosts: db_and_web_srv_1
      vars:
        - db: demo
        - user_db: demo
        - password: abcdef
      tasks:
        - name: Create database
          mysql_db: name={{ db }} state=present
        - name: Create user database
          mysql_user:
            name: '{{ user_db }}'
            password: '{{ password }}'
            priv:
              "'{{ db }}'.*": "ALL,GRANT"
            state: present

Al West:
What is your output when you run this playbook?

Al West:
You have too many quotes in your priv line. Should be:

 priv: "{{ db }}.*:ALL,GRANT"

Al West:
@Nguyễn Vi it always comes to quoting and escaping in development - of course if it isn’t DNS.

Nguyễn Vi:
You are right, I have tried this and it work

Nguyễn Vi:
Thank you :clap: