Remove unnecessary block/whitespace from step1 tasks

In Id5985ce8ac741baa9adc9f5874df0459fd4c24b2 the step1 tasks were moved
into their own file with the leading whitespace and block statement left
exactly as they were.

This patch removes the unnecessary block statement, moves the block name
to the parent inclusion and removes all the leading whitespace.

Change-Id: I243c761a88f746a6abb4ddb13845e813eaf7155c
This commit is contained in:
Jesse Pretorius (odyssey4me) 2020-01-29 12:11:25 +00:00
parent 53a7d4e402
commit 134795a13d
2 changed files with 318 additions and 316 deletions

View File

@ -1,343 +1,343 @@
- name: Write config data at the start of step 1 - name: Create and ensure setype for /var/log/containers directory
block: file:
- name: Create and ensure setype for /var/log/containers directory path: /var/log/containers
file: state: directory
path: /var/log/containers setype: container_file_t
state: directory selevel: s0
setype: container_file_t mode: 0750
selevel: s0 tags:
mode: 0750 - host_config
tags:
- host_config
- name: Create ContainerLogStdoutPath directory
file:
path: "{{ container_log_stdout_path }}"
state: directory
selevel: s0
tags:
- host_config
- name: Create /var/lib/tripleo-config directory
file:
path: /var/lib/tripleo-config
state: directory
setype: svirt_sandbox_file_t
selevel: s0
recurse: true
tags:
- host_config
- container_config
- container_config_tasks
- container_config_scripts
- container_startup_configs
- name: Delete existing /var/lib/tripleo-config/check-mode directory for check mode - name: Create ContainerLogStdoutPath directory
file: file:
path: /var/lib/tripleo-config/check-mode path: "{{ container_log_stdout_path }}"
state: absent state: directory
tags: selevel: s0
- host_config tags:
- container_config - host_config
- container_config_tasks
- container_config_scripts
- container_startup_configs
when:
- ansible_check_mode|bool
ignore_errors: true
check_mode: no
- name: Create /var/lib/tripleo-config/check-mode directory for check mode - name: Create /var/lib/tripleo-config directory
file: file:
path: /var/lib/tripleo-config/check-mode path: /var/lib/tripleo-config
state: directory state: directory
setype: svirt_sandbox_file_t setype: svirt_sandbox_file_t
selevel: s0 selevel: s0
recurse: true recurse: true
tags: tags:
- host_config - host_config
- container_config - container_config
- container_config_tasks - container_config_tasks
- container_config_scripts - container_config_scripts
- container_startup_configs - container_startup_configs
when:
- ansible_check_mode|bool
check_mode: no
# Puppet manifest for baremetal host configuration - name: Delete existing /var/lib/tripleo-config/check-mode directory for check mode
- name: Write the puppet step_config manifest file:
no_log: True path: /var/lib/tripleo-config/check-mode
copy: state: absent
content: "{{ lookup('file', tripleo_role_name + '/step_config.pp', errors='ignore') | default('', True) }}" tags:
dest: /var/lib/tripleo-config/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}puppet_step_config.pp - host_config
force: yes - container_config
mode: '0600' - container_config_tasks
tags: - container_config_scripts
- host_config - container_startup_configs
check_mode: no when:
diff: no - ansible_check_mode|bool
ignore_errors: true
check_mode: no
- name: Diff puppet step_config manifest changes for check mode - name: Create /var/lib/tripleo-config/check-mode directory for check mode
command: file:
diff -uN /var/lib/tripleo-config/puppet_step_config.pp /var/lib/tripleo-config/check-mode/puppet_step_config.pp path: /var/lib/tripleo-config/check-mode
register: diff_results state: directory
tags: setype: svirt_sandbox_file_t
- host_config selevel: s0
check_mode: no recurse: true
when: tags:
- ansible_check_mode|bool - host_config
- ansible_diff_mode - container_config
failed_when: false - container_config_tasks
changed_when: diff_results.rc == 1 - container_config_scripts
- container_startup_configs
when:
- ansible_check_mode|bool
check_mode: no
- name: Diff puppet step_config manifest changes for check mode # Puppet manifest for baremetal host configuration
debug: - name: Write the puppet step_config manifest
var: diff_results.stdout_lines no_log: True
changed_when: diff_results.rc == 1 copy:
when: content: "{{ lookup('file', tripleo_role_name + '/step_config.pp', errors='ignore') | default('', True) }}"
- ansible_check_mode|bool dest: /var/lib/tripleo-config/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}puppet_step_config.pp
- ansible_diff_mode force: yes
tags: mode: '0600'
- host_config tags:
- host_config
check_mode: no
diff: no
# Config file for our container-puppet.py script, used to generate container configs - name: Diff puppet step_config manifest changes for check mode
- name: Create /var/lib/container-puppet command:
file: diff -uN /var/lib/tripleo-config/puppet_step_config.pp /var/lib/tripleo-config/check-mode/puppet_step_config.pp
path: /var/lib/container-puppet register: diff_results
state: directory tags:
setype: svirt_sandbox_file_t - host_config
selevel: s0 check_mode: no
tags: when:
- container_config - ansible_check_mode|bool
- container_config_tasks - ansible_diff_mode
failed_when: false
changed_when: diff_results.rc == 1
- name: Delete existing /var/lib/container-puppet/check-mode for check mode - name: Diff puppet step_config manifest changes for check mode
file: debug:
path: /var/lib/container-puppet/check-mode var: diff_results.stdout_lines
state: absent changed_when: diff_results.rc == 1
tags: when:
- container_config - ansible_check_mode|bool
ignore_errors: true - ansible_diff_mode
check_mode: no tags:
when: - host_config
- ansible_check_mode|bool
- name: Create /var/lib/container-puppet/check-mode for check mode # Config file for our container-puppet.py script, used to generate container configs
file: - name: Create /var/lib/container-puppet
path: /var/lib/container-puppet/check-mode file:
state: directory path: /var/lib/container-puppet
setype: svirt_sandbox_file_t state: directory
selevel: s0 setype: svirt_sandbox_file_t
tags: selevel: s0
- container_config tags:
check_mode: no - container_config
when: - container_config_tasks
- ansible_check_mode|bool
- name: Write container-puppet.json file - name: Delete existing /var/lib/container-puppet/check-mode for check mode
no_log: True file:
copy: path: /var/lib/container-puppet/check-mode
content: "{{ lookup('file', tripleo_role_name + '/puppet_config.yaml', errors='ignore') | default([], True) | from_yaml | to_nice_json }}" state: absent
dest: /var/lib/container-puppet/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}container-puppet.json tags:
force: yes - container_config
mode: '0600' ignore_errors: true
tags: check_mode: no
- container_config when:
check_mode: no - ansible_check_mode|bool
diff: no
- name: Diff container-puppet.json changes for check mode - name: Create /var/lib/container-puppet/check-mode for check mode
command: file:
diff -uN /var/lib/container-puppet/container-puppet.json /var/lib/container-puppet/check-mode/container-puppet.json path: /var/lib/container-puppet/check-mode
register: diff_results state: directory
tags: setype: svirt_sandbox_file_t
- container_config selevel: s0
check_mode: no tags:
when: - container_config
- ansible_check_mode|bool check_mode: no
- ansible_diff_mode when:
failed_when: false - ansible_check_mode|bool
changed_when: diff_results.rc == 1
- name: Diff container-puppet.json changes for check mode - name: Write container-puppet.json file
debug: no_log: True
var: diff_results.stdout_lines copy:
changed_when: diff_results.rc == 1 content: "{{ lookup('file', tripleo_role_name + '/puppet_config.yaml', errors='ignore') | default([], True) | from_yaml | to_nice_json }}"
when: dest: /var/lib/container-puppet/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}container-puppet.json
- ansible_check_mode|bool force: yes
- ansible_diff_mode mode: '0600'
tags: tags:
- container_config - container_config
check_mode: no
diff: no
- name: Create /var/lib/container-config-scripts - name: Diff container-puppet.json changes for check mode
file: command:
path: /var/lib/container-config-scripts diff -uN /var/lib/container-puppet/container-puppet.json /var/lib/container-puppet/check-mode/container-puppet.json
state: directory register: diff_results
setype: svirt_sandbox_file_t tags:
tags: - container_config
- container_config_scripts check_mode: no
when:
- ansible_check_mode|bool
- ansible_diff_mode
failed_when: false
changed_when: diff_results.rc == 1
# The container config files - name: Diff container-puppet.json changes for check mode
# /var/lib/container-startup-configs.json is removed as we now write debug:
# per-step files instead var: diff_results.stdout_lines
- name: Clean old /var/lib/container-startup-configs.json file changed_when: diff_results.rc == 1
file: when:
path: /var/lib/container-startup-configs.json - ansible_check_mode|bool
state: absent - ansible_diff_mode
tags: tags:
- container_startup_configs - container_config
# For legacy, can be removed in Train cycle - name: Create /var/lib/container-config-scripts
- name: Clean old /var/lib/docker-container-startup-configs.json file file:
file: path: /var/lib/container-config-scripts
path: /var/lib/docker-container-startup-configs.json state: directory
state: absent setype: svirt_sandbox_file_t
tags: tags:
- container_startup_configs - container_config_scripts
# The container config files
# /var/lib/container-startup-configs.json is removed as we now write
# per-step files instead
- name: Clean old /var/lib/container-startup-configs.json file
file:
path: /var/lib/container-startup-configs.json
state: absent
tags:
- container_startup_configs
# For legacy, can be removed in Train cycle
- name: Clean old /var/lib/docker-container-startup-configs.json file
file:
path: /var/lib/docker-container-startup-configs.json
state: absent
tags:
- container_startup_configs
- name: Write container config scripts - name: Write container config scripts
no_log: True no_log: True
copy: copy:
content: "{{ item[1].content }}" content: "{{ item[1].content }}"
dest: "/var/lib/container-config-scripts/{{ item[0] }}" dest: "/var/lib/container-config-scripts/{{ item[0] }}"
force: yes force: yes
mode: "{{ item[1].mode | default('0600', true) }}" mode: "{{ item[1].mode | default('0600', true) }}"
setype: svirt_sandbox_file_t setype: svirt_sandbox_file_t
loop: "{{ role_data_container_config_scripts | dictsort }}" loop: "{{ role_data_container_config_scripts | dictsort }}"
loop_control: loop_control:
label: "{{ item[0] }}" label: "{{ item[0] }}"
vars: vars:
role_data_container_config_scripts: "{{ lookup('file', tripleo_role_name + '/container_config_scripts.yaml', errors='ignore') | default({}, True) | from_yaml }}" role_data_container_config_scripts: "{{ lookup('file', tripleo_role_name + '/container_config_scripts.yaml', errors='ignore') | default({}, True) | from_yaml }}"
tags: tags:
- container_config_scripts - container_config_scripts
# Here we are dumping all the container startup configuration data # Here we are dumping all the container startup configuration data
# so that we can have access to how they are started outside of heat # so that we can have access to how they are started outside of heat
# and container cmd. This lets us create command line tools to test containers. # and container cmd. This lets us create command line tools to test containers.
- name: Set container_config_default fact - name: Set container_config_default fact
no_log: True no_log: True
set_fact: set_fact:
container_config_default: "{{ container_config_default | default({}) | combine( {'step_' + item: {}} ) }}" container_config_default: "{{ container_config_default | default({}) | combine( {'step_' + item: {}} ) }}"
with_sequence: count={{ deploy_steps_max }} with_sequence: count={{ deploy_steps_max }}
tags: tags:
- container_startup_configs - container_startup_configs
- name: Set container_startup_configs_with_default fact - name: Set container_startup_configs_with_default fact
no_log: True no_log: True
set_fact: set_fact:
container_config_with_default: "{{ container_config_default | combine(role_data_container_config) }}" container_config_with_default: "{{ container_config_default | combine(role_data_container_config) }}"
vars: vars:
role_data_container_config: "{{ lookup('file', tripleo_role_name + '/docker_config.yaml', errors='ignore') | default({}, True) | from_yaml }}" role_data_container_config: "{{ lookup('file', tripleo_role_name + '/docker_config.yaml', errors='ignore') | default({}, True) | from_yaml }}"
tags: tags:
- container_startup_configs - container_startup_configs
# This file location is deprecated and the new location is now: # This file location is deprecated and the new location is now:
# /var/lib/tripleo-config/container-startup-config/step_X/<container_name>.json # /var/lib/tripleo-config/container-startup-config/step_X/<container_name>.json
# Can be removed in V cycle # Can be removed in V cycle
- name: Write /var/lib/tripleo-config/container-startup-config-readme.txt - name: Write /var/lib/tripleo-config/container-startup-config-readme.txt
no_log: True no_log: True
copy: copy:
content: "Container startup configs moved to /var/lib/tripleo-config/container-startup-config" content: "Container startup configs moved to /var/lib/tripleo-config/container-startup-config"
dest: /var/lib/tripleo-config/container-startup-config-readme.txt dest: /var/lib/tripleo-config/container-startup-config-readme.txt
force: yes force: yes
mode: '0600' mode: '0600'
tags: tags:
- container_startup_configs - container_startup_configs
- name: Generate startup configs files per step and per container - name: Generate startup configs files per step and per container
no_log: True no_log: True
include_tasks: container_startup_configs_tasks.yaml include_tasks: container_startup_configs_tasks.yaml
loop: "{{ container_config_with_default | dictsort }}" loop: "{{ container_config_with_default | dictsort }}"
tags: tags:
- container_startup_configs - container_startup_configs
- name: Create /var/lib/kolla/config_files directory - name: Create /var/lib/kolla/config_files directory
file: file:
path: /var/lib/kolla/config_files path: /var/lib/kolla/config_files
state: directory state: directory
setype: svirt_sandbox_file_t setype: svirt_sandbox_file_t
selevel: s0 selevel: s0
recurse: true recurse: true
tags: tags:
- container_startup_configs - container_startup_configs
- name: Create /var/lib/config-data directory - name: Create /var/lib/config-data directory
file: file:
path: /var/lib/config-data path: /var/lib/config-data
state: directory state: directory
setype: svirt_sandbox_file_t setype: svirt_sandbox_file_t
selevel: s0 selevel: s0
- name: Write kolla config json files - name: Write kolla config json files
no_log: True no_log: True
copy: copy:
content: "{{ item[1] | to_nice_json }}" content: "{{ item[1] | to_nice_json }}"
dest: "{{ item[0] }}" dest: "{{ item[0] }}"
force: yes force: yes
mode: '0600' mode: '0600'
setype: svirt_sandbox_file_t setype: svirt_sandbox_file_t
loop: "{{ lookup('file', tripleo_role_name + '/kolla_config.yaml', errors='ignore') | default([], True) | from_yaml | dictsort }}" loop: "{{ lookup('file', tripleo_role_name + '/kolla_config.yaml', errors='ignore') | default([], True) | from_yaml | dictsort }}"
loop_control: loop_control:
label: "{{ item[0] }}" label: "{{ item[0] }}"
tags: tags:
- container_startup_configs - container_startup_configs
- name: gather facts needed by role - name: gather facts needed by role
setup: setup:
gather_subset: "!min,python" gather_subset: "!min,python"
when: ansible_python is not defined when: ansible_python is not defined
tags: tags:
- container_config_tasks - 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: tags:
- container_config_tasks - container_config_tasks
- name: Set host puppet debugging fact string - name: Set host puppet debugging fact string
set_fact: set_fact:
host_puppet_config_debug: "--debug --verbose" host_puppet_config_debug: "--debug --verbose"
when: when:
- enable_puppet | bool - enable_puppet | bool
- enable_debug | bool - enable_debug | bool
tags: tags:
- host_config - host_config
- name: Check for /etc/puppet/check-mode directory for check mode - name: Check for /etc/puppet/check-mode directory for check mode
stat: stat:
path: /etc/puppet/check-mode path: /etc/puppet/check-mode
register: check_mode_dir register: check_mode_dir
when: ansible_check_mode|bool when: ansible_check_mode|bool
tags: tags:
- host_config - host_config
- container_config - container_config
- name: Create /etc/puppet/check-mode/hieradata directory for check mode - name: Create /etc/puppet/check-mode/hieradata directory for check mode
file: file:
path: /etc/puppet/check-mode/hieradata path: /etc/puppet/check-mode/hieradata
state: directory state: directory
setype: svirt_sandbox_file_t setype: svirt_sandbox_file_t
selevel: s0 selevel: s0
recurse: true recurse: true
check_mode: no check_mode: no
when: when:
- ansible_check_mode|bool - ansible_check_mode|bool
- not check_mode_dir.stat.exists - not check_mode_dir.stat.exists
tags: tags:
- host_config - host_config
- container_config - container_config
- name: Create puppet check-mode files if they don't exist for check mode - name: Create puppet check-mode files if they don't exist for check mode
shell: | shell: |
cp -a /etc/puppet/hiera.yaml /etc/puppet/check-mode/hiera.yaml cp -a /etc/puppet/hiera.yaml /etc/puppet/check-mode/hiera.yaml
cp -a /etc/puppet/hieradata/* /etc/puppet/check-mode/hieradata/ cp -a /etc/puppet/hieradata/* /etc/puppet/check-mode/hieradata/
sed -i 's/\/etc\/puppet\/hieradata/\/etc\/puppet\/check-mode\/hieradata/' /etc/puppet/check-mode/hiera.yaml sed -i 's/\/etc\/puppet\/hieradata/\/etc\/puppet\/check-mode\/hieradata/' /etc/puppet/check-mode/hiera.yaml
when: when:
- ansible_check_mode|bool - ansible_check_mode|bool
- not check_mode_dir.stat.exists - not check_mode_dir.stat.exists
check_mode: no check_mode: no
tags: tags:
- host_config - host_config
- container_config - container_config

View File

@ -837,7 +837,8 @@ outputs:
stat: stat:
path: "/var/lib/tripleo-config/container-startup-config/step_{{step}}" path: "/var/lib/tripleo-config/container-startup-config/step_{{step}}"
register: container_startup_configs_json_stat register: container_startup_configs_json_stat
- include_tasks: common_deploy_steps_tasks_step_1.yaml - name: Write config data at the start of step 1
include_tasks: common_deploy_steps_tasks_step_1.yaml
when: when:
- ((deploy_identifier is defined and deploy_identifier != "" and deploy_identifier is not none) or not container_startup_configs_json_stat.stat.exists) - ((deploy_identifier is defined and deploy_identifier != "" and deploy_identifier is not none) or not container_startup_configs_json_stat.stat.exists)
tags: tags:
@ -1023,7 +1024,8 @@ outputs:
- import_tasks: deploy_steps_tasks_step_0.yaml - import_tasks: deploy_steps_tasks_step_0.yaml
vars: vars:
step: 0 step: 0
- import_tasks: common_deploy_steps_tasks_step_1.yaml - name: Write config data at the start of step 1
import_tasks: common_deploy_steps_tasks_step_1.yaml
- include_tasks: common_deploy_steps_tasks.yaml - include_tasks: common_deploy_steps_tasks.yaml
with_sequence: start=1 end={{deploy_steps_max-1}} with_sequence: start=1 end={{deploy_steps_max-1}}
loop_control: loop_control: