
By default, Ansible injects a variable for every fact, prefixed with ansible_. This can result in a large number of variables for each host, which at scale can incur a performance penalty. Ansible provides a configuration option [0] that can be set to False to prevent this injection of facts. In this case, facts should be referenced via ansible_facts.<fact>. This change updates all references to Ansible facts within Kayobe from using individual fact variables to using the items in the ansible_facts dictionary. This allows users to disable fact variable injection in their Ansible configuration, which may provide some performance improvement. This change disables fact variable injection in the ansible configuration used in CI, to catch any attempts to use the injected variables. [0] https://docs.ansible.com/ansible/latest/reference_appendices/config.html#inject-facts-as-vars Story: 2007993 Task: 42464 Depends-On: https://review.opendev.org/c/openstack/kolla-ansible/+/791276 Change-Id: I14db53ed6e57d37bbd28dd5819e432e3fe6628b2
62 lines
2.3 KiB
YAML
62 lines
2.3 KiB
YAML
---
|
|
- name: Ensure Kolla container images are built
|
|
hosts: container-image-builders
|
|
vars:
|
|
# Set this to True to push images to the registry when built.
|
|
push_images: False
|
|
# Set this to True to skip using cache.
|
|
nocache: False
|
|
# Set this variable to a space-separated list of regexes to override the
|
|
# default set of images.
|
|
container_image_regexes: ""
|
|
kolla_build_log_path: "/var/log/kolla-build.log"
|
|
tasks:
|
|
- name: Set the container image sets to build if images regexes specified
|
|
set_fact:
|
|
container_image_sets:
|
|
- regexes: "{{ container_image_regexes }}"
|
|
when: container_image_regexes != ''
|
|
|
|
- name: Display the regexes for container images that will be built
|
|
debug:
|
|
msg: >
|
|
Building container images of type
|
|
'{{ item.type | default(kolla_install_type) }}' matching
|
|
'{{ item.regexes }}'. Build logs will be appended to
|
|
{{ kolla_build_log_path }}.
|
|
with_items: "{{ container_image_sets }}"
|
|
|
|
- name: Ensure Kolla build log file exists
|
|
file:
|
|
path: "{{ kolla_build_log_path }}"
|
|
state: touch
|
|
owner: "{{ ansible_facts.user_uid }}"
|
|
group: "{{ ansible_facts.user_gid }}"
|
|
become: True
|
|
|
|
- name: Login to docker registry
|
|
docker_login:
|
|
registry_url: "{{ kolla_docker_registry or omit }}"
|
|
username: "{{ kolla_docker_registry_username }}"
|
|
password: "{{ kolla_docker_registry_password }}"
|
|
reauthorize: yes
|
|
when:
|
|
- kolla_docker_registry_username is not none
|
|
- kolla_docker_registry_password is not none
|
|
|
|
- name: Ensure Kolla container images are built
|
|
shell:
|
|
cmd: >
|
|
set -o pipefail &&
|
|
. {{ kolla_venv }}/bin/activate &&
|
|
kolla-build
|
|
--config-dir {{ kolla_build_config_path }}
|
|
{% if item.type is defined %}--type {{ item.type }}{% endif %}
|
|
{% if kolla_docker_registry is not none %}--registry {{ kolla_docker_registry }}{% endif %}
|
|
{% if push_images | bool %}--push{% endif %}
|
|
{% if nocache | bool %}--nocache{% endif %}
|
|
{{ item.regexes }} 2>&1 | tee --append {{ kolla_build_log_path }}
|
|
executable: /bin/bash
|
|
with_items: "{{ container_image_sets }}"
|
|
when: item.regexes != ''
|