diff options
author | 2018-05-04 23:11:35 +0200 | |
---|---|---|
committer | 2018-06-28 20:03:00 +0100 | |
commit | 3d4ac3786772ec23791183b4c54a9d6fd922752e (patch) | |
tree | 5754b70b800c6161a347f3847fe229c07f7f2029 /xci/infra/bifrost/playbooks | |
parent | fd09da131991a99a886dd0c65969d30d81499511 (diff) |
Use PDF to set up the XCI VMs
This patch is doing the first work item of the spec:
https://github.com/opnfv/releng-xci/blob/master/docs/specs/infra_manager.rst
It creates the required VMs by XCI to afterwards deploy the VIM. It does that
by reading the pdf provided by the user.
- It is currently assumed that the OS for the VM will be installed in the first
disk of the node described by the pdf
- It is assumed that the opnfv VM characteristics are not described in the pdf
but in a similar document called opnfv_vm.yml
- All references to csv from bifrost-create-vm-nodes were removed
Change-Id: I46a85284e4ce7df21cbf66f66619b35f74251e68
Signed-off-by: Manuel Buil <mbuil@suse.com>
Co-Authored-by: Markos Chandras <mchandras@suse.de>
Diffstat (limited to 'xci/infra/bifrost/playbooks')
-rw-r--r-- | xci/infra/bifrost/playbooks/opnfv-virtual.yml (renamed from xci/infra/bifrost/playbooks/opnfv-virtual.yaml) | 69 | ||||
-rw-r--r-- | xci/infra/bifrost/playbooks/xci-create-virtual.yml (renamed from xci/infra/bifrost/playbooks/bootstrap-bifrost.yml) | 32 | ||||
-rw-r--r-- | xci/infra/bifrost/playbooks/xci-prepare-virtual.yml | 93 |
3 files changed, 174 insertions, 20 deletions
diff --git a/xci/infra/bifrost/playbooks/opnfv-virtual.yaml b/xci/infra/bifrost/playbooks/opnfv-virtual.yml index bb0daff6..68d76cfc 100644 --- a/xci/infra/bifrost/playbooks/opnfv-virtual.yaml +++ b/xci/infra/bifrost/playbooks/opnfv-virtual.yml @@ -7,11 +7,12 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## --- -- hosts: localhost - connection: local +- hosts: opnfv name: "Host and Ironic bootstrapping" become: yes gather_facts: yes + vars_files: + - "../vars/{{ ansible_os_family | lower }}.yml" pre_tasks: - name: Remove pre-existing leases file file: path=/var/lib/misc/dnsmasq.leases state=absent @@ -52,6 +53,19 @@ owner: 'root' group: 'root' when: use_prebuilt_images | bool == true + - name: Ensure /etc/hosts has good defaults + lineinfile: + create: yes + dest: "/etc/hosts" + regexp: "{{ item.regexp }}.*({{ ansible_hostname }}|localhost).*" + line: "{{ item.contents }}" + with_items: + - { regexp: '^127\.0\.0\.1', contents: '127.0.0.1 {{ ansible_hostname }} {{ ansible_fqdn }} localhost' } + - { regexp: '^::1', contents: '::1 {{ ansible_hostname }} {{ ansible_fqdn }} localhost ipv6-localhost ipv6-loopback' } + - name: Install required packages + package: + name: "{{ bifrost_required_devel_packages }}" + state: present roles: - role: bifrost-prep-for-install @@ -59,7 +73,9 @@ - role: bifrost-keystone-install - role: bifrost-ironic-install cleaning: false - testing: true + testing: false + enabled_hardware_types: ipmi + network_interface: "{{ ansible_default_ipv4.interface }}" # NOTE(TheJulia): While the next step creates a ramdisk, some elements # do not support ramdisk-image-create as they invoke steps to cleanup # the ramdisk which causes ramdisk-image-create to believe it failed. @@ -89,7 +105,6 @@ - transform_boot_image | bool == false - use_prebuilt_images | bool == false - role: bifrost-keystone-client-config - user: "{{ ansible_env.SUDO_USER }}" clouds: bifrost: config_username: "{{ ironic.keystone.default_username }}" @@ -107,18 +122,36 @@ vars: multinode_testing: "{{ inventory_dhcp | bool == true }}" become: no - connection: local - gather_facts: yes - pre_tasks: + gather_facts: False + tasks: + - name: Gathering facts + setup: + delegate_to: opnfv + delegate_facts: False - name: "Override default bifrost DNS if we are behind a proxy" set_fact: ipv4_nameserver: "192.168.122.1" when: lookup('env','http_proxy') != '' - roles: - - role: ironic-enroll-dynamic - - { role: ironic-inspect-node, when: inspect_nodes | default('false') | bool == true } - - role: bifrost-configdrives-dynamic - - role: bifrost-deploy-nodes-dynamic + - name: Find network interface in the OPNFV node + set_fact: + network_interface: "{{ ansible_default_ipv4.interface }}" + - import_role: + name: ironic-enroll-dynamic + private: True + delegate_to: opnfv + - import_role: + name: ironic-inspect-node + private: True + delegate_to: opnfv + when: inspect_nodes | default('false') | bool == true + - import_role: + name: bifrost-configdrives-dynamic + private: True + delegate_to: opnfv + - import_role: + name: bifrost-deploy-nodes-dynamic + private: True + delegate_to: opnfv environment: http_proxy: "{{ lookup('env','http_proxy') }}" https_proxy: "{{ lookup('env','https_proxy') }}" @@ -127,7 +160,13 @@ - hosts: baremetal name: "Deploy machines." become: no - connection: local serial: 1 - roles: - - role: bifrost-prepare-for-test-dynamic + gather_facts: False + tasks: + #- name: Gathering facts + #setup: + #delegate_to: opnfv + #delegate_facts: False + - import_role: + name: bifrost-prepare-for-test-dynamic + delegate_to: opnfv diff --git a/xci/infra/bifrost/playbooks/bootstrap-bifrost.yml b/xci/infra/bifrost/playbooks/xci-create-virtual.yml index 2153b3b3..043907fe 100644 --- a/xci/infra/bifrost/playbooks/bootstrap-bifrost.yml +++ b/xci/infra/bifrost/playbooks/xci-create-virtual.yml @@ -1,29 +1,42 @@ --- # SPDX-license-identifier: Apache-2.0 ############################################################################## -# Copyright (c) 2017 Ericsson AB and others. +# Copyright (c) 2018 SUSE LINUX GmbH. # 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: localhost - connection: local - gather_facts: true + +- hosts: deployment_host + name: "Bootstrap XCI hardware resources and prepare provisioning environment" + gather_facts: yes vars_files: + - "{{ xci_path }}/xci/var/pdf.yml" + - "{{ xci_path }}/xci/var/opnfv_vm.yml" - "{{ xci_path }}/xci/var/opnfv.yml" pre_tasks: - name: Load distribution variables include_vars: file: "{{ xci_path }}/xci/var/{{ ansible_os_family }}.yml" roles: + - role: create-vm-nodes + become: yes - role: clone-repository project: "opnfv/bifrost" repo: "{{ openstack_bifrost_git_url }}" dest: "{{ xci_cache }}/repos/bifrost" version: "{{ openstack_bifrost_version }}" - tasks: + - name: Wait for host to come back to life + local_action: + module: wait_for + host: "{{ opnfv_vm_ip }}" + delay: 15 + state: started + port: 22 + connect_timeout: 10 + timeout: 180 - name: Load distribution variables include_vars: file: "{{ xci_path }}/xci/var/{{ ansible_os_family }}.yml" @@ -40,3 +53,12 @@ copy: src: "{{ xci_path}}/xci/infra/bifrost/" dest: "{{ xci_cache }}/repos/bifrost" + - name: "Ensure /etc/hosts has good defaults" + lineinfile: + dest: "/etc/hosts" + regexp: "{{ item.regexp }}.*({{ ansible_hostname }}|localhost).*" + line: "{{ item.contents }}" + become: yes + with_items: + - { regexp: '^127\.0\.0\.1', contents: '127.0.0.1 {{ ansible_hostname }} {{ ansible_fqdn }} localhost' } + - { regexp: '^::1', contents: '::1 {{ ansible_hostname }} {{ ansible_fqdn }} localhost ipv6-localhost ipv6-loopback' } diff --git a/xci/infra/bifrost/playbooks/xci-prepare-virtual.yml b/xci/infra/bifrost/playbooks/xci-prepare-virtual.yml new file mode 100644 index 00000000..b4ad8c0c --- /dev/null +++ b/xci/infra/bifrost/playbooks/xci-prepare-virtual.yml @@ -0,0 +1,93 @@ +- name: Prepare deployment host + hosts: deployment_host + gather_facts: True + tasks: + - name: Ensure common private key has correct permissions + file: + path: "{{ xci_path }}/xci/scripts/vm/id_rsa_for_dib" + mode: "0600" + + - name: Remove host from known_hosts file if necessary + shell: + ssh-keygen -R {{ hostvars['opnfv'].ip }} + failed_when: false + +- name: Prepare the OPNFV host + hosts: opnfv + gather_facts: True + vars_files: + - "{{ xci_path }}/xci/var/opnfv.yml" + tasks: + - name: Copy bifrost inventory file + copy: + src: /tmp/baremetal.json + dest: /tmp/baremetal.json + + - name: Configure SSH key for devuser + user: + name: devuser + generate_ssh_key: yes + ssh_key_bits: 2048 + ssh_key_comment: xci + ssh_key_type: rsa + state: present + + - name: Determine local user + become: no + local_action: command whoami + changed_when: False + register: _ansible_user + + - name: Fetch local SSH key + delegate_to: localhost + become: no + slurp: + src: "/home/{{ _ansible_user.stdout }}/.ssh/id_rsa.pub" + register: _local_ssh_key + + - name: "Configure {{ inventory_hostname }} authorized_keys file (devuser)" + authorized_key: + exclusive: no + user: devuser + state: present + manage_dir: yes + key: "{{ _local_ssh_key['content'] | b64decode }}" + comment: "deployer's key" + + - name: "Configure {{ inventory_hostname }} authorized_keys file (root)" + authorized_key: + exclusive: no + user: root + state: present + manage_dir: yes + key: "{{ _local_ssh_key['content'] | b64decode }}" + comment: "deployer's key" + become: yes + + - name: Ensure /httpboot directory exists + file: + path: /httpboot + state: directory + become: yes + + - name: Copy original qcow2 image to OPNFV VM + synchronize: + src: "{{ xci_cache }}/{{ item }}" + dest: /httpboot/ + recursive: yes + delete: yes + with_items: + - "deployment_image.qcow2" + - "deployment_image.qcow2.sha256.txt" + become: yes + + - name: Configure DNS on openSUSE + block: + - stat: + path: /etc/resolv.conf.netconfig + register: _resolv_conf_netconfig + - shell: | + mv /etc/resolv.conf.netconfig /etc/resolv.conf + become: yes + when: _resolv_conf_netconfig.stat.exists + when: ansible_pkg_mgr == 'zypper' |