Ansible 2.0 compatibility

These changes allow the various playbooks to be executed by
Ansible 1.9.x and 2.0. This was necessary as 2.0 has a number
of changes to the YAML processor, and certain ways of doing
things have naturally had to change.

- Removed pass-through variable when a role is explicitly defined
  with variables passed through to it as updated yaml parser fails
  to handle appropriately.
- Defined a default dib_packages variable of an empty string.
- Changed stray boolean compare to use an is defined check as
  the the parser in Ansible 2.0 does not equate undefined to
  false.
- Explicitly defined the testing_user for the syntax check
  as the check fails without it.
- Revised MySQL module syntax usage to be compatible between
  Ansible 1.9.x and 2.0 development branches.
- Updated some conditionals making string compares with lookups
  which is apparently problematic in Ansible 2.0.

Depends-On: I9d5fa719793896cce00a69dafba738755b45b068
Depends-On: I23e902c8637e142fba23d71467225d48ee265253
Change-Id: I4fec7f44dd9d591388f345b3f449cb44b8e50744
Closes-Bug: 1469862
This commit is contained in:
Julia Kreger 2015-06-29 15:55:54 -04:00
parent 9909e00ede
commit 15e1c3f22e
9 changed files with 21 additions and 20 deletions

View File

@ -8,7 +8,7 @@
- { role: bifrost-prep-for-install, when: skip_install is not defined }
- bifrost-ironic-install
- { role: bifrost-create-dib-image, dib_imagename: "{{ http_boot_folder }}/ipa", build_ramdisk: false, dib_os_element: "{{ ipa_dib_os_element|default('debian') }}", dib_elements: "ironic-agent {{ ipa_extra_dib_elements | default('') }}", when: create_ipa_image | bool == true }
- { role: bifrost-create-dib-image, dib_imagename: "{{ deploy_image }}", dib_imagetype: "qcow2", dib_os_element: "{{ dib_os_element|default('debian') }}", dib_elements: "vm serial-console simple-init {{ extra_dib_elements|default('') }}", dib_packages: "{{ dib_packages|default('') }}", when: create_image_via_dib == true and transform_boot_image == false }
- { role: bifrost-create-dib-image, dib_imagename: "{{ deploy_image }}", dib_imagetype: "qcow2", dib_elements: "vm serial-console simple-init {{ extra_dib_elements|default('') }}", when: create_image_via_dib == true and transform_boot_image == false }
environment:
http_proxy: "{{ lookup('env','http_proxy') }}"
https_proxy: "{{ lookup('env','https_proxy') }}"

View File

@ -9,7 +9,9 @@
# ironic_db_password ironic user password for rabbit
ironic_db_password: aSecretPassword473z
# mysql_password: mysql root user password
# mysql_username: Default mysql admin username
mysql_username: root
# mysql_password: Default mysql admin user password
mysql_password:
# The path to the SSH key to be utilized for testing and burn-in

View File

@ -11,3 +11,4 @@ dib_clearenv: false
dib_notmpfs: false
dib_offline: false
dib_skipbase: false
dib_packages: ""

View File

@ -33,10 +33,10 @@
ansible_pkg_mgr: "dnf"
when: ansible_distribution == 'Fedora' and "{{ test_dnf.stat.exists|bool }}"
- name: "Install required packages"
action: "{{ ansible_pkg_mgr }} name={{item}} state=present"
action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
with_items: required_packages
- name: "Restart libvirt service"
service: name={{libvirt_service_name}} state=restarted
service: name="{{libvirt_service_name}}" state=restarted
- name: "Create virtual machines"
script: create_vm_nodes-for-role.sh
environment:

View File

@ -35,11 +35,11 @@
apt: update_cache=yes
when: ansible_os_family == 'Debian'
- name: "Install packages"
action: "{{ ansible_pkg_mgr }} name={{ item }}"
action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
with_items: required_packages
# Step required for Ubuntu 14.10
- name: "Install Ubuntu 14.10 (and later) packages"
action: "{{ ansible_pkg_mgr }} name={{ item }}"
action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
with_items:
- pxelinux
when: ansible_distribution_version|version_compare('14.10', '>=') and ansible_distribution == 'Ubuntu'
@ -88,12 +88,12 @@
- name: "Create ironic user in RabbitMQ"
rabbitmq_user: user=ironic password={{ ironic_db_password }} force=yes state=present configure_priv=.* write_priv=.* read_priv=.*
no_log: true
- name: "MySQL - Create database"
mysql_db: login_user={{ mysql_username }} login_password={{ mysql_password }} name=ironic state=present encoding=utf8
- name: "MySQL - Creating DB"
mysql_db: name=ironic state=present encoding=utf8 login_user="{{ mysql_username | default(None) }}" login_password="{{ mysql_password | default(None) }}"
register: test_created_db
- name: "MySQL - Create user for ironic"
mysql_user: login_user={{ mysql_username }} login_password={{ mysql_password }} name=ironic password={{ ironic_db_password }} priv=ironic.*:ALL state=present
- name: "Install ironic using pip"
- name: "MySQL - Creating user for Ironic"
mysql_user: name=ironic password='{{ ironic_db_password }}' priv=ironic.*:ALL state=present login_user="{{ mysql_username | default(None) }}" login_password="{{ mysql_password | default(None) }}"
- name: "Install Ironic using pip"
pip: name={{ ironic_git_folder }} state=latest
when: skip_install is not defined
- name: "Create an ironic service group"

