From f54c78e2c36d7db53260bc868b5b538cb8e9d911 Mon Sep 17 00:00:00 2001 From: Manuel Buil Date: Wed, 3 Oct 2018 18:18:05 +0200 Subject: [Baremetal] - Change roles and playbooks names A few playbooks and the create-vm-nodes role should change the name to reflect the new reality once the baremetal patches are merged. The playbooks that must change the name are: - xci-prepare-virtual.yml - xci-create-virtual.yml Change-Id: Iaed1f93561fa9d39c7916e0643a5445cdddf4f97 Signed-off-by: Manuel Buil --- xci/infra/bifrost/playbooks/xci-create-virtual.yml | 66 --------------- xci/infra/bifrost/playbooks/xci-prepare-env.yml | 93 ++++++++++++++++++++++ .../bifrost/playbooks/xci-prepare-virtual.yml | 93 ---------------------- xci/infra/bifrost/playbooks/xci-setup-nodes.yml | 66 +++++++++++++++ 4 files changed, 159 insertions(+), 159 deletions(-) delete mode 100644 xci/infra/bifrost/playbooks/xci-create-virtual.yml create mode 100644 xci/infra/bifrost/playbooks/xci-prepare-env.yml delete mode 100644 xci/infra/bifrost/playbooks/xci-prepare-virtual.yml create mode 100644 xci/infra/bifrost/playbooks/xci-setup-nodes.yml (limited to 'xci/infra/bifrost/playbooks') diff --git a/xci/infra/bifrost/playbooks/xci-create-virtual.yml b/xci/infra/bifrost/playbooks/xci-create-virtual.yml deleted file mode 100644 index 381c4fd4..00000000 --- a/xci/infra/bifrost/playbooks/xci-create-virtual.yml +++ /dev/null @@ -1,66 +0,0 @@ ---- -# SPDX-license-identifier: Apache-2.0 -############################################################################## -# 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: deployment_host - name: "Bootstrap XCI hardware resources and prepare provisioning environment" - gather_facts: yes - vars_files: - - "{{ pdf_file }}" - - "{{ idf_file }}" - - "{{ xci_path }}/xci/var/opnfv_vm_pdf.yml" - - "{{ xci_path }}/xci/var/opnfv_vm_idf.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" - - name: Synchronize local development bifrost repository to XCI paths - # command module is much faster than the copy module - synchronize: - src: "{{ openstack_bifrost_dev_path }}" - dest: "{{ xci_cache }}/repos/bifrost" - recursive: yes - delete: yes - when: - - openstack_bifrost_dev_path != "" - - name: combine opnfv/releng-xci and openstack/bifrost scripts/playbooks - 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-env.yml b/xci/infra/bifrost/playbooks/xci-prepare-env.yml new file mode 100644 index 00000000..b4ad8c0c --- /dev/null +++ b/xci/infra/bifrost/playbooks/xci-prepare-env.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' diff --git a/xci/infra/bifrost/playbooks/xci-prepare-virtual.yml b/xci/infra/bifrost/playbooks/xci-prepare-virtual.yml deleted file mode 100644 index b4ad8c0c..00000000 --- a/xci/infra/bifrost/playbooks/xci-prepare-virtual.yml +++ /dev/null @@ -1,93 +0,0 @@ -- 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' diff --git a/xci/infra/bifrost/playbooks/xci-setup-nodes.yml b/xci/infra/bifrost/playbooks/xci-setup-nodes.yml new file mode 100644 index 00000000..9c9c1016 --- /dev/null +++ b/xci/infra/bifrost/playbooks/xci-setup-nodes.yml @@ -0,0 +1,66 @@ +--- +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# 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: deployment_host + name: "Bootstrap XCI hardware resources and prepare provisioning environment" + gather_facts: yes + vars_files: + - "{{ pdf_file }}" + - "{{ idf_file }}" + - "{{ xci_path }}/xci/var/opnfv_vm_pdf.yml" + - "{{ xci_path }}/xci/var/opnfv_vm_idf.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-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" + - name: Synchronize local development bifrost repository to XCI paths + # command module is much faster than the copy module + synchronize: + src: "{{ openstack_bifrost_dev_path }}" + dest: "{{ xci_cache }}/repos/bifrost" + recursive: yes + delete: yes + when: + - openstack_bifrost_dev_path != "" + - name: combine opnfv/releng-xci and openstack/bifrost scripts/playbooks + 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' } -- cgit 1.2.3-korg