Exemple #1
0
def install_tmpfilesd():
    '''Install systemd-tmpfiles configuration for ovs vhost-user sockets'''
    # NOTE(jamespage): Only do this if libvirt is actually installed
    if (init_is_systemd() and user_exists('libvirt-qemu')
            and group_exists('kvm')):
        shutil.copy('files/nova-ovs-vhost-user.conf', '/etc/tmpfiles.d')
        subprocess.check_call(['systemd-tmpfiles', '--create'])
def _install_mattermost():
    # Backup existing installation if it exists
    backup_path = None
    if os.path.isdir('/opt/mattermost'):
        backup_path = "/opt/mattermost.back{}".format(str(datetime.datetime.now()))
        shutil.move('/opt/mattermost', backup_path)
    # Create mattermost user & group if not exists
    if not group_exists('mattermost'):
        add_group("mattermost")
    if not user_exists('mattermost'):
        adduser("mattermost", system_user=True)
    # Get and uppack resource
    mattermost_bdist = resource_get('bdist')
    extract_tarfile(mattermost_bdist, destpath="/opt")

    # Render systemd template
    render(source="mattermost.service.tmpl",
           target="/etc/systemd/system/mattermost.service",
           perms=0o644,
           owner="root",
           context={})
    check_call(['systemctl', 'daemon-reload'])
    if backup_path:
        shutil.move(
            '{}/config/config.json'.format(backup_path),
            '/opt/mattermost/config/config.json')
        shutil.move(
            '{}/data'.format(backup_path),
            '/opt/mattermost/')
    # Create dirs that don't exist yet
    for folder in ("data", "logs", "config"):
        os.makedirs("/opt/mattermost/{}".format(folder),
                    mode=0o700,
                    exist_ok=True)
    chownr("/opt/mattermost", "mattermost", "mattermost", chowntopdir=True)
def create_user_and_group_if_not_exists(user, group):
    """Create documize user & group if not exists
    """
    if not group_exists(group):
        add_group(group)
    if not user_exists(user):
        adduser(user, system_user=True)
Exemple #4
0
def _install_mattermost():
    # Backup existing installation if it exists
    backup_path = None
    if os.path.isdir('/opt/mattermost'):
        backup_path = "/opt/mattermost.back{}".format(
            str(datetime.datetime.now()))
        shutil.move('/opt/mattermost', backup_path)
    # Create mattermost user & group if not exists
    if not group_exists('mattermost'):
        add_group("mattermost")
    if not user_exists('mattermost'):
        adduser("mattermost", system_user=True)
    # Get and uppack resource
    mattermost_bdist = resource_get('bdist')
    extract_tarfile(mattermost_bdist, destpath="/opt")

    # Render systemd template
    render(source="mattermost.service.tmpl",
           target="/etc/systemd/system/mattermost.service",
           perms=0o644,
           owner="root",
           context={})
    check_call(['systemctl', 'daemon-reload'])
    if backup_path:
        shutil.move('{}/config/config.json'.format(backup_path),
                    '/opt/mattermost/config/config.json')
        shutil.move('{}/data'.format(backup_path), '/opt/mattermost/')
    # Create dirs that don't exist yet
    for folder in ("data", "logs", "config"):
        os.makedirs("/opt/mattermost/{}".format(folder),
                    mode=0o700,
                    exist_ok=True)
    chownr("/opt/mattermost", "mattermost", "mattermost", chowntopdir=True)
def install_tmpfilesd():
    '''Install systemd-tmpfiles configuration for ovs vhost-user sockets'''
    # NOTE(jamespage): Only do this if libvirt is actually installed
    if (init_is_systemd() and
            user_exists('libvirt-qemu') and
            group_exists('kvm')):
        shutil.copy('files/nova-ovs-vhost-user.conf',
                    '/etc/tmpfiles.d')
        subprocess.check_call(['systemd-tmpfiles', '--create'])
def create_prometheus_user():
    if not group_exists('prometheus'):
        add_group('prometheus', system_group=True)
    if not user_exists('prometheus'):
        adduser(
            'prometheus',
            shell='/bin/false',
            system_user=True,
            primary_group='prometheus',
            home_dir='/var/lib/prometheus',
        )
    set_state('prometheus.user.available')
 def configure_installdir(self):
     ''' Create and fix permissions on install dir'''
     if not os.path.exists(self.installdir):
         os.makedirs(self.installdir)
     hookenv.log("Fixing data dir permissions: {}".format(
         self.installdir), 'DEBUG')
     if host.user_exists(self.user) and host.group_exists(self.user):
         host.chownr(self.installdir, self.user,
                     self.user, chowntopdir=True)
     else:
         hookenv.log("Skipping chown because user/group {} is missing".format(
             self.installdir), 'DEBUG')
def install_mattermost():
    """Grab the mattermost binary, unpack, install
    to /srv.
    """

    status_set('maintenance', "Installing Mattermost")

    # Create mattermost user & group if not exists
    if not group_exists('mattermost'):
        add_group("mattermost")
    if not user_exists('mattermost'):
        adduser("mattermost", system_user=True)

    # Get and uppack resource
    if os.path.exists('/srv/mattermost'):
        shutil.rmtree('/srv/mattermost')

    mattermost_bdist = resource_get('bdist')
    extract_tarfile(mattermost_bdist, destpath="/srv")

    # Create data + log + config dirs
    for dir in ("data", "logs", "config"):
        os.makedirs(os.path.join("/srv/mattermost", dir),
                    mode=0o700,
                    exist_ok=True)
        shutil.chown(os.path.join("/srv/mattermost", dir),
                     user="******",
                     group="mattermost")

    # Render systemd template
    render(source="mattermost.service.tmpl",
           target="/etc/systemd/system/mattermost.service",
           perms=0o644,
           owner="root",
           context={})
    check_call(['systemctl', 'daemon-reload'])
    set_state('mattermost.installed')
    status_set('active', 'Mattermost installation complete')