From 7869e67bd834bfbc4ff66675416248a47cc7f6fa Mon Sep 17 00:00:00 2001 From: Michael Davies Date: Mon, 18 Jan 2016 03:57:40 +0000 Subject: [PATCH] Refactoring post andymccr review and suggestions --- defaults/main.yml | 14 +++++-- ...stall.yml => ironic_conductor_install.yml} | 0 tasks/ironic_db_setup.yml | 35 +++++++++++----- tasks/ironic_install.yml | 40 ++++++++++++++----- tasks/ironic_post_install.yml | 3 -- tasks/main.yml | 4 +- tasks/python_ironicclient_install.yml | 39 +++++++++++++----- 7 files changed, 95 insertions(+), 40 deletions(-) rename tasks/{ironic_conductor_pre_install.yml => ironic_conductor_install.yml} (100%) diff --git a/defaults/main.yml b/defaults/main.yml index d6e837fd..43367412 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -49,10 +49,10 @@ ironic_service_names: ironic_standalone: True # Database -ironic_database_user: ironic -ironic_database_database: ironic -ironic_database_address: localhost -ironic_database_password: gu1d0 +ironic_galera_user: ironic +ironic_galera_database: ironic +ironic_galera_address: localhost +ironic_galera_password: gu1d0 # TBD(mrda): need to handle this a little better :) database_root_user: root @@ -94,6 +94,12 @@ ironic_common_apt_packages: ironic_common_pip_packages: - virtualenvwrapper +ironic_pip_packages: + - ironic + +python_ironicclient_pip_packages: + - python_ironicclient + ironic_conductor_apt_packages: - libmysqlclient-dev - libxml2-dev diff --git a/tasks/ironic_conductor_pre_install.yml b/tasks/ironic_conductor_install.yml similarity index 100% rename from tasks/ironic_conductor_pre_install.yml rename to tasks/ironic_conductor_install.yml diff --git a/tasks/ironic_db_setup.yml b/tasks/ironic_db_setup.yml index 0d045b95..7dd6fa8a 100644 --- a/tasks/ironic_db_setup.yml +++ b/tasks/ironic_db_setup.yml @@ -15,27 +15,29 @@ - name: Create database for ironic mysql_db: - #login_user: "{{ database_root_user }}" - #login_password: "{{ database_root_password }}" - #login_host: "{{ ironic_database_address }}" - name: "{{ ironic_database_database }}" + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ ironic_galera_address }}" + name: "{{ ironic_galera_database }}" state: "present" + register: ironic_db tags: - ironic-db-setup - name: Grant access to the DB mysql_user: - #login_user: "{{ database_root_user }}" - #login_password: "{{ database_root_password }}" - #login_host: "{{ ironic_database_address }}" - name: "{{ ironic_database_user }}" - password: "{{ ironic_database_password }}" + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ ironic_database_address }}" + name: "{{ ironic_galera_user }}" + password: "{{ ironic_galera_password }}" host: "{{ item }}" state: "present" - priv: "{{ ironic_database_database }}.*:ALL" + priv: "{{ ironic_galera_database }}.*:ALL" with_items: - "localhost" - "%" + when: ironic_db.changed == True tags: - ironic-db-setup @@ -45,7 +47,18 @@ sudo_user: "{{ ironic_system_user_name }}" notify: - Restart ironic services - when: ironic_checkout.changed + when: ironic_db.changed == True + tags: + - ironic-db-setup + - ironic-conductor + +- name: Update database schema + command: "{{ ironic_bin }}/ironic-dbsync --config-file /etc/ironic/ironic.conf upgrade" + sudo: yes + sudo_user: "{{ ironic_system_user_name }}" + notify: + - Restart ironic services + when: ironic_db.changed == False tags: - ironic-db-setup - ironic-conductor diff --git a/tasks/ironic_install.yml b/tasks/ironic_install.yml index 113feee8..6bdec620 100644 --- a/tasks/ironic_install.yml +++ b/tasks/ironic_install.yml @@ -13,19 +13,37 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Install Ironic (python system library) - when: ironic_checkout.changed and not ironic_venv_enabled +- name: Install pip packages (venv) pip: - name: "file://{{ ironic_git_dest }}" + name: "{{ item }}" + state: present + virtualenv: "{{ ironic_venv_bin | dirname }}" + virtualenv_site_packages: "no" + extra_args: "{{ pip_install_options|default('') }}" + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: + - "{{ ironic_pip_packages }}" + when: + - ironic_venv_enabled | bool tags: - - ironic-api - - ironic-conductor + - ironic-install + - ironic-pip-packages -- name: Install Ironic (openstack venv) - when: ironic_checkout.changed and ironic_venv_enabled +- name: Install pip packages (no venv) pip: - name: "file://{{ ironic_git_dest }}" - virtualenv: "/openstack/venvs/ironic-{{ ironic_venv_tag }}" + name: "{{ item }}" + state: present + extra_args: "{{ pip_install_options|default('') }}" + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: + - "{{ ironic_pip_packages }}" + when: not ironic_venv_enabled | bool tags: - - ironic-api - - ironic-conductor + - ironic-install + - ironic-pip-packages diff --git a/tasks/ironic_post_install.yml b/tasks/ironic_post_install.yml index 0f4cdad4..a33f61cb 100644 --- a/tasks/ironic_post_install.yml +++ b/tasks/ironic_post_install.yml @@ -45,6 +45,3 @@ tags: - ironic-init - -# TODO(mrda): Configure rabbit if standalone - diff --git a/tasks/main.yml b/tasks/main.yml index ca439f60..e14ca294 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -14,9 +14,9 @@ # limitations under the License. - include: ironic_pre_install.yml - - include: ironic_get_source.yml - - include: ironic_conductor_pre_install.yml +# - include: ironic_get_source.yml - include: ironic_install.yml + - include: ironic_conductor_install.yml - include: python_ironicclient_install.yml - include: ironic_post_install.yml - include: ironic_conductor_post_install.yml diff --git a/tasks/python_ironicclient_install.yml b/tasks/python_ironicclient_install.yml index 174fae87..967a5adb 100644 --- a/tasks/python_ironicclient_install.yml +++ b/tasks/python_ironicclient_install.yml @@ -13,17 +13,38 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Install Python-Ironicclient (python system library) - when: python_ironicclient_checkout.changed and not ironic_venv_enabled +- name: Install pip packages (venv) pip: - name: "file://{{ python_ironicclient_git_dest }}" + name: "{{ item }}" + state: present + virtualenv: "{{ ironic_venv_bin | dirname }}" + virtualenv_site_packages: "no" + extra_args: "{{ pip_install_options|default('') }}" + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: + - "{{ python_ironicclient_pip_packages }}" + when: + - ironic_venv_enabled | bool tags: - - ironic-client + - ironicclient-install + - ironicclient-pip-packages -- name: Install Python-Ironicclient (openstack venv) - when: python_ironicclient_checkout.changed and ironic_venv_enabled +- name: Install pip packages (no venv) pip: - name: "file://{{ python_ironicclient_git_dest }}" - virtualenv: "/openstack/venvs/ironic-{{ ironic_venv_tag }}" + name: "{{ item }}" + state: present + extra_args: "{{ pip_install_options|default('') }}" + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: + - "{{ python_ironicclient_pip_packages }}" + when: not ironic_venv_enabled | bool tags: - - ironic-client + - ironicclient-install + - ironicclient-pip-packages +