From 44b2720b3e3c6392ce7ea9827c328cfb69198be8 Mon Sep 17 00:00:00 2001 From: jorgepastorr Date: Tue, 19 Sep 2023 13:54:56 +0200 Subject: [PATCH] change update user password on mysql --- orchestra/contrib/databases/backends.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/orchestra/contrib/databases/backends.py b/orchestra/contrib/databases/backends.py index ca48ff03..327f9461 100644 --- a/orchestra/contrib/databases/backends.py +++ b/orchestra/contrib/databases/backends.py @@ -89,20 +89,12 @@ class MySQLUserController(ServiceController): if user.type != user.MYSQL: return context = self.get_context(user) - if user.target_server.name != "mysql.pangea.lan": - self.append(textwrap.dedent("""\ - # Create user %(username)s - mysql -e 'CREATE USER IF NOT EXISTS "%(username)s"@"%(host)s";' - mysql -e 'ALTER USER IF EXISTS "%(username)s"@"%(host)s" IDENTIFIED BY PASSWORD "%(password)s";'\ - """) % context - ) - else: - self.append(textwrap.dedent("""\ - # Create user %(username)s - mysql -e 'CREATE USER "%(username)s"@"%(host)s";' || true # User already exists - mysql -e 'UPDATE mysql.user SET Password="%(password)s" WHERE User="%(username)s";'\ - """) % context - ) + self.append(textwrap.dedent("""\ + # Create user %(username)s + mysql -e 'CREATE USER IF NOT EXISTS "%(username)s"@"%(host)s";' + mysql -e 'ALTER USER IF EXISTS "%(username)s"@"%(host)s" IDENTIFIED BY PASSWORD "%(password)s";'\ + """) % context + ) def delete(self, user): if user.type != user.MYSQL: