Merge "run docker_puppet_tasks on any role"
This commit is contained in:
commit
d5298e2f79
@ -7,16 +7,23 @@
|
|||||||
setup:
|
setup:
|
||||||
gather_subset: "!min,python"
|
gather_subset: "!min,python"
|
||||||
when: ansible_python is not defined
|
when: ansible_python is not defined
|
||||||
|
tags:
|
||||||
|
- container_config_tasks
|
||||||
|
|
||||||
- name: set python_cmd
|
- name: set python_cmd
|
||||||
set_fact:
|
set_fact:
|
||||||
python_cmd: "python{{ ansible_python.version.major }}"
|
python_cmd: "python{{ ansible_python.version.major }}"
|
||||||
cacheable: true
|
cacheable: true
|
||||||
when: python_cmd is not defined
|
when: python_cmd is not defined
|
||||||
|
tags:
|
||||||
|
- container_config_tasks
|
||||||
|
|
||||||
|
|
||||||
- name: print python facts
|
- name: print python facts
|
||||||
debug:
|
debug:
|
||||||
msg: "python_cmd: {{ python_cmd }}"
|
msg: "python_cmd: {{ python_cmd }}"
|
||||||
|
tags:
|
||||||
|
- container_config_tasks
|
||||||
|
|
||||||
- name: Write config data at the start of step 1
|
- name: Write config data at the start of step 1
|
||||||
when: step == "1"
|
when: step == "1"
|
||||||
@ -301,33 +308,6 @@
|
|||||||
tags:
|
tags:
|
||||||
- container_startup_configs
|
- container_startup_configs
|
||||||
|
|
||||||
########################################################
|
|
||||||
# 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
|
|
||||||
tags:
|
|
||||||
- container_config_tasks
|
|
||||||
|
|
||||||
- name: Write docker-puppet-tasks json files
|
|
||||||
copy:
|
|
||||||
content: "{{item[1]|to_nice_json}}"
|
|
||||||
dest: /var/lib/docker-puppet/docker-puppet-tasks{{item[0].replace("step_", "")}}.json
|
|
||||||
force: yes
|
|
||||||
mode: '0600'
|
|
||||||
loop: "{{ lookup('file', tripleo_role_name + '/docker_puppet_tasks.yaml', errors='ignore') | default({}, True) | from_yaml | dictsort }}"
|
|
||||||
loop_control:
|
|
||||||
label: "{{ item[0] }}"
|
|
||||||
when: deploy_server_id == bootstrap_server_id
|
|
||||||
tags:
|
|
||||||
- container_config_tasks
|
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
# Per step puppet configuration of the baremetal host
|
# Per step puppet configuration of the baremetal host
|
||||||
#####################################################
|
#####################################################
|
||||||
@ -507,16 +487,36 @@
|
|||||||
- container_startup_configs
|
- container_startup_configs
|
||||||
|
|
||||||
########################################################
|
########################################################
|
||||||
# Bootstrap tasks, only performed on bootstrap_server_id
|
# Bootstrap tasks - run any tasks that have been defined
|
||||||
########################################################
|
########################################################
|
||||||
|
|
||||||
- name: Check if /var/lib/docker-puppet/docker-puppet-tasks{{ step }}.json exists
|
- name: "Clean docker_puppet_tasks for {{ansible_hostname}} step {{step}}"
|
||||||
stat:
|
file:
|
||||||
path: /var/lib/docker-puppet/{{ ansible_check_mode | ternary('check-mode/', '') }}docker-puppet-tasks{{ step }}.json
|
path: /var/lib/docker-puppet/docker-puppet-tasks{{step}}.json
|
||||||
register: docker_puppet_tasks_json
|
state: absent
|
||||||
tags:
|
tags:
|
||||||
- container_config_tasks
|
- container_config_tasks
|
||||||
|
|
||||||
|
- name: Calculate docker_puppet_tasks for {{ansible_hostname}} step {{step}}
|
||||||
|
set_fact:
|
||||||
|
host_docker_puppet_tasks: "{{host_docker_puppet_tasks|default([]) + [item]}}"
|
||||||
|
loop: "{{docker_puppet_tasks.get('step_' + step, [])}}"
|
||||||
|
when: vars[item.service_name + '_short_bootstrap_node_name'] == ansible_hostname
|
||||||
|
vars:
|
||||||
|
docker_puppet_tasks: "{{ lookup('file', tripleo_role_name + '/docker_puppet_tasks.yaml', errors='ignore') | default({}, True) | from_yaml }}"
|
||||||
|
tags:
|
||||||
|
- container_config_tasks
|
||||||
|
|
||||||
|
- name: Write docker-puppet-tasks json file for {{ansible_hostname}} step {{step}}
|
||||||
|
copy:
|
||||||
|
content: "{{host_docker_puppet_tasks|to_nice_json}}"
|
||||||
|
dest: "/var/lib/docker-puppet/docker-puppet-tasks{{step}}.json"
|
||||||
|
force: yes
|
||||||
|
mode: '0600'
|
||||||
|
tags:
|
||||||
|
- container_config_tasks
|
||||||
|
when: host_docker_puppet_tasks is defined
|
||||||
|
|
||||||
- name: Run docker-puppet tasks (bootstrap tasks) for step {{ step }}
|
- name: Run docker-puppet tasks (bootstrap tasks) for step {{ step }}
|
||||||
shell: "{{ python_cmd }} /var/lib/docker-puppet/docker-puppet.py"
|
shell: "{{ python_cmd }} /var/lib/docker-puppet/docker-puppet.py"
|
||||||
environment:
|
environment:
|
||||||
@ -528,9 +528,7 @@
|
|||||||
CONTAINER_CLI: "{{ container_cli }}"
|
CONTAINER_CLI: "{{ container_cli }}"
|
||||||
DEBUG: "{{ docker_puppet_debug }}"
|
DEBUG: "{{ docker_puppet_debug }}"
|
||||||
MOUNT_HOST_PUPPET: '{{docker_puppet_mount_host_puppet}}'
|
MOUNT_HOST_PUPPET: '{{docker_puppet_mount_host_puppet}}'
|
||||||
when:
|
when: host_docker_puppet_tasks is defined
|
||||||
- deploy_server_id == bootstrap_server_id
|
|
||||||
- docker_puppet_tasks_json.stat.exists
|
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: outputs
|
register: outputs
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
@ -295,7 +295,10 @@ resources:
|
|||||||
type: json
|
type: json
|
||||||
value:
|
value:
|
||||||
yaql:
|
yaql:
|
||||||
expression: dict(coalesce($.data, []).where($ != null).select($.get('docker_puppet_tasks')).where($ != null).selectMany($.items()).groupBy($[0], $[1]))
|
# This extracts docker_puppet_tasks for each step,
|
||||||
|
# and merges {service_name: the_service} for each item, so we
|
||||||
|
# can later filter based on the bootstrap hostname for the service
|
||||||
|
expression: dict(coalesce($.data, []).where($ != null).select([$.get('docker_puppet_tasks'), $.get('service_name')]).where($[0] != null).select([$[0], dict($[0].keys().zip(dict(service_name=>$[1]).repeat(len($[0].keys()))))]).select($[0].mergeWith($[1])).selectMany($.items()).groupBy($[0], $[1]))
|
||||||
data: {get_attr: [ServiceChain, role_data]}
|
data: {get_attr: [ServiceChain, role_data]}
|
||||||
|
|
||||||
HostPrepTasks:
|
HostPrepTasks:
|
||||||
|
Loading…
Reference in New Issue
Block a user