示例#1
0
def install_puppet():
    """ Installs latest Puppet & hiera packages

    Emits:
    puppet.available: Emitted once the runtime has been installed
    """

    # install required puppet modules
    # BIGTOP-2003. A workaround to install newer hiera to get rid of hiera 1.3.0 bug.
    # TODO once Ubuntu trusty fixes version of hiera package, this could be replaced by
    # adding packages: ['puppet'] in layer.yaml options:basic
    try:
        # Ideally the sources should be taken from config.yaml but I can not make it work
        wget = 'wget -O /tmp/puppetlabs-release-trusty.deb https://apt.puppetlabs.com/puppetlabs-release-trusty.deb'
        dpkg = 'dpkg -i /tmp/puppetlabs-release-trusty.deb'
        apt_update = 'apt-get update'
        subprocess.call(wget.split())
        subprocess.call(dpkg.split())
        subprocess.call(apt_update.split())
    except CalledProcessError:
        pass  # All modules are set

    kv.set('puppet.url', config.get('install_sources'))
    kv.set('puppet.key', config.get('install_keys'))

    apt.queue_install(['puppet'])
    apt.install_queued()
示例#2
0
def install_packages(rel=None):
    hookenv.status_set('maintenance', 'Installing software')
    hookenv.log("Installing designate dashboard plugin")
    apt.queue_install(['python-designate-dashboard'])
    apt.install_queued()
    reactive.set_state('python-designate-dashboard.installed')
    rel.set_remote('plugin-ready')
    hookenv.status_set('active', 'Plugin Installed')
示例#3
0
 def install_puppet_apt_pkg(self):
     '''Install puppet pkg/enable srvc
     '''
     hookenv.status_set('maintenance',
                        'Installing %s' % self.puppet_apt_pkg)
     self.install_puppet_apt_src()
     # Queue the installation of appropriate puppet pkgs
     apt.queue_install(self.puppet_apt_pkg)
     apt.install_queued()
 def install_puppet_apt_pkg(self):
     '''Install puppet pkg/enable srvc
     '''
     hookenv.status_set('maintenance',
                        'Installing %s' % self.puppet_apt_pkg)
     self.install_puppet_apt_src()
     # Queue the installation of appropriate puppet pkgs
     apt.queue_install(self.puppet_apt_pkg)
     apt.install_queued()
示例#5
0
def check_version_and_install():
    series = lsb_release()['DISTRIB_CODENAME']
    if not series >= 'xenial':
        log('letsencrypt not supported on series >= %s' % (series))
        status_set('blocked', "Unsupported series < Xenial")
        return
    else:
        apt.queue_install(['letsencrypt'])
        apt.install_queued()
示例#6
0
def check_version_and_install():
    series = lsb_release()['DISTRIB_RELEASE']
    if not series >= '16.04':
        log('letsencrypt not supported on series >= %s' % (series))
        status_set('blocked', "Unsupported series < Xenial")
        return
    else:
        apt.queue_install(['letsencrypt'])
        apt.install_queued()
        # open ports during installation to prevent a scenario where
        # we need to wait for the update-status hook to request
        # certificates because Juju hasn't opened the ports yet and
        # no other hook is queued to run.
        open_port(80)
        open_port(443)
示例#7
0
def install_puppet():
    """Install Puppet packages.

    If the user has configured repos, use them. If not (and we're on trusty),
    use the puppetlabs repo to avoid buggy archive packages. If neither of
    these, install packages using the default system repos.
    """
    distname, version, series = platform.linux_distribution()

    if series == 'trusty' and is_state('config.default.install_sources'):
        # BIGTOP-2003. A workaround to install newer hiera to get rid of
        # hiera 1.3.0 bug.
        apt.add_source('deb http://apt.puppetlabs.com trusty main dependencies',
                       '4BD6EC30')

        apt.update()

    apt.queue_install(['puppet'])
    apt.install_queued()
示例#8
0
def install_limeds():
    apt.add_source('ppa:cwchien/gradle')
    apt.queue_install(['git', 'gradle-2.12'])
    apt.update()
    apt.install_queued()
    service_name = hookenv.local_unit().split('/')[0]
    subprocess.check_call(['hostnamectl', 'set-hostname', ''])
    # Make hostname resolvable
    with open('/etc/hosts', 'a') as hosts_file:
        hosts_file.write('127.0.0.1 {}\n'.format(service_name))
    # Add bitbucket host key so git ssh doesn't request to confirm host key
    with open('/root/.ssh/known_hosts', 'a+') as known_hosts_file:
        known_hosts_file.write(KNOWN_HOSTS)
    if os.path.isdir('/opt/limeds'):
        shutil.rmtree('/opt/limeds')
    keypath = '{}/files/id_rsa'.format(hookenv.charm_dir())
    # Fix bug where permissions of charm files are changed
    subprocess.check_call(['chmod', 'go-r', keypath])
    repo = '[email protected]:ibcndevs/cot-demo.git'
    subprocess.check_call([
        # use ssh-agent to use supplied privkey for git ssh connection
        'ssh-agent',
        'bash',
        '-c',
        # remote 'upstream' will point to supplied given repo
        'ssh-add {}; git clone {} -o upstream /opt/limeds'.format(
            keypath, repo)
    ])
    subprocess.check_call(['gradle', 'jar', 'export'], cwd='/opt/limeds')
    templating.render(
        source='upstart.conf',
        target='/etc/init/limeds.conf',
        context={
            'description':
            'limeds',
            'command':
            'cd /opt/limeds/run/ \njava -jar -Dgosh.args=--nointeractive generated/distributions/executable/cot-demo.jar',
        })
示例#9
0
def install_limeds():
    apt.add_source('ppa:cwchien/gradle')
    apt.queue_install(['git', 'gradle-2.12'])
    apt.update()
    apt.install_queued()
    service_name = hookenv.local_unit().split('/')[0]
    subprocess.check_call(['hostnamectl', 'set-hostname', ''])
    # Make hostname resolvable
    with open('/etc/hosts', 'a') as hosts_file:
        hosts_file.write('127.0.0.1 {}\n'.format(service_name))
    # Add bitbucket host key so git ssh doesn't request to confirm host key
    with open('/root/.ssh/known_hosts', 'a+') as known_hosts_file:
        known_hosts_file.write(KNOWN_HOSTS)
    if os.path.isdir('/opt/limeds'):
        shutil.rmtree('/opt/limeds')
    keypath = '{}/files/id_rsa'.format(hookenv.charm_dir())
    # Fix bug where permissions of charm files are changed
    subprocess.check_call(['chmod', 'go-r', keypath])
    repo = '[email protected]:ibcndevs/cot-demo.git'
    subprocess.check_call([
        # use ssh-agent to use supplied privkey for git ssh connection
        'ssh-agent', 'bash', '-c',
        # remote 'upstream' will point to supplied given repo
        'ssh-add {}; git clone {} -o upstream /opt/limeds'.format(keypath, repo)
    ])
    subprocess.check_call([
        'gradle', 'jar', 'export'
    ], cwd='/opt/limeds')
    templating.render(
        source='upstart.conf',
        target='/etc/init/limeds.conf',
        context={
            'description': 'limeds',
            'command': 'cd /opt/limeds/run/ \njava -jar -Dgosh.args=-nointeractive generated/distributions/executable/cot-demo.jar',
        }
    )
示例#10
0
def install_rest2kafka():
    apt.add_source('ppa:cwchien/gradle')
    apt.queue_install(['python-pip', 'python-dev'])
    apt.update()
    apt.install_queued()
    subprocess.check_call(['pip2', 'install', 'pykafka', 'flask'])
    # Make hostname resolvable
    service_name = hookenv.local_unit().split('/')[0]
    with open('/etc/hosts', 'a') as hosts_file:
        hosts_file.write('127.0.0.1 {}\n'.format(service_name))
    mergecopytree(charm_dir() + '/files/rest2kafka', "/opt/rest2kafka")
    chownr('/opt/rest2kafka', 'ubuntu', 'ubuntu')
    templating.render(
        source='upstart.conf',
        target='/etc/init/rest2kafka.conf',
        owner='ubuntu',
        group='ubuntu',
        context={
            'user': '******',
            'description': 'rest2kafka',
            'command': '/opt/rest2kafka/rest2kafka.py',
            'debug': 'False',
        }
    )
示例#11
0
def install_packages():
    pin_dse()

    apt.queue_install(cassandra.get_deb_packages())

    if reactive.is_flag_set('apt.queued_installs'):
        with helpers.autostart_disabled():
            if not apt.install_queued():
                return  # apt layer already left us in a blocked state

    if cassandra.get_edition() == 'apache-snap':
        snap.install('cassandra')
    elif cassandra.get_jre() == 'oracle':
        tb = fetch_oracle_jre()
        if tb is None:
            return
        install_oracle_jre_tarball(tb)
    elif cassandra.get_jre() == 'openjdk':
        subprocess.check_call(['update-java-alternatives', '--jre-headless', '--set', 'java-1.8.0-openjdk-amd64'])
    reactive.set_flag('cassandra.installed')
示例#12
0
def install_packages(packages):
    hookenv.status_set('maintenance', 'Installing software')
    hookenv.log("Installing packages")
    apt.queue_install(packages)
    apt.install_queued()
示例#13
0
def install_layer_samba():
    sys.path.append(os.path.realpath('..'))
    # Do your setup here.
    #
    # If your charm has other dependencies before it can install,
    # add those as @when() clauses above., or as additional @when()
    # decorated handlers below
    #
    # See the following for information about reactive charms:
    #
    #  * https://jujucharms.com/docs/devel/developer-getting-started
    #  * https://github.com/juju-solutions/layer-basic#overview
    #
    config = hookenv.config()

    password = config['password']
    server_name = config['server_name']
    online = config['online']

    hookenv.status_set('maintenance', 'Updating apt')
    apt.update()

    hookenv.status_set('maintenance', 'Installing packages')
    apt.queue_install(['samba'])
    apt.install_queued()

    #os.system('git clone https://github.com/bdrung/ionit.git')
    #os.system('python3 ionit/setup.py install')

    hookenv.status_set('maintenance', 'Configuring')

    host.add_group('juju-samba-ubuntu')
    host.adduser('ubuntu', password)
    host.add_user_to_group('ubuntu', 'juju-samba-ubuntu')

    cmd = ("sudo echo -e \"" + password + "\n" + password +
           "\" | smbpasswd -s -a ubuntu")
    os.system(cmd)

    if not os.path.exists('/opt/samba/share'):
        os.makedirs('/opt/samba/share')
    host.chownr('/opt/samba/share', 'ubuntu', 'juju-samba-ubuntu', True, True)
    if not os.path.exists('/etc/samba/smb.conf'):
        os.makedirs('/etc/samba')
        shutil.copy('opt/smb.conf', '/etc/samba/smb.conf')
    render(source='smb',
           target='/etc/samba/smb.conf',
           context={
               "cfg": config,
           },
           owner='root',
           perms=0o740)

    restartSamba()

    set_flag('layer-samba.installed')

    if (not online):
        stopSamba()
        hookenv.status_set('active', 'Stopped')
    hookenv.status_set('active', 'Started')