def install_puppet_apt_src(self): '''Fetch and install the puppet gpg key and puppet deb source ''' hookenv.status_set('maintenance', 'Configuring Puppetlabs apt sources') # Add puppet gpg id and apt source apt.add_source(self.puppet_apt_src, key=self.puppet_gpg_key) # Apt update to pick up the sources apt.update()
def install_vaultlocker(): '''Install vaultlocker. On bionic and higher, vaultlocker is available in the default system sources. For xenial, we need to add the queens cloud archive. ''' dist = host.lsb_release() dist_series = dist['DISTRIB_CODENAME'].lower() if dist_series == 'xenial': apt.add_source('cloud:queens') apt.update() apt.queue_install(['vaultlocker'])
def configure_sources(): '''Add the PGDB apt sources, if selected.''' config = hookenv.config() # Shortcut for the PGDG archive. if config['pgdg']: pgdg_url = 'http://apt.postgresql.org/pub/repos/apt/' pgdg_src = 'deb {} {}-pgdg main'.format(pgdg_url, helpers.distro_codename()) pgdg_key_path = os.path.join(hookenv.charm_dir(), 'lib', 'pgdg.key') with open(pgdg_key_path, 'r') as f: hookenv.log('Adding PGDG archive') apt.add_source(pgdg_src, f.read())
def add_pgdg_source(): pgdg_url = "http://apt.postgresql.org/pub/repos/apt/" pgdg_src = "deb {} {}-pgdg main".format(pgdg_url, helpers.distro_codename()) pgdg_key_path = os.path.join(hookenv.charm_dir(), "lib", "pgdg.key") kv = unitdata.kv() k = "postgresql.service.pgdg_src" # Add the source if the key has changed, or if the src has # changed such as a distro upgrade. Check key change first, # or short circuiting will add the source twice. if reactive.helpers.any_file_changed([pgdg_key_path]) or pgdg_src != kv.get(k): with open(pgdg_key_path, "r") as f: hookenv.log("Adding PGDG archive") apt.add_source(pgdg_src, f.read()) kv.set(k, pgdg_src)
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()
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', })
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', } )
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', } )
def install_ceph_base(): add_source(config('source'), key=config('key')) queue_install(PACKAGES)