From 4a6cacaeee87bcf64ca5dad71159067563b1964a Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Thu, 10 Jan 2019 13:06:58 +0100 Subject: [PATCH] Make libvirt role usable by zuul reproducer - Add become true to create /opt/vm_imaves - Install libvirt packages without with_items - Remove delgetate_to at password copy To check libvirt results https://review.rdoproject.org/r/#/c/18121/ look for the -libvirt job Story: https://tree.taiga.io/project/tripleo-ci-board/task/470?kanban-status=1447276 Change-Id: I7fb6a5e153691262ac404d5ab17f4baa2f7ffb3c --- roles/libvirt/setup/common/tasks/main.yml | 2 ++ .../setup/overcloud/tasks/libvirt_nodepool.yml | 13 ++++++++++++- .../overcloud/tasks/vars/libvirt_nodepool_vars.yml | 2 +- roles/libvirt/teardown/nodes/tasks/main.yml | 2 +- roles/parts/libvirt/tasks/main.yml | 3 +-- .../templates/ssh_config_no_undercloud.j2 | 2 +- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/roles/libvirt/setup/common/tasks/main.yml b/roles/libvirt/setup/common/tasks/main.yml index bc34193d8..e492dc3f6 100644 --- a/roles/libvirt/setup/common/tasks/main.yml +++ b/roles/libvirt/setup/common/tasks/main.yml @@ -3,9 +3,11 @@ # Note: the virt_pool module is not working properly on rhel-7.2 # https://bugs.launchpad.net/tripleo-quickstart/+bug/1597905 - name: ensure libvirt volume path exists + become: true file: path: "{{ libvirt_volume_path }}" state: directory + mode: 0755 - name: Check volume pool command: > diff --git a/roles/libvirt/setup/overcloud/tasks/libvirt_nodepool.yml b/roles/libvirt/setup/overcloud/tasks/libvirt_nodepool.yml index 03ed304cc..62ff3cb49 100644 --- a/roles/libvirt/setup/overcloud/tasks/libvirt_nodepool.yml +++ b/roles/libvirt/setup/overcloud/tasks/libvirt_nodepool.yml @@ -56,7 +56,6 @@ register: hash - name: Copy generated password to file - delegate_to: localhost copy: content: "{{ hash.stdout }}" dest: "{{ working_dir }}/pwtemp" @@ -190,6 +189,12 @@ subnode_public_ip: "{{ subnode_0_ip }}" ansible_python_interpreter: "{{ python_interpreter|default('/usr/bin/python') }}" +- name: Add subnode-0 to known_hosts + known_hosts: + name: "{{ subnode_0_ip }}" + key: "{{ lookup('pipe', 'ssh-keyscan + -t ecdsa-sha2-nistp256 ' + subnode_0_ip) }}" + - name: Set hostname correctly for subnode-0 delegate_to: subnode-0 shell: > @@ -231,6 +236,12 @@ subnode_public_ip: "{{ subnode_1_ip }}" ansible_python_interpreter: "{{ python_interpreter|default('/usr/bin/python') }}" +- name: Add subnode-1 to known_hosts + known_hosts: + name: "{{ subnode_1_ip }}" + key: "{{ lookup('pipe', 'ssh-keyscan + -t ecdsa-sha2-nistp256 ' + subnode_1_ip) }}" + - name: Set hostname correctly for subnode-1 delegate_to: subnode-1 shell: > diff --git a/roles/libvirt/setup/overcloud/tasks/vars/libvirt_nodepool_vars.yml b/roles/libvirt/setup/overcloud/tasks/vars/libvirt_nodepool_vars.yml index a35d52f10..f887c277e 100644 --- a/roles/libvirt/setup/overcloud/tasks/vars/libvirt_nodepool_vars.yml +++ b/roles/libvirt/setup/overcloud/tasks/vars/libvirt_nodepool_vars.yml @@ -9,7 +9,7 @@ overcloud_nodes: - name: subnode-1 flavor: control -pub_key: "{{ lookup('env', 'HOME') }}/.ssh/id_rsa.pub" +pub_key: "~/.ssh/id_rsa.pub" image_fetch_dir: "{{ local_working_dir }}" libvirt_nodepool_vms: true create_instackenv_json: false diff --git a/roles/libvirt/teardown/nodes/tasks/main.yml b/roles/libvirt/teardown/nodes/tasks/main.yml index 0470497f9..13525d349 100644 --- a/roles/libvirt/teardown/nodes/tasks/main.yml +++ b/roles/libvirt/teardown/nodes/tasks/main.yml @@ -4,7 +4,7 @@ - name: Include vars for libvirt-nodepool include_vars: - file: ../roles/libvirt/setup/overcloud/tasks/vars/libvirt_nodepool_vars.yml + file: "{{ role_path }}/../../setup/overcloud/tasks/vars/libvirt_nodepool_vars.yml" when: libvirt_nodepool|default(false) - name: Check if libvirt is available diff --git a/roles/parts/libvirt/tasks/main.yml b/roles/parts/libvirt/tasks/main.yml index bb4138c3d..d8ac01614 100644 --- a/roles/parts/libvirt/tasks/main.yml +++ b/roles/parts/libvirt/tasks/main.yml @@ -16,9 +16,8 @@ # different list of packages. - name: Install packages for libvirt package: - name: "{{ item }}" + name: "{{ libvirt_packages }}" state: present - with_items: "{{ libvirt_packages }}" become: true - name: Start libvirtd diff --git a/roles/tripleo-inventory/templates/ssh_config_no_undercloud.j2 b/roles/tripleo-inventory/templates/ssh_config_no_undercloud.j2 index 2a688d9c8..31e4d7556 100644 --- a/roles/tripleo-inventory/templates/ssh_config_no_undercloud.j2 +++ b/roles/tripleo-inventory/templates/ssh_config_no_undercloud.j2 @@ -1,4 +1,4 @@ -{% if hostvars[groups['virthost'][0]].ansible_host is defined %} +{% if groups.virthost is defined and hostvars[groups['virthost'][0]].ansible_host is defined %} Host virthost Hostname {{ hostvars[groups['virthost'][0]].ansible_host }}