Be explicit when passing vars into deploy steps

Implicit defaults hide issues with overring ansible variables as we
pass values in from deploy-steps.j2.

Make no implicit defaults for variables passed into deploy steps via
ansible vars. Only expect those take the values defined in the caller
deploy-steps.j2 playbook template. Add missing params and vars for
templates to propagate ansible values for external deploy/upgrade,
upgrade/update and post upgrade steps playbooks.

Make DockerPuppetDebug boolean to align with other booleans we pass
into deploy steps via ansible vars. Fix its processing in
docker-puppet.py, which is defaults for DockerPuppetDebug: ''
converted into 'false' in deploy steps tasks playbook, and then
that becomes always True in docker-puppet.py.

Related-Bug: #1799914

Change-Id: Ia630f08f553bd53656c76e5c8059f15d314a17c0
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
This commit is contained in:
Bogdan Dobrelya 2018-10-25 12:15:12 +02:00
parent 697cefb95e
commit 35aae87301
3 changed files with 77 additions and 14 deletions

View File

@ -320,8 +320,8 @@
set_fact:
host_puppet_config_debug: "--debug --verbose"
when:
- enable_puppet | default(true) | bool
- enable_debug | default(false) | bool
- enable_puppet | bool
- enable_debug | bool
tags:
- host_config
@ -373,7 +373,7 @@
- container_config
- name: Run puppet host configuration for step {{ step }}
when: enable_puppet|default(true)|bool
when: enable_puppet|bool
command: >-
puppet apply {{ host_puppet_config_debug | default('') }}
--modulepath=/etc/puppet/modules:/opt/stack/puppet-modules:/usr/share/openstack-puppet/modules
@ -395,7 +395,7 @@
debug:
var: outputs.stdout_lines | default([]) | union(outputs.stderr_lines | default([]))
when:
- enable_puppet | default(true) | bool
- enable_puppet | bool
- outputs.rc is defined
failed_when: outputs.rc not in [0, 2]
tags:
@ -410,9 +410,9 @@
shell: "{{ python_cmd }} /var/lib/docker-puppet/docker-puppet.py"
environment:
NET_HOST: 'true'
DEBUG: '{{ docker_puppet_debug | default(false) }}'
PROCESS_COUNT: '{{ docker_puppet_process_count | default(3) }}'
CONTAINER_CLI: "{{ container_cli | default('docker') }}"
DEBUG: '{{ docker_puppet_debug | bool }}'
PROCESS_COUNT: '{{ docker_puppet_process_count }}'
CONTAINER_CLI: "{{ container_cli }}"
CONFIG: '/var/lib/docker-puppet/{{ ansible_check_mode | ternary("check-mode/", "") }}docker-puppet.json'
CONFIG_VOLUME_PREFIX: '/var/lib/config-data{{ ansible_check_mode | ternary("/check-mode", "") }}'
CHECK_MODE: '{{ ansible_check_mode | ternary(1, 0) }}'
@ -472,7 +472,7 @@
- name: Start containers for step {{ step }}
command: >-
paunch --debug apply
--default-runtime "{{ container_cli | default('docker') }}"
--default-runtime "{{ container_cli }}"
--file /var/lib/tripleo-config/hashed-docker-container-startup-config-step_{{ step }}.json
--config-id tripleo_step{{ step }} --managed-by tripleo-{{ tripleo_role_name }}
changed_when: false
@ -509,9 +509,9 @@
NET_HOST: "true"
NO_ARCHIVE: "true"
STEP: "{{ step }}"
CONTAINER_CLI: "{{ container_cli | default('docker') }}"
DEBUG: "{{ docker_puppet_debug|default(false) }}"
MOUNT_HOST_PUPPET: '{{docker_puppet_mount_host_puppet | default(true)}}'
CONTAINER_CLI: "{{ container_cli }}"
DEBUG: "{{ docker_puppet_debug }}"
MOUNT_HOST_PUPPET: '{{docker_puppet_mount_host_puppet}}'
when:
- deploy_server_id == bootstrap_server_id
- docker_puppet_tasks_json.stat.exists

View File

