--- # SPDX-license-identifier: Apache-2.0 ############################################################################## # Copyright (c) 2017 Ericsson AB and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - hosts: opnfv remote_user: root vars_files: - "{{ xci_path }}/xci/var/opnfv.yml" - "{{ xci_path }}/xci/installer/osa/files/openstack_services.yml" environment: http_proxy: "{{ lookup('env','http_proxy') }}" https_proxy: "{{ lookup('env','https_proxy') }}" no_proxy: "{{ lookup('env','no_proxy') }}" HTTP_PROXY: "{{ lookup('env','http_proxy') }}" HTTPS_PROXY: "{{ lookup('env','https_proxy') }}" NO_PROXY: "{{ lookup('env','no_proxy') }}" pre_tasks: - name: Load distribution variables include_vars: file: "{{ item }}" with_items: - "{{ xci_path }}/xci/var/{{ ansible_os_family }}.yml" - "{{ xci_flavor_ansible_file_path }}/flavor-vars.yml" - name: Set facts for remote deployment set_fact: remote_xci_path: "{{ ansible_env.HOME }}/releng-xci" remote_xci_flavor_files: "{{ ansible_env.HOME }}/releng-xci/xci/installer/{{installer_type}}/files/{{ xci_flavor }}" remote_xci_playbooks: "{{ ansible_env.HOME }}/releng-xci/xci/playbooks" roles: - role: bootstrap-host configure_network: xci_flavor != 'aio' - role: peru.proxy_settings proxy_settings_http_proxy: "{{ lookup('env','http_proxy') }}" proxy_settings_https_proxy: "{{ lookup('env','https_proxy') }}" proxy_settings_ftp_proxy: "{{ lookup('env','ftp_proxy') }}" proxy_settings_no_proxy: "{{ lookup('env','no_proxy') }}" tasks: - name: generate SSH keys shell: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N "" args: creates: "{{ ansible_env.HOME }}/.ssh/id_rsa" - name: fetch public key fetch: src: "{{ ansible_env.HOME }}/.ssh/id_rsa.pub" dest: "{{ xci_path }}/xci/files/authorized_keys" flat: yes - name: Copy releng-xci to remote host synchronize: src: "{{ xci_path }}/" dest: "{{ remote_xci_path }}" recursive: yes delete: yes - name: copy flavor inventory shell: "/bin/cp -rf {{ remote_xci_flavor_files }}/inventory {{ remote_xci_playbooks }}" - name: copy openstack_deploy shell: "/bin/cp -rf {{openstack_osa_path}}/etc/openstack_deploy {{openstack_osa_etc_path}}" - name: copy openstack_user_config.yml shell: "/bin/cp -rf {{ remote_xci_flavor_files }}/openstack_user_config.yml {{openstack_osa_etc_path}}" failed_when: false - name: copy all user override files shell: "/bin/cp -rf {{ remote_xci_flavor_files }}/user_variables.yml {{openstack_osa_etc_path}}" failed_when: false - name: copy cinder.yml shell: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/cinder.yml {{openstack_osa_etc_path}}/env.d" - name: Configure OpenStack-Ansible components lineinfile: path: "{{ openstack_osa_etc_path }}/user_variables.yml" line: "{{ item.component }}: {{ item.value }}" state: present with_items: - { component: "tempest_install", value: "{{ run_tempest | bool }}" } - { component: "tempest_run", value: "{{ run_tempest | bool }}" } - { component: "core_openstack", value: "{{ core_openstack_install | bool }}" } - block: - name: copy ceph.yml shell: "/bin/cp -rf {{ remote_xci_flavor_files }}/ceph.yml {{openstack_osa_etc_path}}/conf.d/" - name: copy user_ceph.yml shell: "/bin/cp -rf {{ remote_xci_flavor_files }}/user_ceph.yml {{openstack_osa_etc_path}}/user_ceph.yml" - name: copy user_variables_ceph.yml shell: "/bin/cp -rf {{ remote_xci_flavor_files }}/user_variables_ceph.yml {{openstack_osa_etc_path}}/user_variables_ceph.yml" when: xci_ceph_enabled == "true" - block: - name: copy user_variables_proxy.yml shell: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/user_variables_proxy.yml {{openstack_osa_etc_path}}/user_variables_proxy.yml" - name: "Configure http_proxy_env_url" lineinfile: path: "{{openstack_osa_etc_path}}/user_variables_proxy.yml" regexp: "^http_proxy_env_url:.*" line: "{{ 'http_proxy_env_url: ' + lookup('env','http_proxy') }}" when: - lookup('env','http_proxy') != "randomfoobarstring" - name: copy OPNFV OpenStack playbook shell: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/setup-openstack.yml {{openstack_osa_path}}/playbooks" - name: copy pinned versions of OSA Roles and global requirements shell: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/{{ item }} {{openstack_osa_path}}/{{ item }}" with_items: - "ansible-role-requirements.yml" - "global-requirement-pins.txt" when: - openstack_osa_version != "master" - name: copy pinned versions of OpenStack services shell: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/openstack_services.yml {{openstack_osa_path}}/playbooks/defaults/repo_packages/openstack_services.yml" when: - openstack_osa_version != "master" - include: "{{ xci_path }}/xci/playbooks/bootstrap-scenarios.yml" - name: bootstrap ansible on opnfv host command: "/bin/bash ./scripts/bootstrap-ansible.sh" args: chdir: "{{openstack_osa_path}}" - name: install opnfv pip required packages pip: name: "{{ item }}" state: present extra_args: '-c https://raw.githubusercontent.com/openstack/requirements/{{ requirements_git_install_branch }}/upper-constraints.txt' with_items: - pyyaml - python-neutronclient - python-openstackclient - name: Install ARA callback plugin in OSA virtualenv pip: name: ara state: present extra_args: '-c https://raw.githubusercontent.com/openstack/requirements/{{ requirements_git_install_branch }}/upper-constraints.txt' executable: '/opt/ansible-runtime/bin/pip' - name: Determine ARA callback location shell: "/opt/ansible-runtime/bin/python -c 'import os,ara; print(os.path.dirname(ara.__file__))'" args: executable: /bin/bash register: _ara_install_dir - name: Create local Ansible plugins directory file: path: "{{ ansible_env.HOME }}/.ansible/plugins/callback/ara" state: directory - name: Configure ARA callback file: path: "{{ ansible_env.HOME }}/.ansible/plugins/callback/ara/callbacks" src: "{{ _ara_install_dir.stdout }}/plugins/callbacks" force: yes state: link - name: generate password token command: "python pw-token-gen.py --file {{openstack_osa_etc_path}}/user_secrets.yml" args: chdir: "{{openstack_osa_path}}/scripts" - name: check if certificate directory /etc/ssl/certs exists already stat: path=/etc/ssl/certs register: check_etc_ssl_certs - name: create certificate directory /etc/ssl/certs file: path: "/etc/ssl/certs" state: directory when: check_etc_ssl_certs.stat.exists == false - name: create key directory /etc/ssl/private file: path: "/etc/ssl/private" state: directory - name: copy certificate to /etc/ssl/certs copy: src: "/etc/ssl/certs/xci.crt" dest: "/etc/ssl/certs/" - name: read remote key from /etc/ssl/private set_fact: xci_ssl_key: "{{ lookup('pipe', 'sudo cat /etc/ssl/private/xci.key' ) }}" - name: copy key to /etc/ssl/private copy: content: "{{ xci_ssl_key }}" dest: "/etc/ssl/private/xci.key" become: true - name: fetch xci environment copy: src: "{{ xci_path }}/.cache/xci.env" dest: /root/xci.env - hosts: localhost remote_user: root tasks: - name: Append public keys to authorized_keys shell: "/bin/cat {{ ansible_env.HOME }}/.ssh/id_rsa.pub >> {{ xci_path }}/xci/files/authorized_keys" - hosts: opnfv remote_user: root vars_files: - "{{ xci_path }}/xci/var/opnfv.yml" pre_tasks: - name: Load distribution variables include_vars: file: "{{ item }}" failed_when: false with_items: - "{{ xci_path }}/xci/var/{{ ansible_os_family }}.yml" - "{{ xci_flavor_ansible_file_path }}/flavor-vars.yml" - "{{ xci_flavor_ansible_file_path }}/user_variables.yml" roles: - role: "openstack-ansible-openstack_openrc" tasks: - name: add extra insecure flag to generated openrc blockinfile: dest: "{{ ansible_env.HOME }}/openrc" block: | export OS_INSECURE=true - name: fetch generated openrc fetch: src: "{{ ansible_env.HOME }}/openrc" dest: "{{ xci_path }}/.cache/openrc" flat: true - name: add public key to host copy: src: "{{ xci_path }}/xci/files/authorized_keys" dest: /root/.ssh/authorized_keys