tripleo-heat-templates/common/host-container-puppet-tasks.yaml
Alex Schultz 1a085631c0 [Ussuri and older] Set python_cmd where we need it
If you use --start-at-tasks, python_cmd may not be defined when we run
the generate configuration or host container tasks.  We should ensure
this variable is set prior to using it.

This variable was no longer used with the transition of the
container-puppet.py items into ansible itself so it only applies for
Ussuri and older.

Change-Id: I956307d5c69cd4d259fb1ab2731fe0001a196c8e
Closes-Bug: #1907858
2021-01-04 21:45:10 +00:00

98 lines
4.1 KiB
YAML

- name: Write container-puppet-tasks json file for {{ansible_hostname | lower}} step {{step}}
no_log: True
copy:
content: "{{lookup ('vars', 'host_container_puppet_tasks_' ~ step, default=[]) | to_nice_json}}"
dest: "/var/lib/container-puppet/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}container-puppet-tasks{{step}}.json"
force: yes
mode: '0600'
check_mode: no
tags:
- container_config_tasks
- name: Gather ansible facts if necessary
setup:
gather_subset: "!min,python"
when: ansible_python is not defined
tags:
- container_config_tasks
- name: Set python_cmd if necessary
set_fact:
python_cmd: "python{{ ansible_python.version.major }}"
cacheable: true
when: python_cmd is not defined
tags:
- container_config_tasks
- name: Block for container-puppet tasks (bootstrap tasks) for step {{ step }} with paunch
when:
- enable_paunch|default(true)
tags:
- container_config_tasks
block:
- name: Run container-puppet tasks (bootstrap tasks) for step {{ step }} with paunch
async: 3600
poll: 0
shell: "{{ python_cmd }} /var/lib/container-puppet/container-puppet.py"
environment:
CONFIG: /var/lib/container-puppet/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}container-puppet-tasks{{ step }}.json
CONFIG_VOLUME_PREFIX: '/var/lib/config-data{{ ansible_check_mode | bool | ternary("/check-mode", "") }}'
NET_HOST: "true"
NO_ARCHIVE: "true"
STEP: "{{ step }}"
CONTAINER_CLI: "{{ container_cli }}"
DEBUG: "{{ docker_puppet_debug }}"
MOUNT_HOST_PUPPET: '{{docker_puppet_mount_host_puppet}}'
SHORT_HOSTNAME: "{{ ansible_hostname | lower }}"
PROCESS_COUNT: "{{ docker_puppet_process_count }}"
register: bootstrap_tasks_async_result
no_log: true
- name: Wait for container-puppet tasks (bootstrap tasks) for step {{ step }} to finish
async_status:
jid: "{{ bootstrap_tasks_async_result.ansible_job_id }}"
register: bootstrap_tasks_outputs
until: bootstrap_tasks_outputs.finished
retries: 1200
delay: 3
- name: "Debug output for task: Run container-puppet tasks (bootstrap tasks) for step {{ step }}"
debug:
var: bootstrap_tasks_outputs.stdout_lines | default([]) | union(bootstrap_tasks_outputs.stderr_lines | default([]))
when:
- bootstrap_tasks_outputs.rc is defined
failed_when: bootstrap_tasks_outputs.rc != 0
- name: Block for container-puppet tasks (bootstrap tasks) for step {{ step }} with tripleo-ansible
when:
- not enable_paunch|default(true)
tags:
- container_config_tasks
block:
- name: "Generate container puppet configs for step {{ step }}"
container_puppet_config:
check_mode: '{{ ansible_check_mode | bool | ternary(1, 0) }}'
config_vol_prefix: "/var/lib/config-data{{ ansible_check_mode | bool | ternary('/check-mode', '') }}"
debug: "{{ docker_puppet_debug | bool }}"
net_host: true
no_archive: true
puppet_config: "/var/lib/container-puppet/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}container-puppet-tasks{{ step }}.json"
short_hostname: "{{ ansible_hostname | lower }}"
step: "{{ step }}"
- name: "Manage Puppet containers (bootstrap tasks) for step {{ step }} with tripleo-ansible"
include_role:
name: tripleo_container_manage
vars:
tripleo_container_manage_concurrency: "{{ docker_puppet_process_count }}"
tripleo_container_manage_systemd_order: false
tripleo_container_manage_systemd_teardown: false
tripleo_container_manage_config: "/var/lib/tripleo-config/container-puppet-config/step_{{ step }}"
tripleo_container_manage_config_patterns: 'container-puppet-*.json'
tripleo_container_manage_config_id: "tripleo_puppet_step{{ step }}"
tripleo_container_manage_debug: "{{ docker_puppet_debug | bool }}"
# puppet with --detailed-exitcodes will return 0 for success and
# no changes and 2 for success and resource changes. Other
# numbers are failures
tripleo_container_manage_valid_exit_code: [0, 2]