@ -69,8 +69,8 @@ parameters:
description: Whether to run the puppet (baremetal) deployment tasks.
type: boolean
DockerPuppetDebug:
type: string
default: ''
type: boolean
default: false
description: Set to True to enable debug logging with docker-puppet.py
DockerPuppetProcessCount:
type: number
@ -646,6 +646,13 @@ outputs:
DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts}
DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts}
CONTAINER_CLI: {get_param: ContainerCli}
DEPLOY_IDENTIFIER: {get_param: DeployIdentifier}
BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]}
ENABLE_DEBUG: {get_param: ConfigDebug}
ENABLE_PUPPET: {get_param: EnablePuppet}
DOCKER_PUPPET_DEBUG: {get_param: DockerPuppetDebug}
DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount}
DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet}
template: |
- hosts: DEPLOY_SOURCE_HOST
name: Gather facts from undercloud
@ -665,7 +672,14 @@ outputs:
gather_facts: no
any_errors_fatal: yes
vars:
bootstrap_server_id: BOOTSTRAP_SERVER_ID
deploy_identifier: DEPLOY_IDENTIFIER
enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI
docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
tasks:
- include_tasks: update_steps_tasks.yaml
with_sequence: start=0 end={{update_steps_max-1}}
@ -784,6 +798,13 @@ outputs:
DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts}
DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts}
CONTAINER_CLI: {get_param: ContainerCli}
DEPLOY_IDENTIFIER: {get_param: DeployIdentifier}
BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]}
ENABLE_DEBUG: {get_param: ConfigDebug}
ENABLE_PUPPET: {get_param: EnablePuppet}
DOCKER_PUPPET_DEBUG: {get_param: DockerPuppetDebug}
DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount}
DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet}
template: |
- hosts: DEPLOY_TARGET_HOST
any_errors_fatal: yes
@ -791,7 +812,14 @@ outputs:
- include_tasks: upgrade_steps_tasks.yaml
with_sequence: start=0 end={{upgrade_steps_max-1}}
vars:
bootstrap_server_id: BOOTSTRAP_SERVER_ID
deploy_identifier: DEPLOY_IDENTIFIER
enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI
docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
loop_control:
loop_var: step
post_upgrade_steps_tasks: |
@ -805,6 +833,13 @@ outputs:
DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts}
DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts}
CONTAINER_CLI: {get_param: ContainerCli}
DEPLOY_IDENTIFIER: {get_param: DeployIdentifier}
BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]}
ENABLE_DEBUG: {get_param: ConfigDebug}
ENABLE_PUPPET: {get_param: EnablePuppet}
DOCKER_PUPPET_DEBUG: {get_param: DockerPuppetDebug}
DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount}
DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet}
template: |
- hosts: DEPLOY_TARGET_HOST
any_errors_fatal: yes
@ -812,7 +847,14 @@ outputs:
- include_tasks: post_upgrade_steps_tasks.yaml
with_sequence: start=0 end={{post_upgrade_steps_max-1}}
vars:
bootstrap_server_id: BOOTSTRAP_SERVER_ID
deploy_identifier: DEPLOY_IDENTIFIER
enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI
docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
loop_control:
loop_var: step
external_upgrade_steps_tasks: {get_attr: [ExternalUpgradeTasks, value]}
@ -821,6 +863,13 @@ outputs:
params:
DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts}
DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts}
DEPLOY_IDENTIFIER: {get_param: DeployIdentifier}
BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]}
ENABLE_DEBUG: {get_param: ConfigDebug}
ENABLE_PUPPET: {get_param: EnablePuppet}
DOCKER_PUPPET_DEBUG: {get_param: DockerPuppetDebug}
DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount}
DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet}
CONTAINER_CLI: {get_param: ContainerCli}
template: |
- hosts: DEPLOY_SOURCE_HOST
@ -850,7 +899,14 @@ outputs:
any_errors_fatal: yes
become: false
vars:
bootstrap_server_id: BOOTSTRAP_SERVER_ID
deploy_identifier: DEPLOY_IDENTIFIER
enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI
docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
tasks:
- include: external_upgrade_steps_tasks.yaml
with_sequence: start=0 end={{external_upgrade_steps_max-1}}
@ -868,7 +924,14 @@ outputs:
any_errors_fatal: yes
become: false
vars:
bootstrap_server_id: BOOTSTRAP_SERVER_ID
deploy_identifier: DEPLOY_IDENTIFIER
enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI
docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
tasks:
- include: external_deploy_steps_tasks.yaml
with_sequence: start=1 end={{deploy_steps_max-1}}

View File

@ -41,7 +41,7 @@ def get_logger():
if logger is None:
logger = logging.getLogger()
ch = logging.StreamHandler(sys.stdout)
if os.environ.get('DEBUG', False):
if os.environ.get('DEBUG') in ['True', 'true'] :
logger.setLevel(logging.DEBUG)
ch.setLevel(logging.DEBUG)
else: