ansible bootstrap variables cannot be overridden once for multiple hosts at the same time

Bug #1832045 reported by Allain Legacy
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
StarlingX
Fix Released
Medium
Allain Legacy

Bug Description

Brief Description
-----------------
The Ansible bootstrap playbook defines some variables in host_vars/default.yml. Currently, those variables can be overridden on a per-host basis in an inventory_hostname.yml file. For variables that are, by nature, host specific that mechanism is fine, but there are variables that an end user may want to override on a per-site basis for many hosts without needing to manage the same change for many hosts. For example, a site may have local requirements for "dns_servers" or "docker_registries" so it would be more convenient to override those variables once in a single file and have that change apply to multiple hosts.

The main bootstrap.yml can be modified to insert an additional "include_vars" task to take variables from a site local file. See the following example where a new line has been inserted *before* the inventory_hostname include_vars task.

  pre_tasks:
    - include_vars: "{{ override_files_dir }}/secret"
      failed_when: false
    - include_vars: "{{ override_files_dir }}/site.yml"
      failed_when: false
    - include_vars: "{{ override_files_dir }}/{{ inventory_hostname }}.yml"
      failed_when: false

This order is important to ensure that an end user can still apply a per-host override that eclipses a per-site override.

Severity
--------
Minor

Steps to Reproduce
------------------
n/a

Expected Behavior
------------------
It should be possible to override one or more variables on a per-site basis using a single statement per variable.

Actual Behavior
----------------
A variable must be overridden for each host in the host inventory file.

Reproducibility
---------------
100%

System Configuration
--------------------
Any

Branch/Pull Time/Commit
-----------------------
June 7 latest build.

Last Pass
---------
Unknown

Timestamp/Logs
--------------
N/A

Test Activity
-------------
Developer testing

Revision history for this message
Ghada Khalil (gkhalil) wrote :

Enhancement/Optimization for ansible deployment; useful for deploying multiple systems at once. Marking as release gating given the benefit and the small code change

Changed in starlingx:
assignee: nobody → Allain Legacy (alegacy)
importance: Undecided → Medium
status: New → Triaged
tags: added: stx.2.0 stx.config
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to config (master)

Reviewed: https://review.opendev.org/664608
Committed: https://git.openstack.org/cgit/starlingx/config/commit/?id=2905fd8bc0c0c03b4f7676448e76c78e980cc39d
Submitter: Zuul
Branch: master

commit 2905fd8bc0c0c03b4f7676448e76c78e980cc39d
Author: Allain Legacy <email address hidden>
Date: Tue Jun 11 07:54:58 2019 -0500

    playbookconfig: add variable include for site overrides

    Some playbook variables are site specific rather than host specific. For
    example "dns_servers" versus "external_oam_unit_0_address". It is
    cumbersome for an end user to have to override site specific variable in
    N different host files when it applies to all hosts in a specific site.

    The main play of the playbook is being extended to add an additional
    include so that a "site.yml" file can be imported with variable
    overrides specific to an entire site.

    The new "include_vars" is performed ahead of the host level
    "include_vars" so that if an end user still wants to override a site
    specific variable on a per-host basis that is still possible.

    Change-Id: I0ac49e9311af24d88d29dc381168a60c38f642cf
    Closes-Bug: #1832045
    Signed-off-by: Allain Legacy <email address hidden>

Changed in starlingx:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.