Exemplo n.º 1
0
    def test_is_ironic(self):
        r = test_utils.QuestionsAnsweredRunner(None)

        r.complete['hypervisor'] = 'kvm'
        self.assertFalse(utils.is_ironic(r))

        r.complete['hypervisor'] = 'ironic'
        self.assertTrue(utils.is_ironic(r))
def get_steps(r):
    """Final tweaks to configuration before we run the playbooks."""

    nextsteps = []

    # We also need to re-write git repos in a large number of roles
    replacements = [
        ('(http|https|git)://github.com', r.complete['git-mirror-github']),
        ('(http|https|git)://git.openstack.org',
         r.complete['git-mirror-openstack']),
        ('https://mirror.rackspace.com', 'http://mirror.rackspace.com'),
        (' +checksum:.*', ''),
    ]

    if r.complete['local-cache'] != 'none':
        replacements.append(
            ('https://rpc-repo.rackspace.com',
             'http://%s/rpc-repo.rackspace.com' % r.complete['local-cache']))
        replacements.append(
            ('https://bootstrap.pypa.io/get-pip.py',
             'http://%s/pip/get-pip.py' % r.complete['local-cache']))

    nextsteps.append(
        steps.BulkRegexpEditorStep('bulk-edit-roles', '/etc/ansible',
                                   '.*\.(ini|yml)$', replacements, **r.kwargs))

    # Release specific steps: Mitaka
    if r.complete['osa-branch'] == 'stable/mitaka' and utils.is_ironic(r):
        nextsteps.append(
            steps.CopyFileStep('enable-ironic-environment-mitaka',
                               'etc/openstack_deploy/env.d/ironic.yml',
                               '/etc/openstack_deploy/env.d/ironic.yml',
                               **r.kwargs))

    if utils.is_ironic(r):
        nextsteps.append(steps.PatchStep('ironic-tftp-address', **r.kwargs))

        if r.complete['osa-branch'] == 'stable/mitaka':
            nextsteps.append(steps.PatchStep('ironic-pxe-options', **r.kwargs))
        else:
            nextsteps.append(
                steps.PatchStep('ironic-pxe-options-newton', **r.kwargs))

    return nextsteps
Exemplo n.º 3
0
def get_steps(r):
    """Things we need the user to tell us about ironic."""

    nextsteps = []
    if utils.is_ironic(r):
        nextsteps.append(
            steps.QuestionStep(
                'ironic-ip-block', 'IP block for Ironic nodes',
                ('We need to know what IP range to use for the neutron '
                 'network that Ironic nodes appear on. This block is managed '
                 'by neutronso should be separate from your primary netblock. '
                 'Please specify this as a CIDR range, for example '
                 '192.168.52.0/24.'), 'Ironic IP Block', **r.kwargs))
    return nextsteps
Exemplo n.º 4
0
def get_steps(r):
    """Clone OSA."""

    nextsteps = []
    nextsteps.append(
        steps.SimpleCommandStep(
            'git-clone-osa',
            ('git clone %s/openstack/openstack-ansible '
             '/opt/openstack-ansible' % r.complete['git-mirror-openstack']),
            **r.kwargs))
    nextsteps.append(
        steps.KwargsStep(
            'kwargs-osa', r, {
                'cwd': '/opt/openstack-ansible',
                'env': {
                    'ANSIBLE_ROLE_FETCH_MODE': 'git-clone',
                    'ANSIBLE_DEBUG': _ansible_debug(r),
                    'ANSIBLE_KEEP_REMOTE_FILES': '1'
                }
            }, **r.kwargs))

    if utils.is_ironic(r):
        nextsteps.append(
            steps.KwargsStep(
                'kwargs-ironic', r,
                {'env': {
                    'BOOTSTRAP_OPTS': 'nova_virt_type=ironic'
                }}, **r.kwargs))

    if r.complete['enable-ceph'] == 'yes':
        if r.complete['osa-branch'] in ['stable/mitaka', 'stable/newton']:
            # This isn't implemented for these releases
            pass
        else:
            nextsteps.append(
                steps.KwargsStep('kwargs-ceph', r,
                                 {'env': {
                                     'SCENARIO': 'ceph'
                                 }}, **r.kwargs))

    return nextsteps
