Consume RoleData config from config download files
In https://review.openstack.org/#/c/525260/, we moved the creation of various RoleData driven config files to deploy-steps-tasks.yaml, and to consume the values from various role_data_* variables that were written in the inventory (see https://review.openstack.org/#/c/528354/). However, we were already downloading and saving the RoleData to separate files via config download. We should consume from those files instead of the inventory. That has the advantage that one can quickly modify and iterate on the local files, and have those changes applied. That is harder to do when these values are in the inventory, and not possible to do when using dynamic inventory. Since the tasks will fail trying to read from the files when not using config-download, conditional local_action tasks that use the stat module first verify the existence of the files before attempting to read their contents. If they don't exist, the values fall back to whatever has been defined by the ansible variable. Change-Id: Idfdce6f0a778b0a7f2fed17ff56d1a3e451868ab Closes-Bug: #1749784
This commit is contained in:
parent
75a980ca04
commit
c334ad38d5
@ -10,13 +10,33 @@
|
||||
- name: Create /var/lib/tripleo-config directory
|
||||
file: path=/var/lib/tripleo-config state=directory setype=svirt_sandbox_file_t selevel=s0 recurse=true
|
||||
# Puppet manifest for baremetal host configuration
|
||||
- name: Check if puppet step_config.pp manifest exists
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
stat:
|
||||
path: "{{ role_name + '/step_config.pp' }}"
|
||||
register: stat_step_config
|
||||
- name: Set fact when file existed
|
||||
set_fact:
|
||||
role_data_step_config: "{{lookup('file', role_name + '/step_config.pp')}}"
|
||||
when: stat_step_config.stat.exists
|
||||
- name: Write the puppet step_config manifest
|
||||
copy: content="{{role_data_step_config}}" dest=/var/lib/tripleo-config/puppet_step_config.pp force=yes mode=0600
|
||||
# Config file for our docker-puppet.py script, used to generate container configs
|
||||
- name: Create /var/lib/docker-puppet
|
||||
file: path=/var/lib/docker-puppet state=directory setype=svirt_sandbox_file_t selevel=s0 recurse=true
|
||||
- name: Write docker-puppet-tasks json files
|
||||
copy: content="{{role_data_puppet_config | to_json}}" dest=/var/lib/docker-puppet/docker-puppet.json force=yes mode=0600
|
||||
- name: Check if docker-puppet puppet_config.yaml configuration file exists
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
stat:
|
||||
path: "{{ role_name + '/puppet_config.yaml' }}"
|
||||
register: stat_puppet_config
|
||||
- name: Set fact when file existed
|
||||
set_fact:
|
||||
role_data_puppet_config: "{{lookup('file', role_name + '/puppet_config.yaml') | from_yaml | to_json}}"
|
||||
when: stat_puppet_config.stat.exists
|
||||
- name: Write docker-puppet.json file
|
||||
copy: content="{{role_data_puppet_config}}" dest=/var/lib/docker-puppet/docker-puppet.json force=yes mode=0600
|
||||
- name: Create /var/lib/docker-config-scripts
|
||||
file: path=/var/lib/docker-config-scripts state=directory
|
||||
|
||||
@ -28,6 +48,16 @@
|
||||
file:
|
||||
path: /var/lib/docker-container-startup-configs.json
|
||||
state: absent
|
||||
- name: Check if docker_config_scripts.yaml file exists
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
stat:
|
||||
path: "{{ role_name + '/docker_config_scripts.yaml' }}"
|
||||
register: stat_docker_config_scripts
|
||||
- name: Set fact when file existed
|
||||
set_fact:
|
||||
role_data_docker_config_scripts: "{{lookup('file', role_name + '/docker_config_scripts.yaml') | from_yaml}}"
|
||||
when: stat_docker_config_scripts.stat.exists
|
||||
- name: Write docker config scripts
|
||||
copy: content="{{item.value.content}}" dest="/var/lib/docker-config-scripts/{{item.key}}" force=yes mode="{{item.value.mode|default('0600', true)}}"
|
||||
with_dict: "{{role_data_docker_config_scripts}}"
|
||||
@ -40,6 +70,16 @@
|
||||
set_fact:
|
||||
docker_config_default: "{{ docker_config_default|default({}) | combine( {'step_'+item: {}} ) }}"
|
||||
with_sequence: count={{deploy_steps_max}}
|
||||
- name: Check if docker_config.yaml file exists
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
stat:
|
||||
path: "{{ role_name + '/docker_config.yaml' }}"
|
||||
register: stat_docker_config
|
||||
- name: Set fact when file existed
|
||||
set_fact:
|
||||
role_data_docker_config: "{{lookup('file', role_name + '/docker_config.yaml') | from_yaml}}"
|
||||
when: stat_docker_config.stat.exists
|
||||
- name: Set docker_startup_configs_with_default fact
|
||||
set_fact:
|
||||
docker_config_with_default: "{{docker_config_default | combine(role_data_docker_config)}}"
|
||||
@ -50,6 +90,16 @@
|
||||
with_dict: "{{docker_config_with_default}}"
|
||||
- name: Create /var/lib/kolla/config_files directory
|
||||
file: path=/var/lib/kolla/config_files state=directory setype=svirt_sandbox_file_t selevel=s0 recurse=true
|
||||
- name: Check if kolla_config.yaml file exists
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
stat:
|
||||
path: "{{ role_name + '/kolla_config.yaml' }}"
|
||||
register: stat_kolla_config
|
||||
- name: Set fact when file existed
|
||||
set_fact:
|
||||
role_data_kolla_config: "{{lookup('file', role_name + '/kolla_config.yaml') | from_yaml}}"
|
||||
when: stat_kolla_config.stat.exists
|
||||
- name: Write kolla config json files
|
||||
copy: content="{{item.value|to_json}}" dest="{{item.key}}" force=yes mode=0600
|
||||
with_dict: "{{role_data_kolla_config}}"
|
||||
@ -63,6 +113,16 @@
|
||||
with_fileglob:
|
||||
- /var/lib/docker-puppet/docker-puppet-tasks*.json
|
||||
when: deploy_server_id == bootstrap_server_id
|
||||
- name: Check if docker_puppet_tasks.yaml file exists
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
stat:
|
||||
path: "{{ role_name + '/docker_puppet_tasks.yaml' }}"
|
||||
register: stat_docker_puppet_tasks
|
||||
- name: Set fact when file existed
|
||||
set_fact:
|
||||
role_data_docker_puppet_tasks: "{{lookup('file', role_name + '/docker_puppet_tasks.yaml') | from_yaml}}"
|
||||
when: stat_docker_puppet_tasks.stat.exists
|
||||
- name: Write docker-puppet-tasks json files
|
||||
copy: content="{{item.value|to_json}}" dest=/var/lib/docker-puppet/docker-puppet-tasks{{item.key.replace("step_", "")}}.json force=yes mode=0600
|
||||
with_dict: "{{role_data_docker_puppet_tasks}}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user