Deal with new in-distro stuff
This commit is contained in:
parent
e736923671
commit
4de9fb2fe2
|
@ -1,4 +1,7 @@
|
|||
options:
|
||||
source:
|
||||
type: string
|
||||
description: Package install location for Percona XtraDB Cluster (defaults to distro for >= 14.04)
|
||||
dataset-size:
|
||||
default: '80%'
|
||||
type: string
|
||||
|
|
|
@ -21,6 +21,7 @@ except ImportError:
|
|||
|
||||
|
||||
class MySQLHelper():
|
||||
|
||||
def __init__(self, host='localhost'):
|
||||
self.host = host
|
||||
|
||||
|
@ -120,13 +121,13 @@ def get_mysql_password(username=None, password=None):
|
|||
else:
|
||||
mkdir(os.path.dirname(_passwd_file),
|
||||
owner='root', group='root',
|
||||
perms=0770)
|
||||
perms=0o770)
|
||||
# Force permissions - for some reason the chmod in makedirs fails
|
||||
os.chmod(os.path.dirname(_passwd_file), 0770)
|
||||
os.chmod(os.path.dirname(_passwd_file), 0o770)
|
||||
_password = password or pwgen(length=32)
|
||||
write_file(_passwd_file, _password,
|
||||
owner='root', group='root',
|
||||
perms=0660)
|
||||
perms=0o660)
|
||||
return _password
|
||||
|
||||
|
||||
|
|
|
@ -19,11 +19,13 @@ from charmhelpers.core.hookenv import (
|
|||
from charmhelpers.core.host import (
|
||||
service_restart,
|
||||
file_hash,
|
||||
write_file
|
||||
write_file,
|
||||
lsb_release
|
||||
)
|
||||
from charmhelpers.fetch import (
|
||||
apt_update,
|
||||
apt_install,
|
||||
add_source,
|
||||
)
|
||||
from percona_utils import (
|
||||
PACKAGES,
|
||||
|
@ -56,7 +58,11 @@ hooks = Hooks()
|
|||
|
||||
@hooks.hook('install')
|
||||
def install():
|
||||
setup_percona_repo()
|
||||
if config('source') is None and \
|
||||
lsb_release()['DISTRIB_CODENAME'] < 'trusty':
|
||||
setup_percona_repo()
|
||||
elif config('source') is not None:
|
||||
add_source(config('source'))
|
||||
configure_mysql_root_password(config('root-password'))
|
||||
render_config() # Render base configuation (no cluster)
|
||||
apt_update(fatal=True)
|
||||
|
@ -78,7 +84,7 @@ def render_config(clustered=False, hosts=[]):
|
|||
context.update(parse_config())
|
||||
write_file(path=MY_CNF,
|
||||
content=render_template(os.path.basename(MY_CNF), context),
|
||||
perms=0444)
|
||||
perms=0o444)
|
||||
|
||||
|
||||
@hooks.hook('cluster-relation-joined')
|
||||
|
@ -235,7 +241,7 @@ def ha_relation_joined():
|
|||
resource_params = {
|
||||
'res_mysql_vip': 'params ip="%s" cidr_netmask="%s" nic="%s"' %
|
||||
(vip, vip_cidr, vip_iface),
|
||||
}
|
||||
}
|
||||
groups = {'grp_percona_cluster': 'res_mysql_vip'}
|
||||
|
||||
for rel_id in relation_ids('ha'):
|
||||
|
|
|
@ -111,12 +111,15 @@ def configure_sstuser(sst_password):
|
|||
def configure_mysql_root_password(password):
|
||||
''' Configure debconf with root password '''
|
||||
dconf = Popen(['debconf-set-selections'], stdin=PIPE)
|
||||
package = "percona-server-server"
|
||||
# Set both percona and mysql password options to cover
|
||||
# both upstream and distro packages.
|
||||
packages = ["percona-server-server", "mysql-server"]
|
||||
root_pass = get_mysql_root_password(password)
|
||||
dconf.stdin.write("%s %s/root_password password %s\n" %
|
||||
(package, package, root_pass))
|
||||
dconf.stdin.write("%s %s/root_password_again password %s\n" %
|
||||
(package, package, root_pass))
|
||||
for package in packages:
|
||||
dconf.stdin.write("%s %s/root_password password %s\n" %
|
||||
(package, package, root_pass))
|
||||
dconf.stdin.write("%s %s/root_password_again password %s\n" %
|
||||
(package, package, root_pass))
|
||||
dconf.communicate()
|
||||
dconf.wait()
|
||||
|
||||
|
|
Loading…
Reference in New Issue