xci: Introduce XCI_LOOP variable to control what to do properly
[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     # TODO: this only works for ubuntu/xenial and need to be adjusted for other distros
21     - { role: configure-network, when: ansible_distribution_release == "xenial", src: "../template/opnfv.interface.j2", dest: "/etc/network/interfaces" }
22   tasks:
23     - name: generate SSH keys
24       shell: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""
25       args:
26         creates: /root/.ssh/id_rsa
27     - name: fetch public key
28       fetch: src="/root/.ssh/id_rsa.pub" dest="/"
29     - name: copy flavor inventory
30       shell: "/bin/cp -rf {{XCI_FLAVOR_ANSIBLE_FILE_PATH}}/inventory {{OPNFV_RELENG_PATH}}/prototypes/xci/playbooks"
31     - name: copy flavor vars
32       shell: "/bin/cp -rf {{XCI_FLAVOR_ANSIBLE_FILE_PATH}}/flavor-vars.yml {{OPNFV_RELENG_PATH}}/prototypes/xci/var"
33     - name: copy openstack_deploy
34       shell: "/bin/cp -rf {{OPENSTACK_OSA_PATH}}/etc/openstack_deploy {{OPENSTACK_OSA_ETC_PATH}}"
35     - name: copy openstack_user_config.yml
36       shell: "/bin/cp -rf {{XCI_FLAVOR_ANSIBLE_FILE_PATH}}/openstack_user_config.yml {{OPENSTACK_OSA_ETC_PATH}}"
37     - name: copy user_variables.yml
38       shell: "/bin/cp -rf {{XCI_FLAVOR_ANSIBLE_FILE_PATH}}/user_variables.yml {{OPENSTACK_OSA_ETC_PATH}}"
39     - name: copy cinder.yml
40       shell: "/bin/cp -rf {{OPNFV_RELENG_PATH}}/prototypes/xci/file/cinder.yml {{OPENSTACK_OSA_ETC_PATH}}/env.d"
41     - name: bootstrap ansible on opnfv host
42       command: "/bin/bash ./scripts/bootstrap-ansible.sh"
43       args:
44         chdir: "{{OPENSTACK_OSA_PATH}}"
45     - name: generate password token
46       command: "python pw-token-gen.py --file {{OPENSTACK_OSA_ETC_PATH}}/user_secrets.yml"
47       args:
48         chdir: "{{OPENSTACK_OSA_PATH}}/scripts"
49     # TODO: We need to get rid of this as soon as the issue is fixed upstream
50     - name: change the haproxy state from disable to enable
51       replace:
52         dest: "{{OPENSTACK_OSA_PATH}}/playbooks/os-keystone-install.yml"
53         regexp: '(\s+)haproxy_state: disabled'
54         replace: '\1haproxy_state: enabled'
55     - name: copy OPNFV OpenStack playbook
56       shell: "/bin/cp -rf {{OPNFV_RELENG_PATH}}/prototypes/xci/file/setup-openstack.yml {{OPENSTACK_OSA_PATH}}/playbooks"
57     # Copy pinned role requirements if we are running as part of daily CI loop
58     - name: copy OPNFV role requirements
59       shell: "/bin/cp -rf {{OPNFV_RELENG_PATH}}/prototypes/xci/file/ansible-role-requirements.yml {{OPENSTACK_OSA_PATH}}"
60       when: XCI_LOOP == "daily"
61 - hosts: localhost
62   remote_user: root
63   tasks:
64     - name: Generate authorized_keys
65       shell: "/bin/cat /opnfv/root/.ssh/id_rsa.pub >> ../file/authorized_keys"
66     - name: Append public keys to authorized_keys
67       shell: "/bin/cat /root/.ssh/id_rsa.pub >> ../file/authorized_keys"