View File

@ -13,7 +13,7 @@
- name: "Set ci_testing flag if a list of changes are found in the environment variables"
set_fact:
ci_testing: true
when: lookup('env', 'ZUUL_CHANGES') != ""
when: lookup('env', 'ZUUL_CHANGES') | length > 0
- name: "Set ci_testing_zuul if it appears we are running in upstream OpenStack CI"
set_fact:
ci_testing_zuul: true

View File

@ -23,11 +23,11 @@
# TODO(TheJulia) Fix the above paths to be consistent, because the NV job gets the dib
# folder cloned, while the gate job does not. Likely need to work out a semi-hybrid
# solution.
when: lookup('env', 'ZUUL_BRANCH') != ""
when: lookup('env', 'ZUUL_BRANCH') | length > 0
- name: "Set ci_testing_zuul_changes if ZUUL_CHANGES is set"
set_fact:
ci_testing_zuul_changes: true
when: lookup('env', 'ZUUL_CHANGES') != ""
when: lookup('env', 'ZUUL_CHANGES') | length > 0
- name: "Override the ipv4_gateway setting"
set_fact:
ipv4_gateway: "192.168.122.1"
@ -58,7 +58,7 @@
# do not support ramdisk-image-create as they invoke steps to cleanup
# the ramdisk which causes ramdisk-image-create to believe it failed.
- { role: bifrost-create-dib-image, dib_imagename: "{{ http_boot_folder }}/ipa", build_ramdisk: false, dib_os_element: "{{ ipa_dib_os_element|default('debian') }}", dib_elements: "ironic-agent {{ ipa_extra_dib_elements | default('') }}", when: create_ipa_image | bool == true }
- { role: bifrost-create-dib-image, dib_imagetype: "qcow2", dib_imagename: "{{deploy_image}}", dib_os_element: "{{ dib_os_element|default('debian') }}", dib_elements: "vm serial-console simple-init {{ extra_dib_elements|default('') }}", dib_packages: "{{ dib_packages|default('') }}", when: create_image_via_dib == true and transform_boot_image == false }
- { role: bifrost-create-dib-image, dib_imagetype: "qcow2", dib_imagename: "{{deploy_image}}", dib_os_element: "debian", dib_elements: "vm serial-console simple-init {{ extra_dib_elements|default('') }}", when: create_image_via_dib == true and transform_boot_image == false }
environment:
http_proxy: "{{ lookup('env','http_proxy') }}"
https_proxy: "{{ lookup('env','https_proxy') }}"

View File

@ -2,10 +2,8 @@
set -e
ANSIBLE_GIT_URL=${ANSIBLE_GIT_URL:-https://github.com/ansible/ansible.git}
# NOTE(TheJulia): Switching to Ansible stable-1.9 branch as the development
# branch is undergoing some massive changes and we are seeing odd failures
# that we should not be seeing. Until devel has stabilized, we should stay
# on the stable branch.
# Note(TheJulia): Presently defaulting to stable-1.9, although the syntax
# is compatible with the Ansible devel branch as of 20150923.
ANSIBLE_GIT_BRANCH=${ANSIBLE_GIT_BRANCH:-stable-1.9}
if [ -x '/usr/bin/apt-get' ]; then

View File

@ -26,7 +26,7 @@ cd $BIFROST_HOME/playbooks
# Syntax check of dynamic inventory test path
ansible-playbook -vvvv -i inventory/localhost test-bifrost-create-vm.yaml --syntax-check --list-tasks
ansible-playbook -vvvv -i inventory/localhost test-bifrost-dynamic.yaml --syntax-check --list-tasks
ansible-playbook -vvvv -i inventory/localhost test-bifrost-dynamic.yaml --syntax-check --list-tasks -e testing_user=cirros
# Create the test VM
ansible-playbook -vvvv -i inventory/localhost test-bifrost-create-vm.yaml