aboutsummaryrefslogtreecommitdiffstats
path: root/manifests/profile/base/database/mysql
diff options
context:
space:
mode:
authorDamien Ciabrini <dciabrin@redhat.com>2017-07-03 05:15:56 -0400
committerDamien Ciabrini <dciabrin@redhat.com>2017-07-12 04:08:05 -0400
commit764157de6f222e0e5698cdcf7b22926b7997fcb8 (patch)
tree322f3e0397fced2eaa989d01a20193f6252fc0c9 /manifests/profile/base/database/mysql
parent096e913306584baaf0fd2e7bb4951ecb23f370ac (diff)
Fix mysql client config generation with containerized environment
When the tripleo::profile::base::database::mysql::client profile is included by other openstack services, the file /etc/my.cnf.d/tripleo.cnf is not generated because docker-puppet is configured to disregard the exec tags. Make the profile use either File or Exec resource based on how it's being called, to make it work for both containerized and non-containerized use cases. Change-Id: I103baa02373f6713cc300ac039a6f173ff0bbf1c
Diffstat (limited to 'manifests/profile/base/database/mysql')
-rw-r--r--manifests/profile/base/database/mysql/client.pp39
1 files changed, 27 insertions, 12 deletions
diff --git a/manifests/profile/base/database/mysql/client.pp b/manifests/profile/base/database/mysql/client.pp
index 1e55f05..68d524b 100644
--- a/manifests/profile/base/database/mysql/client.pp
+++ b/manifests/profile/base/database/mysql/client.pp
@@ -53,13 +53,6 @@ class tripleo::profile::base::database::mysql::client (
$step = Integer(hiera('step')),
) {
if $step >= 1 {
- # If the folder /etc/my.cnf.d does not exist (e.g. if mariadb is not
- # present in the base image but installed as a package afterwards),
- # create it. We do not want to touch the permissions in case it already
- # exists due to the mariadb server package being pre-installed
- # Note: We use exec instead of file in the case that the mysql class is
- # included on this node as well (we'd get duplicate declaration in such a
- # situation when using file)
if $mysql_client_bind_address {
$client_bind_changes = [
"set ${mysql_read_default_group}/bind-address '${mysql_client_bind_address}'"
@@ -85,15 +78,37 @@ class tripleo::profile::base::database::mysql::client (
$conf_changes = union($client_bind_changes, $changes_ssl)
# Create /etc/my.cnf.d/tripleo.cnf
- exec { 'directory-create-etc-my.cnf.d':
- command => 'mkdir -p /etc/my.cnf.d',
- unless => 'test -d /etc/my.cnf.d',
- path => ['/usr/bin', '/usr/sbin', '/bin', '/sbin'],
- } ->
+ # If the folder /etc/my.cnf.d does not exist (e.g. if mariadb is not
+ # present in the base image but installed as a package afterwards),
+ # create it. We do not want to touch the permissions in case it already
+ # exists due to the mariadb server package being pre-installed
+ if $::uuid == 'docker' {
+ # When generating configuration with docker-puppet, services do
+ # not include any profile that would ensure creation of /etc/my.cnf.d,
+ # so we enforce the check here.
+ file {'/etc/my.cnf.d':
+ ensure => 'directory'
+ }
+ } else {
+ # Otherwise, depending on the role, puppet may run this profile
+ # concurrently with the mysql profile, so we use an exec resource
+ # in order to avoid getting duplicate declaration errors
+ exec { 'directory-create-etc-my.cnf.d':
+ command => 'mkdir -p /etc/my.cnf.d',
+ unless => 'test -d /etc/my.cnf.d',
+ path => ['/usr/bin', '/usr/sbin', '/bin', '/sbin'],
+ before => Augeas['tripleo-mysql-client-conf']
+ }
+ }
+
augeas { 'tripleo-mysql-client-conf':
incl => $mysql_read_default_file,
lens => 'Puppet.lns',
changes => $conf_changes,
}
+
+ # If a profile created a file resource for the parent directory,
+ # ensure it is being run before the config file generation
+ File<| title == '/etc/my.cnf.d' |> -> Augeas['tripleo-mysql-client-conf']
}
}