Replace dict combine in standalone containers-prepare-parameters
The dict combine steps used previously in the standalone role for containers-prepare-parameters was mangling the output when includes and excludes were used. This patch replaces the combine operations with replace/ blockinfile ansible operations to avoid combining and misplacing settings. Change-Id: I9af336d2088fa4ec55f2b5d97dbf5f52875b6ef8 Closes-Bug: BZ1710021
This commit is contained in:
parent
887055a159
commit
28fa4f7ef2
@ -4,3 +4,7 @@ extends: default
|
|||||||
rules:
|
rules:
|
||||||
line-length:
|
line-length:
|
||||||
max: 180
|
max: 180
|
||||||
|
|
||||||
|
#braces: {min-spaces-inside: 1, max-spaces-inside: 10}
|
||||||
|
ignore: |
|
||||||
|
/roles/standalone/tasks/main.yml
|
||||||
|
@ -38,123 +38,89 @@
|
|||||||
- name: update registry if needed in container-prepare-parameters.yaml
|
- name: update registry if needed in container-prepare-parameters.yaml
|
||||||
when:
|
when:
|
||||||
- docker_registry_host != '' and docker_registry_namespace != ''
|
- docker_registry_host != '' and docker_registry_namespace != ''
|
||||||
vars:
|
replace:
|
||||||
yaml_file: "{{ working_dir }}/containers-prepare-parameters.yaml"
|
path: "{{ working_dir }}/containers-prepare-parameters.yaml"
|
||||||
container_image_prep_updates:
|
regexp: " namespace: (.*)"
|
||||||
set:
|
replace: " namespace: {{ docker_registry_host }}/{{ docker_registry_namespace }}"
|
||||||
namespace: "{{ docker_registry_host }}/{{ docker_registry_namespace }}"
|
|
||||||
initial_dict: |
|
|
||||||
{{ lookup('file', yaml_file) | from_yaml }}
|
|
||||||
merged_dict:
|
|
||||||
parameter_defaults:
|
|
||||||
ContainerImagePrepare:
|
|
||||||
- |
|
|
||||||
{{ initial_dict.parameter_defaults.ContainerImagePrepare |
|
|
||||||
combine(container_image_prep_updates, recursive=true) }}
|
|
||||||
copy:
|
|
||||||
content: "{{ merged_dict | to_nice_yaml }}"
|
|
||||||
dest: "{{ yaml_file }}"
|
|
||||||
backup: true
|
backup: true
|
||||||
|
|
||||||
# update the container tag to match dlrn hash
|
# update the container tag to match dlrn hash
|
||||||
- name: update container tag if needed in container-prepare-parameters.yaml
|
- name: update container tag if needed in container-prepare-parameters.yaml
|
||||||
when:
|
when:
|
||||||
- container_build_id != ''
|
- container_build_id != ''
|
||||||
vars:
|
replace:
|
||||||
yaml_file: "{{ working_dir }}/containers-prepare-parameters.yaml"
|
path: "{{ working_dir }}/containers-prepare-parameters.yaml"
|
||||||
container_image_prep_updates:
|
regexp: " tag: (.*)"
|
||||||
set:
|
replace: " tag: {{ container_build_id }}"
|
||||||
tag: "{{ container_build_id }}"
|
|
||||||
initial_dict: |
|
|
||||||
{{ lookup('file', yaml_file) | from_yaml }}
|
|
||||||
merged_dict:
|
|
||||||
parameter_defaults:
|
|
||||||
ContainerImagePrepare:
|
|
||||||
- |
|
|
||||||
{{ initial_dict.parameter_defaults.ContainerImagePrepare |
|
|
||||||
combine(container_image_prep_updates, recursive=true) }}
|
|
||||||
copy:
|
|
||||||
content: "{{ merged_dict | to_nice_yaml }}"
|
|
||||||
dest: "{{ yaml_file }}"
|
|
||||||
backup: true
|
backup: true
|
||||||
|
|
||||||
# in extra-common/defaults
|
# in extra-common/defaults
|
||||||
# docker_prep_prefix: "{{ ansible_distribution | lower }}-binary-"
|
# docker_prep_prefix: "{{ ansible_distribution | lower }}-binary-"
|
||||||
- name: update container name_prefix for the appropriate distro
|
- name: update container name_prefix for the appropriate distro
|
||||||
vars:
|
replace:
|
||||||
yaml_file: "{{ working_dir }}/containers-prepare-parameters.yaml"
|
path: "{{ working_dir }}/containers-prepare-parameters.yaml"
|
||||||
container_image_prep_updates:
|
regexp: " name_prefix: (.*)"
|
||||||
set:
|
replace: " name_prefix: {{ docker_prep_prefix }}"
|
||||||
name_prefix: "{{ docker_prep_prefix }}"
|
|
||||||
initial_dict: |
|
|
||||||
{{ lookup('file', yaml_file) | from_yaml }}
|
|
||||||
merged_dict:
|
|
||||||
parameter_defaults:
|
|
||||||
ContainerImagePrepare:
|
|
||||||
- |
|
|
||||||
{{ initial_dict.parameter_defaults.ContainerImagePrepare |
|
|
||||||
combine(container_image_prep_updates, recursive=true) }}
|
|
||||||
copy:
|
|
||||||
content: "{{ merged_dict | to_nice_yaml }}"
|
|
||||||
dest: "{{ yaml_file }}"
|
|
||||||
backup: true
|
backup: true
|
||||||
|
|
||||||
# ceph parameters
|
# ceph parameters
|
||||||
- name: update container ceph parameters
|
- name: update container ceph parameters
|
||||||
when:
|
when:
|
||||||
- standalone_container_ceph_updates|default(false)|bool
|
- standalone_container_ceph_updates|default(false)|bool
|
||||||
vars:
|
replace:
|
||||||
yaml_file: "{{ working_dir }}/containers-prepare-parameters.yaml"
|
path: "{{ working_dir }}/containers-prepare-parameters.yaml"
|
||||||
container_image_prep_updates:
|
regexp: " {{ item.original }}: (.*)"
|
||||||
set:
|
replace: " {{ item.replace }}"
|
||||||
ceph_namespace: "{{ docker_ceph_namespace }}"
|
|
||||||
ceph_image: "{{ docker_ceph_image }}"
|
|
||||||
ceph_tag: "{{ docker_ceph_tag }}"
|
|
||||||
initial_dict: |
|
|
||||||
{{ lookup('file', yaml_file) | from_yaml }}
|
|
||||||
merged_dict:
|
|
||||||
parameter_defaults:
|
|
||||||
ContainerImagePrepare:
|
|
||||||
- |
|
|
||||||
{{ initial_dict.parameter_defaults.ContainerImagePrepare |
|
|
||||||
combine(container_image_prep_updates, recursive=true) }}
|
|
||||||
copy:
|
|
||||||
content: "{{ merged_dict | to_nice_yaml }}"
|
|
||||||
dest: "{{ yaml_file }}"
|
|
||||||
backup: true
|
backup: true
|
||||||
|
with_items:
|
||||||
|
- { original: "ceph_namespace", replace: "ceph_namespace: {{ docker_ceph_namespace }}" }
|
||||||
|
- { original: "ceph_image", replace: "ceph_image: {{ docker_ceph_image }}" }
|
||||||
|
- { original: "ceph_tag", replace: "ceph_tag: {{ docker_ceph_tag }}" }
|
||||||
|
|
||||||
# update params for container update
|
# update params for container update
|
||||||
- name: Add updates to container-prepare-parameters.yaml
|
- name: Add updates to container-prepare-parameters.yaml
|
||||||
when:
|
when:
|
||||||
- standalone_container_prep_updates
|
- standalone_container_prep_updates
|
||||||
vars:
|
block:
|
||||||
yaml_file: "{{ working_dir }}/containers-prepare-parameters.yaml"
|
- name: Replace tag_from_label value
|
||||||
container_image_prep_updates:
|
replace:
|
||||||
- push_destination: "{{ local_docker_registry_host }}:8787"
|
path: "{{ working_dir }}/containers-prepare-parameters.yaml"
|
||||||
tag_from_label: null
|
regexp: " tag_from_label: (.*)"
|
||||||
modify_role: tripleo-modify-image
|
replace: " tag_from_label: null"
|
||||||
modify_append_tag: "{{ update_containers_append_tag }}"
|
backup: true
|
||||||
modify_only_with_labels:
|
|
||||||
- kolla_version
|
|
||||||
modify_vars:
|
|
||||||
tasks_from: yum_update.yml
|
|
||||||
yum_repos_dir_path: /etc/yum.repos.d
|
|
||||||
update_repo: "{{ standalone_container_prep_update_repo }}"
|
|
||||||
initial_dict: |
|
|
||||||
{{ lookup('file', yaml_file) | from_yaml }}
|
|
||||||
merged_dict:
|
|
||||||
parameter_defaults:
|
|
||||||
DockerInsecureRegistryAddress:
|
|
||||||
- "{{ local_docker_registry_host }}:8787"
|
|
||||||
ContainerImagePrepare:
|
|
||||||
- |
|
|
||||||
{{ initial_dict.parameter_defaults.ContainerImagePrepare |
|
|
||||||
combine(container_image_prep_updates, recursive=true) }}
|
|
||||||
copy:
|
|
||||||
content: "{{ merged_dict | to_nice_yaml }}"
|
|
||||||
dest: "{{ yaml_file }}"
|
|
||||||
backup: true
|
|
||||||
|
|
||||||
|
- name: Add settings to modify
|
||||||
|
blockinfile:
|
||||||
|
path: "{{ working_dir }}/containers-prepare-parameters.yaml"
|
||||||
|
state: present
|
||||||
|
backup: true
|
||||||
|
insertbefore: "(.*) tag_from_label: null"
|
||||||
|
block: |
|
||||||
|
#
|
||||||
|
push_destination: "{{ local_docker_registry_host }}:8787"
|
||||||
|
modify_role: tripleo-modify-image
|
||||||
|
modify_append_tag: "{{ update_containers_append_tag }}"
|
||||||
|
{% if osp_release is defined -%}
|
||||||
|
# no kolla labels are defined
|
||||||
|
{% else -%}
|
||||||
|
modify_only_with_labels:
|
||||||
|
- kolla_version
|
||||||
|
{% endif -%}
|
||||||
|
modify_vars:
|
||||||
|
tasks_from: yum_update.yml
|
||||||
|
yum_repos_dir_path: /etc/yum.repos.d
|
||||||
|
update_repo: "{{ standalone_container_prep_update_repo }}"
|
||||||
|
|
||||||
|
- name: Modify the insecure registry value when using podman
|
||||||
|
when:
|
||||||
|
- standalone_container_prep_updates
|
||||||
|
- osp_release is defined
|
||||||
|
- release not in ['newton', 'ocata', 'pike', 'queens', 'rocky']
|
||||||
|
replace:
|
||||||
|
path: "{{ working_dir }}/standalone_parameters.yaml"
|
||||||
|
regexp: " - 192.168.24.1:8787"
|
||||||
|
replace: " - 192.168.24.1"
|
||||||
|
backup: true
|
||||||
|
|
||||||
- name: Create the deploy command for standalone
|
- name: Create the deploy command for standalone
|
||||||
template:
|
template:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user