Exemplo n.º 5
0
def get_steps(r):
    """Final installation steps."""

    nextsteps = []

    #####################################################################
    # Release specific steps: Mitaka
    if r.complete['osa-branch'] == 'stable/mitaka' and utils.is_ironic(r):
        nextsteps.append(
            steps.SimpleCommandStep('add-ironic-to-nova-venv',
                                    './helpers/add-ironic-to-nova-venv',
                                    **r.kwargs))

    # Debug output that might be helpful, not scripts are running from
    # ostrich directory
    nextsteps.append(
        steps.SimpleCommandStep('lxc-details', './helpers/lxc-details',
                                **r.kwargs))
    nextsteps.append(
        steps.SimpleCommandStep('pip-ruin-everything',
                                ('pip install python-openstackclient '
                                 'python-ironicclient'), **r.kwargs))
    nextsteps.append(
        steps.SimpleCommandStep('os-cmd-bootstrap',
                                './helpers/os-cmd-bootstrap', **r.kwargs))

    # Remove our HTTP proxy settings because the interfere with talking to
    # OpenStack
    nextsteps.append(
        steps.KwargsStep(
            'kwargs-disable-http-proxy', r, {
                'max_attempts': 1,
                'env': {
                    'http_proxy': None,
                    'https_proxy': None,
                    'HTTP_PROXY': None,
                    'HTTPS_PROXY': None
                }
            }, **r.kwargs))

    return nextsteps
Exemplo n.º 6
0
def get_steps(r):
    """The actual steps."""

    nextsteps = []
    playnames = [
        'openstack-hosts-setup',
        'security-hardening',
        'lxc-hosts-setup',
        'lxc-containers-create',
        'setup-infrastructure',
        'os-keystone-install',
        'os-glance-install',
        'os-cinder-install',
        'os-nova-install',
        'os-neutron-install',
        'os-heat-install',
        'os-horizon-install',
        'os-ceilometer-install',
        'os-aodh-install',
        'os-swift-install',
    ]

    if utils.is_ironic(r):
        playnames.append('os-ironic-install')

    for play in playnames:
        nextsteps.append(
            steps.AnsibleTimingSimpleCommandStep(
                play, 'openstack-ansible -vvv %s.yml' % play,
                os.path.expanduser('~/.ostrich/timings-%s.json' % play),
                **r.kwargs))

    nextsteps.append(
        steps.KwargsStep('kwargs-return-to-ostrich-dir', r, {'cwd': None},
                         **r.kwargs))

    return nextsteps
Exemplo n.º 7
0
def get_steps(r):
    """Do all the configuration we do before bootstrapping."""

    nextsteps = []

    p = urlparse.urlparse(r.complete['git-mirror-github'])
    mirror_host_github = p.netloc.split(':')[0]
    p = urlparse.urlparse(r.complete['git-mirror-openstack'])
    mirror_host_openstack = p.netloc.split(':')[0]

    nextsteps.append(
        steps.SimpleCommandStep(
            'git-mirror-host-keys',
            ('ssh-keyscan -H %s >> /etc/ssh/ssh_known_hosts' %
             mirror_host_openstack), **r.kwargs))

    if mirror_host_github != mirror_host_openstack:
        nextsteps.append(
            steps.SimpleCommandStep(
                'git-mirror-host-keys-github',
                ('ssh-keyscan -H %s >> /etc/ssh/ssh_known_hosts' %
                 mirror_host_github), **r.kwargs))

    if utils.is_ironic(r):
        if r.complete['osa-branch'] == 'stable/mitaka':
            nextsteps.append(steps.PatchStep('ironic-aio-mitaka', **r.kwargs))
        else:
            nextsteps.append(
                steps.YamlAddElementStep('enable-ironic-aio-scenario',
                                         'tests/bootstrap-aio.yml',
                                         [0, 'vars', 'confd_overrides', 'aio'],
                                         {'name': 'ironic.yml.aio'},
                                         **r.kwargs))

            if r.complete['osa-branch'] in ['stable/mitaka', 'stable/newton']:
                # This isn't implemented for these releases
                pass
            else:
                nextsteps.append(
                    steps.YamlAddElementStep(
                        'enable-ironic-ceph-scenario',
                        'tests/bootstrap-aio.yml',
                        [0, 'vars', 'confd_overrides', 'ceph'],
                        {'name': 'ironic.yml.aio'}, **r.kwargs))

        nextsteps.append(
            steps.FileAppendStep('group-vars-ironic_service_user_name',
                                 'playbooks/inventory/group_vars/all.yml',
                                 '\n\nironic_service_user_name: ironic',
                                 **r.kwargs))

    if r.complete['osa-branch'] != 'stable/mitaka':
        nextsteps.append(
            steps.RegexpEditorStep(
                'ansible-no-loopback-swap',
                ('/opt/openstack-ansible/tests/roles/bootstrap-host/'
                 'tasks/prepare_loopback_swap.yml'),
                'command: grep /openstack/swap.img /proc/swaps',
                'command: /bin/true', **r.kwargs))

    nextsteps.append(
        steps.RegexpEditorStep('lxc-cachable-downloads',
                               '/usr/share/lxc/templates/lxc-download',
                               'wget_wrapper -T 30 -q https?://',
                               'wget_wrapper -T 30 -q --no-hsts http://',
                               **r.kwargs))

    nextsteps.append(
        steps.SimpleCommandStep(
            'archive-upper-constraints',
            ('curl https://git.openstack.org/cgit/openstack/requirements/'
             'plain/upper-constraints.txt?id='
             '$(awk \'/requirements_git_install_branch:/ {print $2}\' '
             '/opt/openstack-ansible/playbooks/defaults/repo_packages/'
             'openstack_services.yml) -o ~/.ostrich/upper-contraints.txt'),
            **r.kwargs))

    return nextsteps
