Ejemplo n.º 1
0
    def setup(self):
        """
        easy_install, pipをインストールします。
        また、pipはパッケージインストール時にソースからコンパイルするため、
        いくつかのdevelパッケージをインストールしておきます。
        """
        self.init()

        git.setup()
        self.install_packages()

        with api.warn_only():
            result = run('which easy_install')

        if result.return_code != 0:
            sudo('sh -c "cd /tmp/ && wget https://bootstrap.pypa.io/ez_setup.py -O - | python"')

        with api.warn_only():
            result = run('which pip')

        if result.return_code != 0:
            sudo('easy_install pip')

        if self.prefix != '/usr':
            sudo('pip install virtualenv')
            if not filer.exists(self.prefix):
                sudo('virtualenv {0} --system-site-packages'.format(self.prefix))
Ejemplo n.º 2
0
def setup():
    git.setup()
    sudo('rm -rf /tmp/git')
    git.sync('https://github.com/fabrickit-fablib/git.git')
    git.sync('https://github.com/fabrickit-fablib/git.git', dest='/tmp/git')
    git.sync('https://github.com/fabrickit-fablib/git.git', dest='/tmp/git')
    git.sync('https://github.com/fabrickit-fablib/git.git', dest='/tmp/git-sudo', use_sudo=True)
    git.sync('https://github.com/fabrickit-fablib/git.git', dest='/tmp/git-sudo', use_sudo=True)
Ejemplo n.º 3
0
    def setup(self):
        sudo('setenforce 0')
        Editor('/etc/selinux/config').s('SELINUX=enforcing', 'SELINUX=disable')

        Service('firewalld').stop().disable()

        git.setup()
        dest = git.sync('https://github.com/openstack-dev/devstack.git', dest='/tmp/devstack', branch='stable/liberty')
        print dest

        filer.template('/tmp/devstack/local.conf')
Ejemplo n.º 4
0
def setup():
    git.setup()
    sudo('rm -rf /tmp/git')
    git.sync('https://github.com/fabrickit-fablib/git.git')
    git.sync('https://github.com/fabrickit-fablib/git.git', dest='/tmp/git')
    git.sync('https://github.com/fabrickit-fablib/git.git', dest='/tmp/git')
    git.sync('https://github.com/fabrickit-fablib/git.git',
             dest='/tmp/git-sudo',
             use_sudo=True)
    git.sync('https://github.com/fabrickit-fablib/git.git',
             dest='/tmp/git-sudo',
             use_sudo=True)
Ejemplo n.º 5
0
    def setup(self):
        self.install_packages()
        self.start_services().enable_services()

        repo = '/home/{0}/fabkit-repo'.format(env.user)
        filer.mkdir(repo, use_sudo=False)
        git.setup()
        git.sync('https://github.com/fabrickit/fabkit.git',
                 dest='{0}/fabfile'.format(repo))

        python = Python('/opt/fabkit')
        python.setup()
        python.install(
            requirements='{0}/fabfile/requirements.txt'.format(repo))

        run('cd {0} && /opt/fabkit/bin/fab genconfig:fabfile.ini &&'
            ' sed -i "/^\[web\]/,/^\[/s/#hostname =.*/hostname = */g" fabfile.ini'.format(repo))

        data = {
            'port': 80,
            'repo': repo,
            'user': env.user,
            'group': env.user,
            'python_path': python.get_site_packages(),
            'processes': 5,
            'threads': 1,
        }

        run('cd {0}/fabfile/core/webapp/ &&'
            ' /opt/fabkit/bin/python manage.py migrate &&'
            ' echo "from django.contrib.auth.models import User;'
            '       User.objects.create_superuser(\'admin\', \'admin@localhost\', \'admin\')"'
            '       | /opt/fabkit/bin/python manage.py shell &&'
            ' /opt/fabkit/bin/python manage.py collectstatic --noinput'.format(repo))

        sudo('chmod 755 /home/{0}'.format(env.user))

        if re.match('CentOS .*', env.node['os']):
            log_prefix = '/var/log/httpd/{0}'.format(env.user)
            data['error_log'] = '{0}-error.log'.format(log_prefix)
            data['custom_log'] = '{0}-access.log'.format(log_prefix)

            if filer.template(src='httpd.conf',
                              dest='/etc/httpd/conf.d/{0}_httpd.conf'.format(env.user),
                              data=data):
                self.handlers['restart_httpd'] = True

        elif re.match('Ubuntu .*', env.node['os']):
            log_prefix = '/var/log/apache2/{0}'.format(env.user)
            data['error_log'] = '{0}-error.log'.format(log_prefix)
            data['custom_log'] = '{0}-access.log'.format(log_prefix)

            if filer.template(src='httpd.conf',
                              dest='/etc/apache2/sites-enabled/{0}_httpd.conf'.format(env.user),
                              data=data):
                self.handlers['restart_apache2'] = True

        self.exec_handlers()

        # install
        sudo('npm install -g coffee-script'.format(repo))
        sudo('cd {0}/fabfile/core/webapp && npm install'.format(repo))

        # install node packages for develop
        sudo('npm install -g grunt-cli'.format(repo))
        sudo('cd {0}/fabfile/core/webapp/node_chat && npm install'.format(repo))
