Files
kayobe/ansible/roles/kolla-openstack/tasks/config.yml
Mark Goddard 5563c665c0 Don't overwrite custom kolla-ansible configuration files, merge them
Previously, if a user provided a custom neutron ML2 configuration file in
/home/stackhpc-mark/kayobe/src/kayobe-config/etc/kayobe/neutron/ml2_conf.ini, it would overwrite the options set by
kayobe. This change applies the 'ignore' rule when copying custom config files,
as well as when deleting them. This works because we read in the contents of
these files and append it to kayobe's own configuration.
2017-11-02 16:39:24 +00:00

102 lines
4.0 KiB
YAML

---
- name: Ensure the Kolla OpenStack configuration directores exist
file:
path: "{{ item.dest }}"
state: directory
mode: 0750
with_items: "{{ kolla_openstack_custom_config }}"
when: item.enabled | bool
- name: Ensure the Kolla OpenStack configuration files exist
template:
src: "{{ item.src }}"
dest: "{{ kolla_node_custom_config_path }}/{{ item.dest }}"
mode: 0640
with_items:
- { src: glance.conf.j2, dest: glance.conf, enabled: "{{ kolla_enable_glance }}" }
- { src: ironic.conf.j2, dest: ironic.conf, enabled: "{{ kolla_enable_ironic }}" }
- { src: ironic-dnsmasq.conf.j2, dest: ironic/ironic-dnsmasq.conf, enabled: "{{ kolla_enable_ironic }}" }
- { src: ironic-inspector.conf.j2, dest: ironic-inspector.conf, enabled: "{{ kolla_enable_ironic }}" }
- { src: magnum.conf.j2, dest: magnum.conf, enabled: "{{ kolla_enable_magnum }}" }
- { src: ml2_conf.ini.j2, dest: neutron/ml2_conf.ini, enabled: "{{ kolla_enable_neutron }}" }
- { src: murano.conf.j2, dest: murano.conf, enabled: "{{ kolla_enable_murano }}" }
- { src: neutron.conf.j2, dest: neutron.conf, enabled: "{{ kolla_enable_neutron }}" }
- { src: nova.conf.j2, dest: nova.conf, enabled: "{{ kolla_enable_nova }}" }
- { src: pxelinux.default.j2, dest: ironic/pxelinux.default, enabled: "{{ kolla_enable_ironic }}" }
- { src: sahara.conf.j2, dest: sahara.conf, enabled: "{{ kolla_enable_sahara }}" }
when: item.enabled | bool
- name: Ensure the ironic inspector kernel and ramdisk are downloaded
get_url:
url: "{{ item.url }}"
dest: "{{ kolla_node_custom_config_path }}/ironic/{{ item.dest }}"
mode: 0640
with_items:
- { url: "{{ kolla_inspector_ipa_kernel_upstream_url }}", dest: "ironic-agent.kernel" }
- { url: "{{ kolla_inspector_ipa_ramdisk_upstream_url }}", dest: "ironic-agent.initramfs" }
when:
- kolla_enable_ironic | bool
- item.url != None
- name: Ensure the ironic inspector kernel and ramdisk are copied
copy:
src: "{{ item.path }}"
dest: "{{ kolla_node_custom_config_path }}/ironic/{{ item.dest }}"
mode: 0640
with_items:
- { path: "{{ kolla_inspector_ipa_kernel_path }}", dest: "ironic-agent.kernel" }
- { path: "{{ kolla_inspector_ipa_ramdisk_path }}", dest: "ironic-agent.initramfs" }
when:
- kolla_enable_ironic | bool
- item.path != None
# We support a fairly flexible mechanism of dropping config file templates into
# an 'extra' config directory, and passing these through to kolla-ansible. We
# look for matching files in the source directory to template, and also remove
# any unexpected files from the destination, to support removal of files.
- name: Find extra configuration files
find:
path: "{{ item.src }}"
patterns: "{{ item.patterns }}"
with_items: "{{ kolla_openstack_custom_config }}"
register: find_src_result
- name: Find previously generated extra configuration files
find:
path: "{{ item.dest }}"
patterns: "{{ item.patterns }}"
with_items: "{{ kolla_openstack_custom_config }}"
register: find_dest_result
- name: Ensure extra configuration files exist
template:
src: "{{ item.1.path }}"
dest: "{{ item.0.item.dest }}/{{ item.1.path | basename }}"
mode: 0640
with_subelements:
- "{{ find_src_result.results }}"
- files
- skip_missing: True
when:
- item.0.item.enabled | bool
- item.1.path | basename not in item.0.item.ignore | default([])
- name: Ensure unnecessary extra configuration files are absent
file:
path: "{{ item.1.path }}"
state: absent
with_subelements:
- "{{ find_dest_result.results }}"
- files
- skip_missing: True
when:
- not item.0.item.enabled or
item.1.path | basename not in src_files
- item.1.path | basename not in item.0.item.ignore | default([])
vars:
# Find the source result that corresponds to this one.
src_result: "{{ (find_src_result.results | selectattr('item', 'equalto', item.0.item) | list)[0] }}"
# Find the list of files in the source.
src_files: "{{ src_result.files | map(attribute='path') | map('basename') | list }}"