From eead93830fc0d20996287439d765770d69bc533c Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 18 Sep 2017 20:16:43 +0100 Subject: xci: Move VM provisioning to xci-deploy.sh The bifrost-provision.sh script will provision machines using Ansible playbooks. If we run this script in an Ansible playbook, that means that we will run Ansible with Ansible and this can only lead to further confusion when debugging issues. As such, since we already have a script to provision machines, lets use it directly from the xci-deploy.sh script. This also reverts 3f04e1fd72b14420788af64b14c35a5f74727f82 which added virtualenv support in bifrost since that causes more problems than it fixes for the time being. Change-Id: Id82b7c06a2af28b66f64f1966227888227ec276f Signed-off-by: Markos Chandras --- bifrost/scripts/bifrost-provision.sh | 2 +- xci/playbooks/provision-vm-nodes.yml | 11 ----------- xci/xci-deploy.sh | 9 +++++++++ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/bifrost/scripts/bifrost-provision.sh b/bifrost/scripts/bifrost-provision.sh index df05c7ce..d4d1f96a 100755 --- a/bifrost/scripts/bifrost-provision.sh +++ b/bifrost/scripts/bifrost-provision.sh @@ -16,7 +16,7 @@ BIFROST_HOME=$SCRIPT_HOME/.. ANSIBLE_INSTALL_ROOT=${ANSIBLE_INSTALL_ROOT:-/opt/stack} ENABLE_VENV="false" USE_DHCP="false" -USE_VENV="true" +USE_VENV="false" BUILD_IMAGE=true PROVISION_WAIT_TIMEOUT=${PROVISION_WAIT_TIMEOUT:-3600} diff --git a/xci/playbooks/provision-vm-nodes.yml b/xci/playbooks/provision-vm-nodes.yml index 0419dcfc..3d88c5cb 100644 --- a/xci/playbooks/provision-vm-nodes.yml +++ b/xci/playbooks/provision-vm-nodes.yml @@ -90,14 +90,3 @@ command: "/bin/bash ./scripts/destroy-env.sh" args: chdir: "{{ OPENSTACK_BIFROST_PATH }}" - -- hosts: localhost - connection: local - vars_files: - - ../var/{{ ansible_os_family }}.yml - - ../var/opnfv.yml - tasks: - - name: create and provision VM nodes for the flavor {{ XCI_FLAVOR }} - command: "/bin/bash ./scripts/bifrost-provision.sh" - args: - chdir: "{{ OPENSTACK_BIFROST_PATH }}" diff --git a/xci/xci-deploy.sh b/xci/xci-deploy.sh index 6a661349..19f2c18a 100755 --- a/xci/xci-deploy.sh +++ b/xci/xci-deploy.sh @@ -115,7 +115,13 @@ fi echo "Info: Starting provisining VM nodes using openstack/bifrost" echo "-------------------------------------------------------------------------" cd $XCI_PATH/playbooks +# NOTE(hwoarang) we need newer ansible to work on the following playbook +sudo pip uninstall -y ansible || true +sudo -H pip uninstall -y ansible || true +sudo pip install ansible==${XCI_ANSIBLE_PIP_VERSION} ansible-playbook -i inventory provision-vm-nodes.yml +cd ${OPENSTACK_BIFROST_PATH} +bash ./scripts/bifrost-provision.sh echo "-----------------------------------------------------------------------" echo "Info: VM nodes are provisioned!" source $OPENSTACK_BIFROST_PATH/env-vars @@ -130,8 +136,11 @@ echo # - creates log directory # - copies flavor files such as playbook, inventory, and var file #------------------------------------------------------------------------------- + echo "Info: Configuring localhost for openstack-ansible" echo "-----------------------------------------------------------------------" +# NOTE(hwoarang) we need newer ansible to work on the OSA playbooks +sudo pip install --force-reinstall ansible==${XCI_ANSIBLE_PIP_VERSION} cd $XCI_PATH/playbooks ansible-playbook -i inventory configure-localhost.yml echo "-----------------------------------------------------------------------" -- cgit 1.2.3-korg From 14d5449ef8de17293f2524005d7c2262f0baa733 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Tue, 19 Sep 2017 21:59:25 +0100 Subject: xci: Gain elevated privileges to remove the XCI_DEVEL_ROOT directory This is similar to 0927671781f6875926dac2e5f4bb10816e67070c. We need elevated privileges to remove the XCI_DEVEL_ROOT directory so move this role to its own play. Change-Id: Ice4f030eeb28cd24a6166f11a5a792ab3df8880c Signed-off-by: Markos Chandras --- xci/file/aio/configure-opnfvhost.yml | 8 +++++++- xci/playbooks/configure-localhost.yml | 11 +++++++++++ xci/playbooks/configure-opnfvhost.yml | 12 ++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/xci/file/aio/configure-opnfvhost.yml b/xci/file/aio/configure-opnfvhost.yml index 708ad618..5ef19326 100644 --- a/xci/file/aio/configure-opnfvhost.yml +++ b/xci/file/aio/configure-opnfvhost.yml @@ -1,11 +1,17 @@ --- - hosts: opnfv remote_user: root - vars_files: + gather_facts: true + become: yes vars_files: - ../var/opnfv.yml roles: - role: remove-folders + +- hosts: opnfv + remote_user: root + vars_files: + - ../var/opnfv.yml - { role: clone-repository, project: "openstack/openstack-ansible", repo: "{{ OPENSTACK_OSA_GIT_URL }}", dest: "{{ OPENSTACK_OSA_PATH }}", version: "{{ OPENSTACK_OSA_VERSION }}" } tasks: - name: bootstrap ansible on opnfv host diff --git a/xci/playbooks/configure-localhost.yml b/xci/playbooks/configure-localhost.yml index 10dd6946..aebde61e 100644 --- a/xci/playbooks/configure-localhost.yml +++ b/xci/playbooks/configure-localhost.yml @@ -9,6 +9,7 @@ ############################################################################## - hosts: localhost connection: local + become: yes vars_files: - ../var/opnfv.yml pre_tasks: @@ -17,6 +18,16 @@ file: ../var/{{ ansible_os_family }}.yml roles: - role: remove-folders + +- hosts: localhost + connection: local + vars_files: + - ../var/opnfv.yml + pre_tasks: + - name: Load distribution variables + include_vars: + file: ../var/{{ ansible_os_family }}.yml + roles: - { role: clone-repository, project: "opnfv/releng-xci", repo: "{{ OPNFV_RELENG_GIT_URL }}", dest: "{{ OPNFV_RELENG_PATH }}", version: "{{ OPNFV_RELENG_VERSION }}" } - { role: clone-repository, project: "openstack/openstack-ansible-openstack_openrc", repo: "{{ OPENSTACK_OSA_OPENRC_GIT_URL }}", dest: "{{ OPENSTACK_OSA_OPENRC_PATH }}", version: "master" } - hosts: localhost diff --git a/xci/playbooks/configure-opnfvhost.yml b/xci/playbooks/configure-opnfvhost.yml index da478255..283aadcf 100644 --- a/xci/playbooks/configure-opnfvhost.yml +++ b/xci/playbooks/configure-opnfvhost.yml @@ -9,6 +9,7 @@ ############################################################################## - hosts: opnfv remote_user: root + become: yes vars_files: - ../var/flavor-vars.yml - ../var/opnfv.yml @@ -18,6 +19,17 @@ file: ../var/{{ ansible_os_family }}.yml roles: - role: remove-folders + +- hosts: opnfv + remote_user: root + vars_files: + - ../var/flavor-vars.yml + - ../var/opnfv.yml + pre_tasks: + - name: Load distribution variables + include_vars: + file: ../var/{{ ansible_os_family }}.yml + roles: - { role: clone-repository, project: "opnfv/releng-xci", repo: "{{ OPNFV_RELENG_GIT_URL }}", dest: "{{ OPNFV_RELENG_PATH }}", version: "{{ OPNFV_RELENG_VERSION }}" } - { role: clone-repository, project: "openstack/openstack-ansible", repo: "{{ OPENSTACK_OSA_GIT_URL }}", dest: "{{ OPENSTACK_OSA_PATH }}", version: "{{ OPENSTACK_OSA_VERSION }}" } -- cgit 1.2.3-korg From f2f978fd7a3346c0ba5323fdf22d8d105836ca44 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 18 Sep 2017 15:33:54 +0100 Subject: bifrost: scripts: Look for virtualbmc on bifrost virtualenv Since I94874d600a29247b7826324cc111901995df90dc, bifrost installs pip packages in virtualenv so we need to look there for virtualbmc if it's not currently installed on the host. Change-Id: Ia4c7e8a75c020dc00b920956495831cc77457876 Signed-off-by: Markos Chandras --- bifrost/scripts/destroy-env.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/bifrost/scripts/destroy-env.sh b/bifrost/scripts/destroy-env.sh index 87f792a5..f6eca4e3 100755 --- a/bifrost/scripts/destroy-env.sh +++ b/bifrost/scripts/destroy-env.sh @@ -19,12 +19,17 @@ rm -rf /opt/stack # HOME is normally set by sudo -H rm -rf ${HOME}/.config/openstack -# Delete all libvirt VMs and hosts from vbmc (look for a port number) -for vm in $(vbmc list | awk '/[0-9]/{{ print $2 }}'); do - virsh destroy $vm || true - virsh undefine $vm || true - vbmc delete $vm -done +# bifrost installs everything on venv so we need to look there if virtualbmc is not installed on the host. +if which vbmc &>/dev/null || { [[ -e /opt/stack/bifrost/bin/activate ]] && source /opt/stack/bifrost/bin/activate; }; then + # Delete all libvirt VMs and hosts from vbmc (look for a port number) + for vm in $(vbmc list | awk '/[0-9]/{{ print $2 }}'); do + virsh destroy $vm || true + virsh undefine $vm || true + vbmc delete $vm + done + which vbmc &>/dev/null || { [[ -e /opt/stack/bifrost/bin/activate ]] && deactivate; } +fi + # Destroy all XCI VMs if the previous operation failed [[ -n ${XCI_FLAVOR} ]] && \ for vm in ${TEST_VM_NODE_NAMES}; do -- cgit 1.2.3-korg From 3a281e5c91bf05d94361af1ff5818657d92a1bfd Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 18 Sep 2017 15:50:16 +0100 Subject: xci: playbooks: Include distribution var files dynamically This is a continuation of I0a49e2ed8d811bb40a99612462752f8691133e0f We need to convert these two plays to include the variable files dynamically similar to the rest of the playbook. Change-Id: I43203651ccafb03e015bfe4d1b075a7ee96b5adc Signed-off-by: Markos Chandras --- xci/playbooks/configure-localhost.yml | 2 -- xci/playbooks/configure-opnfvhost.yml | 1 - xci/playbooks/provision-vm-nodes.yml | 4 +++- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/xci/playbooks/configure-localhost.yml b/xci/playbooks/configure-localhost.yml index aebde61e..915d1959 100644 --- a/xci/playbooks/configure-localhost.yml +++ b/xci/playbooks/configure-localhost.yml @@ -32,7 +32,6 @@ - { role: clone-repository, project: "openstack/openstack-ansible-openstack_openrc", repo: "{{ OPENSTACK_OSA_OPENRC_GIT_URL }}", dest: "{{ OPENSTACK_OSA_OPENRC_PATH }}", version: "master" } - hosts: localhost connection: local - gather_facts: false vars_files: - ../var/opnfv.yml tasks: @@ -77,7 +76,6 @@ dest: "{{OPNFV_RELENG_PATH}}/xci/var" - hosts: localhost connection: local - gather_facts: false vars_files: - ../var/opnfv.yml tasks: diff --git a/xci/playbooks/configure-opnfvhost.yml b/xci/playbooks/configure-opnfvhost.yml index 283aadcf..84c0d827 100644 --- a/xci/playbooks/configure-opnfvhost.yml +++ b/xci/playbooks/configure-opnfvhost.yml @@ -150,7 +150,6 @@ shell: "/bin/cat {{ ansible_env.HOME }}/.ssh/id_rsa.pub >> ../file/authorized_keys" - hosts: opnfv - gather_facts: no remote_user: root vars_files: - ../var/flavor-vars.yml diff --git a/xci/playbooks/provision-vm-nodes.yml b/xci/playbooks/provision-vm-nodes.yml index 3d88c5cb..81fc5755 100644 --- a/xci/playbooks/provision-vm-nodes.yml +++ b/xci/playbooks/provision-vm-nodes.yml @@ -83,9 +83,11 @@ connection: local become: yes vars_files: - - ../var/{{ ansible_os_family }}.yml - ../var/opnfv.yml tasks: + - name: Load distribution variables + include_vars: + file: ../var/{{ ansible_os_family }}.yml - name: destroy VM nodes created by previous deployment command: "/bin/bash ./scripts/destroy-env.sh" args: -- cgit 1.2.3-korg