tripleo-ansible/tripleo_ansible/playbooks/tripleo_nova_image_cache.yml
Oliver Walsh 359ef43f94 Stop relying on future mtime in tripleo_nova_image_cache
The tripleo_nova_image_cache role was relying on a future mtime to convince
nova image cleanup logic to skip a specific image that we want to pre-cache.
This works well on nodes that are not currently hosting an instance of the
image, however if there is an instance using it then nova will reset the mtime
every 40 minutes (by default).

As a result it's not possible to provide fine grained control of the caching.
We can just ensure the image exists on the host with an mtime of now.
It should remain cache for at least remove_unused_original_minimum_age_seconds
from nova.conf (default 86400).

Change-Id: If836759020bcaeb0d3af47f2af7f98ff2150b606
2020-09-02 00:34:44 +01:00

58 lines
2.5 KiB
YAML

---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: TripleO Nova image cache management
hosts: "{{ tripleo_nova_image_cache_plan + '_nova_compute' if tripleo_nova_image_cache_plan|default('') else 'nova_compute'}}"
environment:
# export everything in overcloudrc for openstacksdk
NOVA_VERSION: "{{ lookup('env', 'NOVA_VERSION') }}"
COMPUTE_API_VERSION: "{{ lookup('env', 'COMPUTE_API_VERSION') }}"
OS_USERNAME: "{{ lookup('env', 'OS_USERNAME') }}"
OS_PROJECT_NAME: "{{ lookup('env', 'OS_PROJECT_NAME') }}"
OS_USER_DOMAIN_NAME: "{{ lookup('env', 'OS_USER_DOMAIN_NAME') }}"
OS_PROJECT_DOMAIN_NAME: "{{ lookup('env', 'OS_PROJECT_DOMAIN_NAME') }}"
OS_NO_CACHE: "{{ lookup('env', 'OS_NO_CACHE') }}"
no_proxy: "{{ lookup('env', 'no_proxy') }}"
OS_AUTH_TYPE: "{{ lookup('env', 'OS_AUTH_TYPE') }}"
OS_PASSWORD: "{{ lookup('env', 'OS_PASSWORD') }}"
OS_AUTH_URL: "{{ lookup('env', 'OS_AUTH_URL') }}"
OS_IDENTITY_API_VERSION: "{{ lookup('env', 'OS_IDENTITY_API_VERSION') }}"
OS_IMAGE_API_VERSION: "{{ lookup('env', 'OS_IMAGE_API_VERSION') }}"
OS_VOLUME_API_VERSION: "{{ lookup('env', 'OS_VOLUME_API_VERSION') }}"
OS_REGION_NAME: "{{ lookup('env', 'OS_REGION_NAME') }}"
roles:
- role: tripleo_nova_image_cache
# Standard inventory:
#
# ansible-playbook -i inventory.yml --extra-vars "@test_args1.yml" tripleo_nova_image_cache.yml
# test_args1.yml
# tripleo_nova_image_cache_images:
# - id: d23c6b8f-e166-4a02-afd8-0ae8d6f73f18
# - id: 81bbb16-d589-4730-be70-822a82ab6bb9
#
# Multi-stack inventory:
#
# ansible-playbook -i inventory_multi.yml --extra-vars "@test_args2.yml" tripleo_nova_image_cache.yml
# test_args2.yml:
# tripleo_nova_image_cache_plan: edge0
# tripleo_nova_image_cache_images:
# - id: d23c6b8f-e166-4a02-afd8-0ae8d6f73f18
# - id: 81bbb16-d589-4730-be70-822a82ab6bb9
# tripleo_nova_image_cache_use_proxy: true
# tripleo_nova_image_cache_proxy_hostname: compute-1 # optional, first nova_compute host is used otherwise
#