Initiate packetization of Testing reporting
[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
21 - hosts: opnfv
22   remote_user: root
23   vars_files:
24     - ../var/{{ ansible_os_family }}.yml
25     - ../var/opnfv.yml
26   tasks:
27     - name: Synchronize local development releng repository to XCI paths
28       synchronize:
29         src: "{{ OPNFV_RELENG_DEV_PATH }}"
30         dest: "{{ OPNFV_RELENG_PATH }}"
31         recursive: yes
32         delete: yes
33       when:
34         - OPNFV_RELENG_DEV_PATH != ""
35     - name: Synchronize local development openstack-ansible repository to XCI paths
36       synchronize:
37         src: "{{ OPENSTACK_OSA_DEV_PATH }}"
38         dest: "{{ OPENSTACK_OSA_PATH }}"
39         recursive: yes
40         delete: yes
41       when:
42         - OPENSTACK_OSA_DEV_PATH != ""
43
44 - hosts: opnfv
45   remote_user: root
46   vars_files:
47     - ../var/{{ ansible_os_family }}.yml
48     - ../var/flavor-vars.yml
49     - ../var/opnfv.yml
50   roles:
51     # TODO: this only works for ubuntu/xenial and need to be adjusted for other distros
52     - { role: configure-network, when: ansible_distribution_release == "xenial", src: "../template/opnfv.interface.j2", dest: "/etc/network/interfaces" }
53   tasks:
54     - name: generate SSH keys
55       shell: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""
56       args:
57         creates: /root/.ssh/id_rsa
58     - name: ensure ssh key storage directory exists
59       file:
60         path: "{{ OPNFV_SSH_HOST_KEYS_PATH }}"
61         state: directory
62     - name: fetch public key
63       fetch: src="/root/.ssh/id_rsa.pub" dest="{{ OPNFV_SSH_HOST_KEYS_PATH }}"
64     - name: copy flavor inventory
65       shell: "/bin/cp -rf {{XCI_FLAVOR_ANSIBLE_FILE_PATH}}/inventory {{OPNFV_RELENG_PATH}}/prototypes/xci/playbooks"
66     - name: copy flavor vars
67       shell: "/bin/cp -rf {{XCI_FLAVOR_ANSIBLE_FILE_PATH}}/flavor-vars.yml {{OPNFV_RELENG_PATH}}/prototypes/xci/var"
68     - name: copy openstack_deploy
69       shell: "/bin/cp -rf {{OPENSTACK_OSA_PATH}}/etc/openstack_deploy {{OPENSTACK_OSA_ETC_PATH}}"
70     - name: copy openstack_user_config.yml
71       shell: "/bin/cp -rf {{XCI_FLAVOR_ANSIBLE_FILE_PATH}}/openstack_user_config.yml {{OPENSTACK_OSA_ETC_PATH}}"
72     - name: copy user_variables.yml
73       shell: "/bin/cp -rf {{XCI_FLAVOR_ANSIBLE_FILE_PATH}}/user_variables.yml {{OPENSTACK_OSA_ETC_PATH}}"
74     - name: copy cinder.yml
75       shell: "/bin/cp -rf {{OPNFV_RELENG_PATH}}/prototypes/xci/file/cinder.yml {{OPENSTACK_OSA_ETC_PATH}}/env.d"
76     # TODO: We need to get rid of this as soon as the issue is fixed upstream
77     - name: change the haproxy state from disable to enable
78       replace:
79         dest: "{{OPENSTACK_OSA_PATH}}/playbooks/os-keystone-install.yml"
80         regexp: '(\s+)haproxy_state: disabled'
81         replace: '\1haproxy_state: enabled'
82     - name: copy OPNFV OpenStack playbook
83       shell: "/bin/cp -rf {{OPNFV_RELENG_PATH}}/prototypes/xci/file/setup-openstack.yml {{OPENSTACK_OSA_PATH}}/playbooks"
84     - name: copy OPNFV role requirements
85       shell: "/bin/cp -rf {{OPNFV_RELENG_PATH}}/prototypes/xci/file/ansible-role-requirements.yml {{OPENSTACK_OSA_PATH}}"
86     - name: bootstrap ansible on opnfv host
87       command: "/bin/bash ./scripts/bootstrap-ansible.sh"
88       args:
89         chdir: "{{OPENSTACK_OSA_PATH}}"
90     - name: generate password token
91       command: "python pw-token-gen.py --file {{OPENSTACK_OSA_ETC_PATH}}/user_secrets.yml"
92       args:
93         chdir: "{{OPENSTACK_OSA_PATH}}/scripts"
94 - hosts: localhost
95   remote_user: root
96   vars_files:
97     - ../var/opnfv.yml
98   tasks:
99     - name: Generate authorized_keys
100       shell: "/bin/cat {{ OPNFV_SSH_HOST_KEYS_PATH }}/opnfv/root/.ssh/id_rsa.pub >> ../file/authorized_keys"
101     - name: Append public keys to authorized_keys
102       shell: "/bin/cat {{ ansible_env.HOME }}/.ssh/id_rsa.pub >> ../file/authorized_keys"