Exemplo n.º 8
0
def get_steps(r):
    """Configure user variables with all our special things."""

    nextsteps = []

    if r.complete['http-proxy'] and r.complete['http-proxy'] != 'none':
        # This is the more permanent way of doing this
        local_servers = 'localhost,127.0.0.1'
        if r.complete['local-cache'] != 'none':
            local_servers += ',%s' % r.complete['local-cache']

        if r.complete['osa-branch'] == 'stable/mitaka':
            nextsteps.append(
                steps.FileAppendStep(
                    'proxy-environment-via-ansible',
                    '/etc/openstack_deploy/user_variables.yml',
                    (('\n\n'
                      'no_proxy_env: "%(local)s,{{ '
                      'internal_lb_vip_address }},{{ external_lb_vip_address }},'
                      '{%% for host in groups[\'all_containers\'] %%}'
                      '{{ hostvars[host][\'container_address\'] }}'
                      '{%% if not loop.last %%},{%% endif %%}{%% endfor %%}"\n'
                      'global_environment_variables:\n'
                      '  HTTPS_PROXY: "%(proxy)s"\n'
                      '  https_proxy: "%(proxy)s"\n'
                      '  HTTP_PROXY: "%(proxy)s"\n'
                      '  http_proxy: "%(proxy)s"\n'
                      '  NO_PROXY: "{{ no_proxy_env }}"\n'
                      '  no_proxy: "{{ no_proxy_env }}"') % {
                          'proxy': r.complete['http-proxy'],
                          'local': local_servers
                      }), **r.kwargs))

    nextsteps.append(
        steps.FileAppendStep('osa-debug-mode',
                             '/etc/openstack_deploy/user_variables.yml',
                             '\n\ndebug: true\nverbose: true', **r.kwargs))

    nextsteps.append(
        steps.FileCreateStep(
            'lxc-hosts-apt-keep-configs',
            '/etc/ansible/roles/lxc_hosts/templates/apt-keep-configs.j2',
            """Dpkg::Options {
   "--force-confdef";
   "--force-confold";
}""", **r.kwargs))

    nextsteps.append(
        steps.SimpleCommandStep(
            'lxc-hosts-apt-keep-configs-enable',
            """sed -i -e '/- name: Update container resolvers/ i \\- name: Always keep modified config files\\n  template:\\n    src: apt-keep-configs.j2\\n    dest: "{{ lxc_container_cache_path }}/{{ item.chroot_path }}/etc/apt/apt.conf.d/00apt-keep-configs"\\n  with_items: lxc_container_caches\\n  tags:\\n    - lxc-cache\\n    - lxc-cache-update\\n\\n'  /etc/ansible/roles/lxc_hosts/tasks/lxc_cache_preparation.yml""",
            **r.kwargs))

    # Make updates non-interactive
    if r.complete['osa-branch'] == 'stable/mitaka':
        nextsteps.append(
            steps.PatchStep('lxc-hosts-ucf-non-interactive', **r.kwargs))
        nextsteps.append(
            steps.PatchStep('cinder-constraints-mitaka', **r.kwargs))
    elif r.complete['osa-branch'] == 'stable/newton':
        nextsteps.append(
            steps.PatchStep('lxc-hosts-ucf-non-interactive-newton',
                            **r.kwargs))
    else:
        nextsteps.append(
            steps.PatchStep('lxc-hosts-ucf-non-interactive-ocata', **r.kwargs))

    # Patch ceph role to work
    if r.complete['enable-ceph'] == 'yes':
        if r.complete['osa-branch'] in ['stable/mitaka', 'stable/newton']:
            # This isn't implemented for these releases
            pass
        else:
            nextsteps.append(steps.PatchStep('ceph-global-pg_num', **r.kwargs))

    # Release specific steps: Mitaka
    if r.complete['osa-branch'] == 'stable/mitaka' and utils.is_ironic(r):
        nextsteps.append(
            steps.FileAppendStep('enable-ironic',
                                 '/etc/openstack_deploy/user_variables.yml',
                                 '\n\nnova_virt_type: ironic\n', **r.kwargs))

    # Turn on agent logging in ironic
    if utils.is_ironic(r):
        nextsteps.append(steps.PatchStep('ironic-agent-logs', **r.kwargs))

    return nextsteps
