diff --git a/playbooks/inventory/group_vars/all b/playbooks/inventory/group_vars/all index 1c47d6b44..7ddd89e07 100644 --- a/playbooks/inventory/group_vars/all +++ b/playbooks/inventory/group_vars/all @@ -8,6 +8,11 @@ mysql_password: # If testing is true, then the environment is setup for using libvirt # virtual machines for the hardware instead of real hardware. # testing: true +# +# Normally this user should be ubuntu, however if cirros is used, +# a user may wish to define a specific user for testing VM +# connectivity during atest sequence +testing_user: ubuntu http_boot_folder: /httpboot ssh_public_key_path: "{{ ansible_env.HOME }}/.ssh/id_rsa.pub" latest_os_ironic_url: https://raw.githubusercontent.com/juliakreger/ansible-modules-extras/features/new-openstack/cloud/os_ironic.py diff --git a/playbooks/roles/bifrost-prepare-for-test/tasks/main.yml b/playbooks/roles/bifrost-prepare-for-test/tasks/main.yml index 26fcf51da..ffb0499b1 100644 --- a/playbooks/roles/bifrost-prepare-for-test/tasks/main.yml +++ b/playbooks/roles/bifrost-prepare-for-test/tasks/main.yml @@ -16,6 +16,10 @@ wait_for: state=started port=22 host={{ item.split(',')[11] }} timeout=900 with_lines: - cat {{ baremetal_csv_file }} +- name: "Pausing for 4 seconds to allow testvm to become fully operational and to avoid any potential sshd startup race." + # NOTE(TheJulia): AFAIK sshd opens it's socket and then loads/generates + # keys, which can become visible as a race, hence the four second pause. + pause: seconds=4 - name: "Adding testvms to Ansible Inventory" add_host: name="{{ item.split(',')[11] }}:22" groups=testvm with_lines: diff --git a/playbooks/roles/bifrost-test-vm/tasks/main.yml b/playbooks/roles/bifrost-test-vm/tasks/main.yml index 9f9bc632d..58cb528a5 100644 --- a/playbooks/roles/bifrost-test-vm/tasks/main.yml +++ b/playbooks/roles/bifrost-test-vm/tasks/main.yml @@ -13,7 +13,10 @@ # limitations under the License. --- - name: "Execute ping step to verify connectivity and login to the host. If this fails, the configdrive may not have loaded." - ping: + # NOTE(TheJulia): This is executed as a raw command to validate the remote + # hostname. This is because cirros lacks sftp support. + raw: hostname + register: instance_hostname - name: 'Error if hostname is set to "ubuntu"' # TODO: Presently this step is unable to cycle through each host and verify # it's hostname is properly set. Perhaps if there was some way to extract @@ -22,5 +25,7 @@ # # TODO: As time goes on, we may move to leveraging inventory information # which will allow this role to do validation of the remote node. - fail: msg='If this fails, the configdrive may not have been used as the hostname was set to the default "ubuntu"' - when: ansible_hostname == "ubuntu" + # NOTE(TheJulia): If we go down the path of additional validation, we need + # to keep things like Cirros in mind. + fail: msg='If this fails, the configdrive may not have been used as the hostname was set to the default.' + when: '"ubuntu" in instance_hostname.stdout or "cirros" in instance_hostname.stdout' diff --git a/playbooks/roles/ironic-install/defaults/main.yml b/playbooks/roles/ironic-install/defaults/main.yml index 0561a202b..b0795ed40 100644 --- a/playbooks/roles/ironic-install/defaults/main.yml +++ b/playbooks/roles/ironic-install/defaults/main.yml @@ -54,3 +54,5 @@ deploy_kernel_url: "http://{{ hostvars[inventory_hostname]['ansible_' + network_ deploy_ramdisk_url: "http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:8080/coreos_production_pxe_image-oem.cpio.gz" deploy_image_filename: "trusty-server-cloudimg-amd64.img" deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}" +# Use cirros instead of building an image via diskimage-builder +use_cirros: false diff --git a/playbooks/roles/ironic-install/tasks/main.yml b/playbooks/roles/ironic-install/tasks/main.yml index b8ec6a184..822daaf24 100644 --- a/playbooks/roles/ironic-install/tasks/main.yml +++ b/playbooks/roles/ironic-install/tasks/main.yml @@ -235,6 +235,13 @@ - name: "Download CoreOS image" get_url: url=http://tarballs.openstack.org/ironic-python-agent/coreos/files/coreos_production_pxe_image-oem.cpio.gz dest={{ http_boot_folder }}/coreos_production_pxe_image-oem.cpio.gz when: test_core_os_image_present.stat.exists == false +- name: "Download cirros to use for deployment if requested" + get_url: url=http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img dest="{{deploy_image}}" + # TODO(TheJulia): We may want to revise any boolean operators to + # comparison statements like the one below when they are able to be + # set via the command line as there are oddities across ansible + # versions with auto-translation of true/false values. + when: use_cirros == true or "'true' in use_cirros" - name: "Test if Ubuntu 14.04 server cloud amd64 is present" stat: path={{ deploy_image }} register: test_os_image_present diff --git a/playbooks/test-bifrost.yaml b/playbooks/test-bifrost.yaml index 47c4561c1..51b213aad 100644 --- a/playbooks/test-bifrost.yaml +++ b/playbooks/test-bifrost.yaml @@ -45,8 +45,8 @@ - hosts: testvm name: "Tests connectivity to the VM" sudo: no - gather_facts: yes - remote_user: ubuntu + gather_facts: no + remote_user: "{{testing_user}}" roles: - role: bifrost-test-vm - hosts: localhost diff --git a/scripts/test-bifrost.sh b/scripts/test-bifrost.sh index 89f3ccf1e..b2ca558a2 100755 --- a/scripts/test-bifrost.sh +++ b/scripts/test-bifrost.sh @@ -20,7 +20,7 @@ ansible-playbook -vvvv -i inventory/localhost test-bifrost.yaml --syntax-check - set +e # Execute test playbook -ansible-playbook -vvvv -i inventory/localhost test-bifrost.yaml +ansible-playbook -vvvv -i inventory/localhost test-bifrost.yaml -e use_cirros=true -e testing_user=cirros EXITCODE=$? if [ $EXITCODE != 0 ]; then echo "*************************"