Ejemplo n.º 6
0
    def setup(self):
        self.install_packages()
        self.start_services().enable_services()

        repo = '/home/{0}/fabkit-repo'.format(env.user)
        filer.mkdir(repo, use_sudo=False)
        git.setup()
        git.sync('https://github.com/fabrickit/fabkit.git',
                 dest='{0}/fabfile'.format(repo))

        python = Python('/opt/fabkit')
        python.setup()
        python.install(
            requirements='{0}/fabfile/requirements.txt'.format(repo))

        run('cd {0} && /opt/fabkit/bin/fab genconfig:fabfile.ini &&'
            ' sed -i "/^\[web\]/,/^\[/s/#hostname =.*/hostname = */g" fabfile.ini'
            .format(repo))

        data = {
            'port': 80,
            'repo': repo,
            'user': env.user,
            'group': env.user,
            'python_path': python.get_site_packages(),
            'processes': 5,
            'threads': 1,
        }

        run('cd {0}/fabfile/core/webapp/ &&'
            ' /opt/fabkit/bin/python manage.py migrate &&'
            ' echo "from django.contrib.auth.models import User;'
            '       User.objects.create_superuser(\'admin\', \'admin@localhost\', \'admin\')"'
            '       | /opt/fabkit/bin/python manage.py shell &&'
            ' /opt/fabkit/bin/python manage.py collectstatic --noinput'.format(
                repo))

        sudo('chmod 755 /home/{0}'.format(env.user))

        if re.match('CentOS .*', env.node['os']):
            log_prefix = '/var/log/httpd/{0}'.format(env.user)
            data['error_log'] = '{0}-error.log'.format(log_prefix)
            data['custom_log'] = '{0}-access.log'.format(log_prefix)

            if filer.template(src='httpd.conf',
                              dest='/etc/httpd/conf.d/{0}_httpd.conf'.format(
                                  env.user),
                              data=data):
                self.handlers['restart_httpd'] = True

        elif re.match('Ubuntu .*', env.node['os']):
            log_prefix = '/var/log/apache2/{0}'.format(env.user)
            data['error_log'] = '{0}-error.log'.format(log_prefix)
            data['custom_log'] = '{0}-access.log'.format(log_prefix)

            if filer.template(
                    src='httpd.conf',
                    dest='/etc/apache2/sites-enabled/{0}_httpd.conf'.format(
                        env.user),
                    data=data):
                self.handlers['restart_apache2'] = True

        self.exec_handlers()

        # install
        sudo('npm install -g coffee-script'.format(repo))
        sudo('cd {0}/fabfile/core/webapp && npm install'.format(repo))

        # install node packages for develop
        sudo('npm install -g grunt-cli'.format(repo))
        sudo(
            'cd {0}/fabfile/core/webapp/node_chat && npm install'.format(repo))