Adopt for usage openstack_resources role
With efforts to create a resources in same, unified way, we convert tempest role to use openstack_resources for creating and managing openstack resources, like projects, flavors, networks, images, etc. This should reduce maintenance costs in case of futher collection updates and unify approach. Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/911377 Change-Id: I658e6218cf59650d0abfa491ebaa6d3c37db2993
This commit is contained in:
parent
3c476298a8
commit
ceca11a27d
@ -164,14 +164,15 @@ magnum_trustee_domain_admin_roles:
|
||||
magnum_cluster_user_trust: True
|
||||
|
||||
# Glance images
|
||||
## Example Glance Image - Fedora Atomic
|
||||
# - name: fedora-atomic-latest #Name of the image in Glance
|
||||
# disk_format: qcow2 #Disk format (e.g. qcow2)
|
||||
# image_format: bare #Image format
|
||||
# public: true #Boolean - is the image public
|
||||
# file: https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/31.20200210.3.0/x86_64/fedora-coreos-31.20200210.3.0-openstack.x86_64.qcow2.xz
|
||||
# distro: fedora-atomic #Value for the os_distro metadata
|
||||
# checksum: "sha256:9a5252e24b82a5edb1ce75b05653f59895685b0f1028112462e908a12deae518"
|
||||
## Example Glance Image - Fedora CoreOS
|
||||
# - name: fedora-coreos-latest
|
||||
# disk_format: qcow2
|
||||
# image_format: bare
|
||||
# visibility: public
|
||||
# url: https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/38.20230806.3.0/x86_64/fedora-coreos-38.20230806.3.0-openstack.x86_64.qcow2.xz
|
||||
# properties:
|
||||
# os_distro: "fedora-coreos"
|
||||
# checksum: "da359b10f9aa165c4f81e6cd9ca5f81b"
|
||||
magnum_glance_images: []
|
||||
|
||||
# Define cluster templates to create. It should be list of
|
||||
|
@ -128,7 +128,8 @@ Via os_magnum playbooks and data in user_variables.yml
|
||||
image_format: bare
|
||||
public: true
|
||||
file: https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/31.20200210.3.0/x86_64/fedora-coreos-31.20200210.3.0-openstack.x86_64.qcow2.xz
|
||||
distro: "coreos"
|
||||
properties:
|
||||
os_distro: "fedora-coreos"
|
||||
checksum: "sha256:9a5252e24b82a5edb1ce75b05653f59895685b0f1028112462e908a12deae518"
|
||||
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
Format of ``magnum_glance_images`` has changed to the one compatible
|
||||
with ``openstack_resources`` role.
|
||||
Please reffer to os_magnum role documentation for a relevant example.
|
@ -13,102 +13,24 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Create magnum resources
|
||||
delegate_to: "{{ magnum_service_setup_host }}"
|
||||
- name: Wait for magnum endpoint to become reachable
|
||||
uri:
|
||||
url: "{{ magnum_service_internalurl }}"
|
||||
register: result
|
||||
until: "result.status == 200"
|
||||
retries: 10
|
||||
delay: 10
|
||||
|
||||
- name: Set up the service network
|
||||
ansible.builtin.include_role:
|
||||
name: openstack.osa.openstack_resources
|
||||
vars:
|
||||
ansible_python_interpreter: "{{ magnum_service_setup_host_python_interpreter }}"
|
||||
block:
|
||||
- name: Create image download directory
|
||||
file:
|
||||
path: "{{ magnum_image_path }}"
|
||||
state: directory
|
||||
mode: "0750"
|
||||
owner: "{{ magnum_image_path_owner }}"
|
||||
when: magnum_glance_images
|
||||
|
||||
- name: Download images
|
||||
get_url:
|
||||
url: "{{ item.file }}"
|
||||
dest: "{{ magnum_image_path }}/{{ item.file | basename }}"
|
||||
checksum: "{{ item.checksum | default(omit) }}"
|
||||
mode: "0644"
|
||||
register: download_image
|
||||
until: download_image is success
|
||||
retries: 5
|
||||
delay: 10
|
||||
with_items: "{{ magnum_glance_images }}"
|
||||
|
||||
- name: Upload images to Glance
|
||||
openstack.cloud.image:
|
||||
cloud: "{{ item.cloud | default('default') }}"
|
||||
state: "{{ item.state | default('present') }}"
|
||||
interface: "{{ item.interface | default('admin') }}"
|
||||
validate_certs: "{{ not keystone_service_adminuri_insecure }}"
|
||||
name: "{{ item.name }}"
|
||||
disk_format: "{{ item.disk_format }}"
|
||||
container_format: "{{ item.image_format }}"
|
||||
is_public: "{{ item.public }}"
|
||||
filename: "{{ magnum_image_path }}/{{ item.file | basename }}"
|
||||
properties:
|
||||
os_distro: "{{ item.distro }}"
|
||||
register: upload_image
|
||||
until: upload_image is success
|
||||
retries: 5
|
||||
delay: 10
|
||||
with_items: "{{ magnum_glance_images }}"
|
||||
|
||||
- name: Create flavors for Magnum
|
||||
openstack.cloud.compute_flavor:
|
||||
cloud: "{{ item.cloud | default('default') }}"
|
||||
state: "{{ item.state | default('present') }}"
|
||||
is_public: "{{ item.is_public | default(omit) }}"
|
||||
interface: "{{ item.interface | default('admin') }}"
|
||||
validate_certs: "{{ not keystone_service_adminuri_insecure }}"
|
||||
region_name: "{{ item.region_name | default(magnum_service_region) }}"
|
||||
name: "{{ item.name }}"
|
||||
ram: "{{ item.ram }}"
|
||||
vcpus: "{{ item.vcpus }}"
|
||||
disk: "{{ item.disk | default(0) }}"
|
||||
swap: "{{ item.swap | default(0) }}"
|
||||
ephemeral: "{{ item.ephemeral | default(omit) }}"
|
||||
extra_specs: "{{ item.extra_specs | default(omit) }}"
|
||||
flavorid: "{{ item.flavorid | default(omit) }}"
|
||||
rxtx_factor: "{{ item.rxtx_factor | default(omit) }}"
|
||||
with_items: "{{ magnum_flavors }}"
|
||||
|
||||
- name: Wait for magnum endpoint to become reachable
|
||||
uri:
|
||||
url: "{{ magnum_service_internalurl }}"
|
||||
register: result
|
||||
until: "result.status == 200"
|
||||
retries: 10
|
||||
delay: 10
|
||||
|
||||
- name: Create Magnum cluster templates
|
||||
openstack.cloud.coe_cluster_template:
|
||||
cloud: "{{ item.cloud | default('default') }}"
|
||||
state: "{{ item.state | default('present') }}"
|
||||
interface: "{{ item.interface | default('admin') }}"
|
||||
validate_certs: "{{ not keystone_service_adminuri_insecure }}"
|
||||
region_name: "{{ item.region_name | default(magnum_service_region) }}"
|
||||
coe: "{{ item.coe }}"
|
||||
dns_nameserver: "{{ item.dns_nameserver | default(omit) }}"
|
||||
docker_storage_driver: "{{ item.docker_storage_driver | default(omit) }}"
|
||||
docker_volume_size: "{{ item.docker_volume_size | default(omit) }}"
|
||||
external_network_id: "{{ item.external_network_id | default(omit) }}"
|
||||
fixed_network: "{{ item.fixed_network | default(omit) }}"
|
||||
fixed_subnet: "{{ item.fixed_subnet | default(omit) }}"
|
||||
flavor_id: "{{ item.flavor_id }}"
|
||||
is_floating_ip_enabled: "{{ item.floating_ip_enabled | default(omit) }}"
|
||||
image_id: "{{ item.image_id }}"
|
||||
keypair_id: "{{ item.keypair_id | default(omit) }}"
|
||||
labels: "{{ item.labels | default(omit) }}"
|
||||
master_flavor_id: "{{ item.master_flavor_id }}"
|
||||
master_lb_enabled: "{{ item.master_lb_enabled | default(omit) }}"
|
||||
name: "{{ item.name }}"
|
||||
network_driver: "{{ item.network_driver }}"
|
||||
public: "{{ item.public | default(omit) }}"
|
||||
registry_enabled: "{{ item.registry_enabled | default(omit) }}"
|
||||
server_type: "{{ item.server_type | default(omit) }}"
|
||||
volume_driver: "{{ item.volume_driver | default(omit) }}"
|
||||
with_items: "{{ magnum_cluster_templates }}"
|
||||
openstack_resources_setup_host: "{{ magnum_service_setup_host }}"
|
||||
openstack_resources_python_interpreter: "{{ magnum_service_setup_host_python_interpreter }}"
|
||||
openstack_resources_image:
|
||||
images: "{{ _magnum_glance_images_compat }}"
|
||||
openstack_resources_compute:
|
||||
flavors:
|
||||
- specs: "{{ magnum_flavors }}"
|
||||
openstack_resources_coe:
|
||||
templates: "{{ magnum_cluster_templates }}"
|
||||
|
@ -76,3 +76,26 @@ uwsgi_magnum_services: |-
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ services }}
|
||||
|
||||
_magnum_glance_images_compat: |-
|
||||
{% set images = [] %}
|
||||
{% for image in magnum_glance_images %}
|
||||
{% if 'public' in image and image['public'] %}
|
||||
{% set _ = image.update({'visibility': 'public'}) %}
|
||||
{% set _ = image.pop('public') %}
|
||||
{% endif %}
|
||||
{% if 'distro' in image %}
|
||||
{% set image_properties = image.get('properties', {}) %}
|
||||
{% set _ = image_properties.update({'os_distro': image.pop('distro')}) %}
|
||||
{% set _ = image.update({'properties': image_properties}) %}
|
||||
{% endif %}
|
||||
{% if 'file' in image and image['file'] is url %}
|
||||
{% set _ = image.update({'url': image.pop('file')}) %}
|
||||
{% endif %}
|
||||
{# NOTE(noonedeadpunk): Glance requires image checksum to be in plain md5 only #}
|
||||
{% if 'checksum' in image and image['checksum'].split(':') | length > 1 %}
|
||||
{% set _ = image.pop('checksum') %}
|
||||
{% endif %}
|
||||
{% set _ = images.append(image) %}
|
||||
{% endfor %}
|
||||
{{ images }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user