--- - name: "check if user already created" stat: path: "{{ mikbill.dirs.tmp }}/user_created" register: user_created - name: "create user percona 8" block: - name: "create user: {{ mikbill.database.users.billing.user }}" shell: "{{ item }}" with_items: - mysql --defaults-file="{{ mikbill.dirs.tmp }}/root.cnf" -e "CREATE USER '{{ mikbill.database.users.billing.user }}'@'localhost' IDENTIFIED WITH caching_sha2_password BY '{{ billing_pass }}';" - mysql --defaults-file="{{ mikbill.dirs.tmp }}/root.cnf" -e "GRANT ALL PRIVILEGES ON {{ mikbill.database.proper.name }}.* TO '{{ mikbill.database.users.billing.user }}'@'localhost' WITH GRANT OPTION;" - mysql --defaults-file="{{ mikbill.dirs.tmp }}/root.cnf" -e "FLUSH PRIVILEGES;" no_log: true when: - user_created.stat.exists == False - OS.database.percona.version == 80 or OS.database.percona.version == 8.0 - name: "create user percona 5.6" block: - name: "create user: {{ mikbill.database.users.billing.user }}" shell: "{{ item }}" with_items: - mysql --defaults-file="{{ mikbill.dirs.tmp }}/root.cnf" -e "CREATE USER '{{ mikbill.database.users.billing.user }}'@'localhost' IDENTIFIED BY '{{ billing_pass }}';" - mysql --defaults-file="{{ mikbill.dirs.tmp }}/root.cnf" -e "GRANT ALL PRIVILEGES ON {{ mikbill.database.proper.name }}.* TO '{{ mikbill.database.users.billing.user }}'@'localhost' WITH GRANT OPTION;" - mysql --defaults-file="{{ mikbill.dirs.tmp }}/root.cnf" -e "FLUSH PRIVILEGES;" no_log: true when: - user_created.stat.exists == False - OS.database.percona.version == 56 or OS.database.percona.version == 5.6 - name: "mark completed" file: path: "{{ mikbill.dirs.tmp }}/user_created" state: touch