Merge "Modify interactions with installer VM to set up jenkins-ci for cbench test"
[releng.git] / prototypes / xci / playbooks / configure-opnfvhost.yml
1 ---
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2017 Ericsson AB and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 - hosts: opnfv
11   remote_user: root
12   vars_files:
13     - ../var/{{ ansible_os_family }}.yml
14     - ../var/flavor-vars.yml
15     - ../var/opnfv.yml
16   roles:
17     - role: remove-folders
18     - { role: clone-repository, project: "opnfv/releng", repo: "{{ OPNFV_RELENG_GIT_URL }}", dest: "{{ OPNFV_RELENG_PATH }}", version: "{{ OPNFV_RELENG_VERSION }}" }
19     - { role: clone-repository, project: "openstack/openstack-ansible", repo: "{{ OPENSTACK_OSA_GIT_URL }}", dest: "{{ OPENSTACK_OSA_PATH }}", version: "{{ OPENSTACK_OSA_VERSION }}" }
20   tasks:
21     - name: generate SSH keys
22       shell: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""
23       args:
24         creates: /root/.ssh/id_rsa
25     - name: fetch public key
26       fetch: src="/root/.ssh/id_rsa.pub" dest="/"
27     - name: copy flavor inventory
28       shell: "/bin/cp -rf {{XCI_FLAVOR_ANSIBLE_FILE_PATH}}/inventory {{OPNFV_RELENG_PATH}}/prototypes/xci/playbooks"
29     - name: copy flavor vars
30       shell: "/bin/cp -rf {{XCI_FLAVOR_ANSIBLE_FILE_PATH}}/flavor-vars.yml {{OPNFV_RELENG_PATH}}/prototypes/xci/var"
31     - name: copy openstack_deploy
32       shell: "/bin/cp -rf {{OPENSTACK_OSA_PATH}}/etc/openstack_deploy {{OPENSTACK_OSA_ETC_PATH}}"
33     - name: copy openstack_user_config.yml
34       shell: "/bin/cp -rf {{XCI_FLAVOR_ANSIBLE_FILE_PATH}}/openstack_user_config.yml {{OPENSTACK_OSA_ETC_PATH}}"
35     - name: copy user_variables.yml
36       shell: "/bin/cp -rf {{XCI_FLAVOR_ANSIBLE_FILE_PATH}}/user_variables.yml {{OPENSTACK_OSA_ETC_PATH}}"
37     - name: copy cinder.yml
38       shell: "/bin/cp -rf {{OPNFV_RELENG_PATH}}/prototypes/xci/file/cinder.yml {{OPENSTACK_OSA_ETC_PATH}}/env.d"
39     - name: bootstrap ansible on opnfv host
40       command: "/bin/bash ./scripts/bootstrap-ansible.sh"
41       args:
42         chdir: "{{OPENSTACK_OSA_PATH}}"
43     - name: generate password token
44       command: "python pw-token-gen.py --file {{OPENSTACK_OSA_ETC_PATH}}/user_secrets.yml"
45       args:
46         chdir: "{{OPENSTACK_OSA_PATH}}/scripts"
47     - name: copy OPNFV OpenStack playbook
48       shell: "/bin/cp -rf {{OPNFV_RELENG_PATH}}/prototypes/xci/file/setup-openstack.yml {{OPENSTACK_OSA_PATH}}/playbooks"
49     - name: copy OPNFV role requirements
50       shell: "/bin/cp -rf {{OPNFV_RELENG_PATH}}/prototypes/xci/file/ansible-role-requirements.yml {{OPENSTACK_OSA_PATH}}"
51   roles:
52     # TODO: this only works for ubuntu/xenial and need to be adjusted for other distros
53     - { role: configure-network, when: ansible_distribution_release == "xenial", src: "../template/opnfv.interface.j2", dest: "/etc/network/interfaces" }
54 - hosts: localhost
55   remote_user: root
56   tasks:
57     - name: Generate authorized_keys
58       shell: "/bin/cat /opnfv/root/.ssh/id_rsa.pub >> ../file/authorized_keys"
59     - name: Append public keys to authorized_keys
60       shell: "/bin/cat /root/.ssh/id_rsa.pub >> ../file/authorized_keys"