Browse Source

Move docker_puppet_tasks calculation into services.yaml

This makes the RolesData output more accurate, and we can rework
things so docker-puppet only gets run when there is a non-empty
file calculated (e.g there are tasks to run).

Change-Id: I8cdab3c857977c80fe2e359ab9e05740a838d66b
changes/85/485685/3
Steven Hardy 4 years ago
committed by marios
parent
commit
0a44085af6
  1. 4
      common/services.yaml
  2. 6
      docker/deploy-steps-playbook.yaml
  3. 29
      docker/docker-steps.j2

4
common/services.yaml

@ -223,10 +223,10 @@ resources:
DockerPuppetTasks:
type: OS::Heat::Value
properties:
type: comma_delimited_list
type: json
value:
yaql:
expression: coalesce($.data, []).where($ != null).select($.get('docker_puppet_tasks')).where($ != null).distinct()
expression: dict(coalesce($.data, []).where($ != null).select($.get('docker_puppet_tasks')).where($ != null).selectMany($.items()).groupBy($[0], $[1]))
data: {get_attr: [ServiceChain, role_data]}
HostPrepTasks:

6
docker/deploy-steps-playbook.yaml

@ -64,6 +64,10 @@
########################################################
# Bootstrap tasks, only performed on bootstrap_server_id
########################################################
- name: Check if /var/lib/docker-puppet/docker-puppet-tasks{{step}}.json exists
stat:
path: /var/lib/docker-puppet/docker-puppet-tasks{{step}}.json
register: docker_puppet_tasks_json
- name: Run docker-puppet tasks (bootstrap tasks)
shell: python /var/lib/docker-puppet/docker-puppet.py
environment:
@ -71,7 +75,7 @@
NET_HOST: "true"
NO_ARCHIVE: "true"
STEP: "{{step}}"
when: deploy_server_id == bootstrap_server_id
when: deploy_server_id == bootstrap_server_id and docker_puppet_tasks_json.stat.exists
changed_when: false
check_mode: no
register: outputs

29
docker/docker-steps.j2

@ -60,23 +60,6 @@ conditions:
resources:
# These utility tasks use docker-puppet.py to execute tasks via puppet
# We only execute these on the first node in the primary role
{{primary_role_name}}DockerPuppetTasks:
type: OS::Heat::Value
properties:
type: json
value:
yaql:
expression:
$.data.default_tasks + dict($.data.docker_puppet_tasks.where($1 != null).selectMany($.items()).groupBy($[0], $[1]))
data:
docker_puppet_tasks: {get_param: [role_data, {{primary_role_name}}, docker_puppet_tasks]}
default_tasks:
{%- for step in range(1, deploy_steps_max) %}
step_{{step}}: {}
{%- endfor %}
RoleConfig:
type: OS::Heat::SoftwareConfig
properties:
@ -177,7 +160,7 @@ resources:
vars:
puppet_config: {get_param: [role_data, {{role.name}}, puppet_config]}
docker_puppet_script: {get_file: docker-puppet.py}
docker_puppet_tasks: {get_attr: [{{primary_role_name}}DockerPuppetTasks, value]}
docker_puppet_tasks: {get_param: [role_data, {{role.name}}, docker_puppet_tasks]}
docker_startup_configs: {get_param: [role_data, {{role.name}}, docker_config]}
kolla_config: {get_param: [role_data, {{role.name}}, kolla_config]}
bootstrap_server_id: {get_param: [servers, {{primary_role_name}}, '0']}
@ -195,10 +178,9 @@ resources:
file: path=/var/lib/tripleo-config state=directory
- name: Write the puppet step_config manifest
copy: content="{{puppet_step_config}}" dest=/var/lib/tripleo-config/puppet_step_config.pp force=yes
# This is the docker-puppet configs end in
# this creates a JSON config file for our docker-puppet.py script
- name: Create /var/lib/docker-puppet
file: path=/var/lib/docker-puppet state=directory
# this creates a JSON config file for our docker-puppet.py script
- name: Write docker-puppet-tasks json files
copy: content="{{puppet_config | to_json}}" dest=/var/lib/docker-puppet/docker-puppet.json force=yes
# FIXME: can we move docker-puppet somewhere so it's installed via a package?
@ -222,6 +204,13 @@ resources:
########################################################
# Bootstrap tasks, only performed on bootstrap_server_id
########################################################
- name: Clean /var/lib/docker-puppet/docker-puppet-tasks*.json files
file:
path: "{{item}}"
state: absent
with_fileglob:
- /var/lib/docker-puppet/docker-puppet-tasks*.json
when: deploy_server_id == bootstrap_server_id
- 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
with_dict: "{{docker_puppet_tasks}}"

Loading…
Cancel
Save