Exemplo n.º 1
0
    def internal_build(self):
        from rsconf import systemd
        from rsconf.component import docker_registry
        import pykern.pkdebug

        def _env_ok(k):
            if k.startswith('PYKERN_') or k.startswith(
                    'SIREPO_FEATURE_CONFIG_'):
                return not pykern.pkdebug.SECRETS_RE.search(k)
            return (k == _SECRET
                    or k.startswith('SIREPO_PKCLI_TEST_HTTP_SERVER'))

        jc, z = self.j2_ctx_init()
        e = PKDict()
        for k, v in self.buildt.get_component('sirepo').sirepo_unit_env(
                self).items():
            if _env_ok(k):
                e[k] = v
        assert e.get(_SECRET), \
            f'{_SECRET} not found in sirepo config'
        systemd.timer_prepare(self, jc, on_calendar=z.on_calendar)
        e.pksetdefault(
            SIREPO_PKCLI_TEST_HTTP_SERVER_URI=f'https://{jc.sirepo.vhost}', )
        systemd.docker_unit_enable(
            self,
            cmd='sirepo test_http',
            env=e,
            image=docker_registry.absolute_image(jc, jc.sirepo.docker_image),
            j2_ctx=jc,
            run_u=jc.rsconf_db.run_u,
        )
Exemplo n.º 2
0
    def internal_build(self):
        from rsconf import systemd
        from rsconf.component import docker_registry

        self.buildt.require_component('docker')

        j2_ctx = self.hdb.j2_ctx_copy()
        z = j2_ctx.github_bkp
        z.run_u = j2_ctx.rsconf_db.run_u
        run_d = systemd.timer_prepare(self, j2_ctx, on_calendar=z.on_calendar)
        z.db_d = run_d.join('db')
        z.run_f = run_d.join('run')
        env = pkcollections.Dict(
            PYKERN_PKCLI_GITHUB_EXCLUDE_RE=z.exclude_re,
            PYKERN_PKCLI_GITHUB_PASSWORD=z.password,
            PYKERN_PKCLI_GITHUB_TEST_MODE=z.setdefault('test_mode', False),
            PYKERN_PKCLI_GITHUB_USER=z.user,
        )
        systemd.docker_unit_enable(
            self,
            image=docker_registry.absolute_image(j2_ctx, z.docker_image),
            j2_ctx=j2_ctx,
            env=env,
            run_u=z.run_u,
            cmd=z.run_f,
        )
        self.install_access(mode='500', owner=z.run_u)
        self.install_resource('github_bkp/run.sh', j2_ctx, z.run_f)
        self.install_access(mode='700')
        self.install_directory(z.db_d)
Exemplo n.º 3
0
    def internal_build(self):
        self.buildt.require_component('base_all')

        j2_ctx = self.hdb.j2_ctx_copy()
        z = set_defaults(j2_ctx)
        z.run_u = j2_ctx.rsconf_db.root_u
        run_d = systemd.timer_prepare(self, j2_ctx, on_calendar=z.on_calendar)
        run_f = run_d.join('run')
        systemd.timer_enable(
            self,
            j2_ctx=j2_ctx,
            cmd=run_f,
            run_u=z.run_u,
        )
        self.install_access(mode='500', owner=z.run_u)
        self.install_resource('db_bkp/run.sh', j2_ctx, run_f)
Exemplo n.º 4
0
 def internal_build(self):
     self.buildt.require_component('base_users')
     j2_ctx = self.hdb.j2_ctx_copy()
     z = j2_ctx.logrotate
     z.run_u = j2_ctx.rsconf_db.root_u
     z.conf_f = CONF_F
     z.verbose_flag = '--verbose' if z.get('verbose', False) else ''
     z.run_d = systemd.timer_prepare(self,
                                     j2_ctx,
                                     on_calendar=z.on_calendar)
     run = z.run_d.join('run')
     systemd.timer_enable(
         self,
         j2_ctx=j2_ctx,
         cmd=run,
         run_u=z.run_u,
     )
     self.install_access(mode='500', owner=z.run_u)
     self.install_resource('logrotate/run.sh', j2_ctx, run)
     self.install_access(mode='400')
     self.install_resource('logrotate/logrotate.conf', j2_ctx, z.conf_f)
     self.append_root_bash_with_main(j2_ctx)
Exemplo n.º 5
0
    def internal_build(self):
        self.buildt.require_component('base_all')

        jc = self.hdb.j2_ctx_copy()
        z = jc.bkp
        z.run_u = jc.rsconf_db.root_u
        z.run_d = systemd.timer_prepare(self, jc, on_calendar=z.on_calendar)
        secondary_setup = None
        if jc.rsconf_db.host == z.primary:
            self._primary(jc, z)
            n = 'primary'
        else:
            secondary_setup = self._secondary(jc, z)
            n = 'secondary'
        te = z.run_d.join(n)
        self.install_access(mode='500', owner=z.run_u)
        self.install_resource('bkp/{}.sh'.format(n), jc, te)
        if secondary_setup:
            self.install_abspath(
                secondary_setup,
                z.run_d.join(secondary_setup.purebasename),
            )
        systemd.timer_enable(self, j2_ctx=jc, cmd=te, run_u=z.run_u)