def get_steps(r):
    """Configure all the special things for ironic networking."""

    nextsteps = []

    if not utils.is_ironic(r):
        return []

    nextsteps.append(
        steps.YamlAddElementStep(
            'add-provider-network',
            '/etc/openstack_deploy/openstack_user_config.yml',
            ['global_overrides', 'provider_networks'], {
                'network': {
                    'group_binds': [
                        'neutron_linuxbridge_agent',
                        'ironic_conductor_container', 'ironic_api_container'
                    ],
                    'container_bridge':
                    'br-ironic',
                    'container_type':
                    'veth',
                    'container_interface':
                    'eth12',
                    'type':
                    'flat',
                    'net_name':
                    'ironic',
                    'ip_from_q':
                    'ironic'
                }
            }, **r.kwargs))

    nextsteps.append(
        steps.YamlDeleteElementStep(
            'delete-provider-network',
            '/etc/openstack_deploy/openstack_user_config.yml',
            ['global_overrides', 'provider_networks'], 2, **r.kwargs))

    net, hosts = utils.expand_ironic_netblock(r)

    nextsteps.append(
        steps.YamlUpdateElementStep(
            'configure-external-lb-ip',
            '/etc/openstack_deploy/openstack_user_config.yml',
            ['global_overrides'], 'external_lb_vip_address', str(hosts[4]),
            **r.kwargs))

    nextsteps.append(
        steps.YamlUpdateDictionaryStep(
            'add-network-cidr',
            '/etc/openstack_deploy/openstack_user_config.yml',
            ['cidr_networks'], {'ironic': str(net)}, **r.kwargs))

    nextsteps.append(
        steps.YamlAddElementStep(
            'reserve-netblock-start',
            '/etc/openstack_deploy/openstack_user_config.yml', ['used_ips'],
            '%s,%s' % (hosts[0], hosts[10]), **r.kwargs))
    nextsteps.append(
        steps.YamlAddElementStep(
            'reserve-netblock-end',
            '/etc/openstack_deploy/openstack_user_config.yml', ['used_ips'],
            '%s,%s' % (hosts[-10], hosts[-1]), **r.kwargs))
    nextsteps.append(
        steps.SimpleCommandStep('add-ironic-bridge', 'brctl addbr br-ironic',
                                **r.kwargs))
    nextsteps.append(
        steps.SimpleCommandStep('add-ironic-bridge-nic',
                                'brctl addif br-ironic eth1', **r.kwargs))
    nextsteps.append(
        steps.SimpleCommandStep('add-ironic-bridge-ip',
                                'ifconfig br-ironic inet %s up' % hosts[4],
                                **r.kwargs))
    nextsteps.append(
        steps.SimpleCommandStep('add-ironic-interface-ip',
                                'ifconfig eth1 inet %s up' % hosts[3],
                                **r.kwargs))

    if r.complete['osa-branch'] in ['stable/mitaka', 'stable/newton']:
        nextsteps.append(steps.PatchStep('ironic-vip-address', **r.kwargs))
    else:
        nextsteps.append(
            steps.PatchStep('ironic-vip-address-ocata', **r.kwargs))

    return nextsteps