Skip to content

Commit

Permalink
Merge "Cleanup files and templates using smart sources"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Jan 12, 2019
2 parents 7451001 + 36a5e62 commit 31a46e0
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 363 deletions.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,5 +296,6 @@ heat_role_project_group: heat_all
heat_heat_conf_overrides: {}
heat_api_paste_ini_overrides: {}
heat_default_yaml_overrides: {}
heat_aws_cloudwatch_alarm_yaml_overrides: {}
heat_aws_rds_dbinstance_yaml_overrides: {}
heat_policy_overrides: {}
72 changes: 51 additions & 21 deletions tasks/heat_post_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,13 @@

- name: Drop heat Config(s)
config_template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
src: "heat.conf.j2"
dest: "/etc/heat/heat.conf"
owner: "root"
group: "{{ heat_system_group_name }}"
mode: "0640"
config_overrides: "{{ item.config_overrides }}"
config_type: "{{ item.config_type }}"
with_items:
- src: "heat.conf.j2"
dest: "/etc/heat/heat.conf"
config_overrides: "{{ heat_heat_conf_overrides }}"
config_type: "ini"
- src: "api-paste.ini.j2"
dest: "/etc/heat/api-paste.ini"
config_overrides: "{{ heat_api_paste_ini_overrides }}"
config_type: "ini"
- src: "environment.d/default.yaml.j2"
dest: "/etc/heat/environment.d/default.yaml"
config_overrides: "{{ heat_default_yaml_overrides }}"
config_type: "yaml"
- src: "templates/AWS_RDS_DBInstance.yaml.j2"
dest: "/etc/heat/templates/AWS_RDS_DBInstance.yaml"
config_overrides: "{{ heat_aws_rds_dbinstance_yaml_overrides }}"
config_type: "yaml"
config_overrides: "{{ heat_heat_conf_overrides }}"
config_type: "ini"
notify:
- Restart heat services

Expand All @@ -48,3 +31,50 @@
dest: "/etc/heat/policy.json"
when:
- heat_policy_overrides != {}

# NOTE(cloudnull): This is using "cp" instead of copy with a remote_source
# because we only want to copy the original files once. and we
# don't want to need multiple tasks.
- name: Preserve original configuration file(s)
command: "cp {{ item.target_f }} {{ item.target_f }}.original"
args:
creates: "{{ item.target_f }}.original"
when:
- item.condition | bool
with_items: "{{ heat_core_files }}"

- name: Fetch override files
fetch:
src: "{{ item.target_f }}"
dest: "{{ item.tmp_f }}"
flat: yes
changed_when: false
run_once: true
when:
- item.condition | bool
with_items: "{{ heat_core_files }}"

- name: Copy common config
config_template:
src: "{{ item.tmp_f }}"
dest: "{{ item.target_f }}"
owner: "root"
group: "{{ item.group | default(heat_system_group_name) }}"
mode: "0640"
config_overrides: "{{ item.config_overrides }}"
config_type: "{{ item.config_type }}"
when:
- item.condition | bool
with_items: "{{ heat_core_files }}"
notify:
- Restart heat services

- name: Cleanup fetched temp files
file:
path: "{{ item.tmp_f }}"
state: absent
changed_when: false
delegate_to: localhost
when:
- item.condition | bool
with_items: "{{ heat_core_files }}"
60 changes: 50 additions & 10 deletions tasks/heat_pre_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,61 @@
createhome: "yes"
home: "{{ heat_system_home_folder }}"

# NOTE(cloudnull): During an upgrade the local directory may exist on a source
# install. If the directory does exist it will need to be
# removed. This is required on source installs because the
# config directory is a link.
- name: Source config block
block:
- name: Stat config directory
stat:
path: "/etc/heat"
register: heat_conf_dir_stat

- name: Remove the config directory
file:
path: "/etc/heat"
state: absent
when:
- heat_conf_dir_stat.stat.isdir is defined and
heat_conf_dir_stat.stat.isdir
when:
- heat_install_method == 'source'

- name: Create heat dir
file:
path: "{{ item.path }}"
state: directory
path: "{{ item.path | default(omit) }}"
src: "{{ item.src | default(omit) }}"
dest: "{{ item.dest | default(omit) }}"
state: "{{ item.state | default('directory') }}"
owner: "{{ item.owner|default(heat_system_user_name) }}"
group: "{{ item.group|default(heat_system_group_name) }}"
mode: "{{ item.mode|default('0755') }}"
mode: "{{ item.mode | default(omit) }}"
force: "{{ item.force | default(omit) }}"
when:
- (item.condition | default(true)) | bool
with_items:
- { path: "/openstack", owner: "root", group: "root" }
- { path: "/openstack/venvs", owner: "root", group: "root" }
- { path: "/etc/heat", mode: "0750" }
- { path: "/etc/heat/environment.d" }
- { path: "/etc/heat/templates" }
- { path: "/var/cache/heat", mode: "0700" }
- { path: "{{ heat_system_home_folder }}" }
- path: "/openstack"
owner: "root"
group: "root"
- path: "/openstack/venvs"
owner: "root"
group: "root"
- path: "{{ (heat_install_method == 'distro') | ternary('/etc/heat', (heat_bin | dirname) + '/etc/heat') }}"
mode: "0755"
# NOTE(cloudnull): The "src" path is relative. This ensures all files remain
# within the host/container confines when connecting to
# them using the connection plugin or the root filesystem.
- dest: "/etc/heat"
src: "{{ heat_bin | dirname | regex_replace('^/', '../') }}/etc/heat"
state: link
force: true
condition: "{{ heat_install_method == 'source' }}"
- path: "/etc/heat/environment.d"
- path: "/etc/heat/templates"
- path: "/var/cache/heat"
mode: "0700"
- path: "{{ heat_system_home_folder }}"

- name: Create heat plugin dirs
file:
Expand Down
102 changes: 0 additions & 102 deletions templates/api-paste.ini.j2

This file was deleted.

14 changes: 0 additions & 14 deletions templates/environment.d/default.yaml.j2

This file was deleted.

87 changes: 0 additions & 87 deletions templates/templates/AWS_CloudWatch_Alarm.yaml.j2

This file was deleted.

0 comments on commit 31a46e0

Please sign in to comment.