Exemplo n.º 6
0
    def internal_build(self):
        from rsconf import systemd
        from rsconf.component import bop

        # Must be after bop so bconf_f exists, and bop has to be on the machine
        self.buildt.require_component('bop')
        j2_ctx = self.hdb.j2_ctx_copy()
        z = j2_ctx.bop_timer
        for app_name in sorted(j2_ctx.bop.apps):
            app_vars = bop.merge_app_vars(j2_ctx, app_name)
            if pkconfig.channel_in_internal_test(
                    channel=j2_ctx.rsconf_db.channel):
                self._add_initdb_spec(j2_ctx, z, app_vars)
            if not app_name in z.spec:
                continue
            z.run_u = app_vars.run_u
            z.bconf_f = app_vars.bconf_f
            timers = z.spec[app_name]
            for t in sorted(timers.keys()):
                tv = timers[t]
                z.bash_script = tv.bash_script
                run_u = tv.get('run_u', z.run_u)
                timer_name = '{}_{}'.format(app_name, t)
                run_d = systemd.timer_prepare(
                    self,
                    j2_ctx,
                    #TODO(robnagler) time zone
                    on_calendar=tv.on_calendar,
                    service_name=timer_name,
                )
                run_f = run_d.join('run')
                systemd.timer_enable(self,
                                     j2_ctx=j2_ctx,
                                     cmd=run_f,
                                     run_u=run_u)
                self.install_access(mode='500', owner=run_u)
                self.install_resource('bop_timer/run.sh', j2_ctx, run_f)
Exemplo n.º 7
0
    def internal_build(self):
        from rsconf import systemd
        from rsconf import db
        from rsconf.component import bop

        self.buildt.require_component('postgresql', 'postfix')
        j2_ctx = self.hdb.j2_ctx_copy()
        z = j2_ctx.btest
        z.run_u = j2_ctx.rsconf_db.run_u
        z.run_d = systemd.timer_prepare(self,
                                        j2_ctx,
                                        on_calendar=z.on_calendar)
        z.apps_d = z.run_d.join('apps')
        run_f = z.run_d.join('run')
        systemd.timer_enable(
            self,
            j2_ctx=j2_ctx,
            cmd=run_f,
            run_u=z.run_u,
        )
        z.source_code_d = bop.SOURCE_CODE_D
        z.app_run_u = j2_ctx.rsconf_db.run_u
        self.buildt.get_component('postfix').extend_local_host_names(
            [z.client_host], )
        self.install_access(mode='700', owner=z.app_run_u)
        self.install_directory(z.apps_d)
        z.home_d = db.user_home_path(j2_ctx, z.app_run_u)
        # POSIT: Bivio::Test::Language::HTTP
        z.mail_d = z.home_d.join('btest-mail')
        self.install_directory(z.mail_d)
        if j2_ctx.rsconf_db.channel == 'dev':
            z.mail_copy_d = z.mail_d + '-copy'
            self.install_directory(z.mail_copy_d)
        self.install_access(mode='400')
        self.install_resource(
            'btest/vagrant_procmailrc',
            j2_ctx,
            z.home_d.join('.procmailrc'),
        )
        z.run_app_cmds = ''
        for n in sorted(z.apps):
            a = bop.merge_app_vars(j2_ctx, n)
            z.perl_root = a.perl_root
            self.install_access(mode='700', owner=z.app_run_u)
            z.app_run_d = z.apps_d.join(n)
            self.install_directory(z.app_run_d)
            z.service_name = 'btest_' + n
            z.current_base = 'current'
            z.current_d = z.app_run_d.join(z.current_base)
            z.file_root = z.app_run_d.join('db')
            self.install_directory(z.file_root)
            z.backup_root = z.app_run_d.join('bkp')
            self.install_directory(z.backup_root)
            z.database = a.short_prefix + 'btest'
            z.log_d = z.app_run_d.join('log')
            # handles petshop
            z.root_for_unit = re.sub('::.*', '', z.perl_root)
            z.app_source_d = pkio.py_path('/usr/src/bop').join(z.root_for_unit)
            self.install_directory(z.log_d)
            # handles petshop
            z.root_for_acceptance = re.sub('::', '/', z.perl_root)
            z.perl_root_d = z.current_d.join(z.root_for_acceptance)
            z.facade_local_file_root = z.perl_root_d.join('files')
            z.http_home_page_uri = 'https://' + a.http_host
            z.http_host = a.http_host
            z.mail_host = a.mail_host
            self.install_access(mode='400')
            z.bconf = pkcollections.Dict()
            for x in 'unit', 'acceptance':
                z.bconf_is_unit = x == 'unit'
                z.bconf[x] = z.app_run_d.join('bivio-{}.bconf'.format(x))
                self.install_resource(
                    'btest/bivio.bconf',
                    j2_ctx,
                    z.bconf[x],
                )
            self.install_access(mode='500')
            z.app_run_f = z.app_run_d.join('run')
            #TODO(robnagler) send mail
            self.install_resource(
                'btest/app_run.sh',
                j2_ctx,
                z.app_run_f,
            )
            z.run_app_cmds += '{}\n'.format(z.app_run_f)
            bop.install_perl_rpms(
                self,
                j2_ctx,
                perl_root=z.perl_root,
            )
        self.install_access(mode='500', owner=z.run_u)
        self.install_resource(
            'btest/run.sh',
            j2_ctx,
            run_f,
        )