Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
WIP: Don't use 'puppetlabs-mysql' plugin to create MySQL db/users
Browse files Browse the repository at this point in the history
The MySQL db admin machines are throwing a SQL syntax error when
puppet tries to create the database user. The error is below, with
the password hash omitted:

```
Error: /Stage[main]/Govuk::Apps::Collections_publisher::Db/Mysql::Db[collections_publisher_production]/Mysql_user[collections_pub@%]/ensure: change from absent to present failed: Execution of '/usr/bin/mysql --defaults-extra-file=/root/.my.cnf --database=mysql -e CREATE USER 'collections_pub'@'%' IDENTIFIED BY PASSWORD '(omitted)'' returned 1: ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PASSWORD '(omitted)'' at line 1
```

It looks like 5.6 allowed the IDENTIFIED BY PASSWORD syntax:
https://dev.mysql.com/doc/refman/5.6/en/create-user.html

But 8.0 is just IDENTIFIED BY:
https://dev.mysql.com/doc/refman/8.0/en/create-user.html

And that doesn't look overridable in the puppet module:
https://github.com/puppetlabs/puppetlabs-mysql/blob/a48069e89a4c06abccbb3595d2c782c7cd6e3254/lib/puppet/provider/mysql_user/mysql.rb#L66-L78

puppetlabs-mysql dropped support for the Puppet version we use
before they put in [the fix](puppetlabs/puppetlabs-mysql#1092)
for creating users with MySQL 8, so upgrading is not an option.
  • Loading branch information
ChrisBAshton committed Dec 17, 2021
1 parent db475e7 commit aed4b60
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 91 deletions.
10 changes: 0 additions & 10 deletions modules/govuk/manifests/apps/collections_publisher/db.pp

This file was deleted.

19 changes: 0 additions & 19 deletions modules/govuk/manifests/apps/contacts/db.pp

This file was deleted.

11 changes: 0 additions & 11 deletions modules/govuk/manifests/apps/release/db.pp

This file was deleted.

10 changes: 0 additions & 10 deletions modules/govuk/manifests/apps/search_admin/db.pp

This file was deleted.

11 changes: 0 additions & 11 deletions modules/govuk/manifests/apps/signon/db.pp

This file was deleted.

18 changes: 0 additions & 18 deletions modules/govuk/manifests/apps/whitehall/db.pp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
content => template('govuk/mysql_my.cnf.erb'),
}

# include all MySQL classes that create databases and users
-> class { '::govuk::apps::collections_publisher::db': }
# TODO: automate - or document how to - create the MySQL DB & user
# mysql::db {'collections_publisher_production':
# user => 'collections_pub',
# host => '%',
# password => $mysql_password,
# }
}
8 changes: 6 additions & 2 deletions modules/govuk/manifests/node/s_contacts_admin_db_admin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
content => template('govuk/mysql_my.cnf.erb'),
}

# include all MySQL classes that create databases and users
-> class { '::govuk::apps::contacts::db': }
# TODO: automate - or document how to - create the MySQL DB & user
# mysql::db { 'contacts_production':
# user => 'contacts',
# host => '%',
# password => $mysql_contacts_admin,
# }
}
8 changes: 6 additions & 2 deletions modules/govuk/manifests/node/s_release_db_admin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
content => template('govuk/mysql_my.cnf.erb'),
}

# include all MySQL classes that create databases and users
-> class { '::govuk::apps::release::db': }
# TODO: automate - or document how to - create the MySQL DB & user
# mysql::db {'release_production':
# user => 'release',
# host => '%',
# password => $mysql_release,
# }
}
8 changes: 6 additions & 2 deletions modules/govuk/manifests/node/s_search_admin_db_admin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
content => template('govuk/mysql_my.cnf.erb'),
}

# include all MySQL classes that create databases and users
-> class { '::govuk::apps::search_admin::db': }
# TODO: automate - or document how to - create the MySQL DB & user
# mysql::db {'search_admin_production':
# user => 'search_admin',
# host => '%',
# password => $mysql_search_admin,
# }
}
8 changes: 6 additions & 2 deletions modules/govuk/manifests/node/s_signon_db_admin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
content => template('govuk/mysql_my.cnf.erb'),
}

# include all MySQL classes that create databases and users
-> class { '::govuk::apps::signon::db': }
# TODO: automate - or document how to - create the MySQL DB & user
# mysql::db {'signon_production':
# user => 'signon',
# host => '%',
# password => $mysql_signonotron,
# }
}
14 changes: 12 additions & 2 deletions modules/govuk/manifests/node/s_whitehall_db_admin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
content => template('govuk/mysql_my.cnf.erb'),
}

# include all MySQL classes that create databases and users
-> class { '::govuk::apps::whitehall::db': }
# TODO: automate - or document how to - create the MySQL DB & user(s)
# mysql::db { 'whitehall_production':
# user => 'whitehall',
# host => '%',
# password => $mysql_whitehall_admin,
# }
# govuk_mysql::user { 'whitehall_fe@%':
# password_hash => mysql_password($whitehall_fe_password),
# table => 'whitehall_production.*',
# privileges => ['SELECT'],
# require => Mysql::Db['whitehall_production'],
# }
}

0 comments on commit aed4b60

Please sign in to comment.