2017-07-20 15:04:10 +01:00
|
|
|
# Note the indentation here is required as it's joined
|
|
|
|
# to create a playbook in deploy-steps.j2
|
2017-12-04 13:55:10 +00:00
|
|
|
##################################################
|
|
|
|
# Step 1 block, write data for subsequent steps
|
|
|
|
##################################################
|
2018-11-07 14:43:34 +01:00
|
|
|
- name: gather facts needed by role
|
|
|
|
setup:
|
|
|
|
gather_subset: "!min,python"
|
|
|
|
when: ansible_python is not defined
|
2018-12-13 17:56:44 +00:00
|
|
|
tags:
|
|
|
|
- container_config_tasks
|
2018-11-07 14:43:34 +01:00
|
|
|
|
|
|
|
- name: set python_cmd
|
|
|
|
set_fact:
|
|
|
|
python_cmd: "python{{ ansible_python.version.major }}"
|
|
|
|
cacheable: true
|
|
|
|
when: python_cmd is not defined
|
2018-12-13 17:56:44 +00:00
|
|
|
tags:
|
|
|
|
- container_config_tasks
|
|
|
|
|
2018-11-07 14:43:34 +01:00
|
|
|
|
|
|
|
- name: print python facts
|
|
|
|
debug:
|
|
|
|
msg: "python_cmd: {{ python_cmd }}"
|
2018-12-13 17:56:44 +00:00
|
|
|
tags:
|
|
|
|
- container_config_tasks
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2017-12-04 13:55:10 +00:00
|
|
|
- name: Write config data at the start of step 1
|
|
|
|
when: step == "1"
|
|
|
|
block:
|
2018-11-28 13:56:13 +01:00
|
|
|
- name: Create and ensure setype for /var/log/containers directory
|
|
|
|
file:
|
|
|
|
path: /var/log/containers
|
|
|
|
state: directory
|
|
|
|
setype: var_log_t
|
|
|
|
selevel: s0
|
|
|
|
tags:
|
|
|
|
- host_config
|
2019-02-08 09:55:07 +01:00
|
|
|
- name: Create ContainerLogStdoutPath directory
|
2019-02-06 14:40:08 +01:00
|
|
|
file:
|
2019-02-08 09:55:07 +01:00
|
|
|
path: "{{ container_log_stdout_path }}"
|
2019-02-06 14:40:08 +01:00
|
|
|
state: directory
|
|
|
|
selevel: s0
|
|
|
|
tags:
|
|
|
|
- host_config
|
2017-12-04 13:55:10 +00:00
|
|
|
- name: Create /var/lib/tripleo-config directory
|
2018-04-10 14:57:24 -04:00
|
|
|
file:
|
|
|
|
path: /var/lib/tripleo-config
|
|
|
|
state: directory
|
|
|
|
setype: svirt_sandbox_file_t
|
|
|
|
selevel: s0
|
|
|
|
recurse: true
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- host_config
|
|
|
|
- container_config
|
|
|
|
- container_config_tasks
|
|
|
|
- container_config_scripts
|
|
|
|
- container_startup_configs
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2018-09-04 17:12:00 -04:00
|
|
|
- name: Delete existing /var/lib/tripleo-config/check-mode directory for check mode
|
|
|
|
file:
|
|
|
|
path: /var/lib/tripleo-config/check-mode
|
|
|
|
state: absent
|
|
|
|
tags:
|
|
|
|
- host_config
|
2018-09-06 14:37:14 -04:00
|
|
|
- container_config
|
|
|
|
- container_config_tasks
|
2018-09-04 17:12:00 -04:00
|
|
|
- container_config_scripts
|
|
|
|
- container_startup_configs
|
|
|
|
when:
|
|
|
|
- ansible_check_mode
|
|
|
|
ignore_errors: true
|
|
|
|
check_mode: no
|
|
|
|
|
|
|
|
- name: Create /var/lib/tripleo-config/check-mode directory for check mode
|
|
|
|
file:
|
|
|
|
path: /var/lib/tripleo-config/check-mode
|
|
|
|
state: directory
|
|
|
|
setype: svirt_sandbox_file_t
|
|
|
|
selevel: s0
|
|
|
|
recurse: true
|
|
|
|
tags:
|
|
|
|
- host_config
|
2018-09-06 14:37:14 -04:00
|
|
|
- container_config
|
|
|
|
- container_config_tasks
|
2018-09-04 17:12:00 -04:00
|
|
|
- container_config_scripts
|
|
|
|
- container_startup_configs
|
|
|
|
when:
|
|
|
|
- ansible_check_mode
|
|
|
|
check_mode: no
|
|
|
|
|
2017-12-04 13:55:10 +00:00
|
|
|
# Puppet manifest for baremetal host configuration
|
|
|
|
- name: Write the puppet step_config manifest
|
2018-04-10 14:57:24 -04:00
|
|
|
copy:
|
|
|
|
content: "{{ lookup('file', tripleo_role_name + '/step_config.pp', errors='ignore') | default('', True) }}"
|
2018-09-04 17:12:00 -04:00
|
|
|
dest: /var/lib/tripleo-config/{{ ansible_check_mode | ternary('check-mode/', '') }}puppet_step_config.pp
|
2018-04-10 14:57:24 -04:00
|
|
|
force: yes
|
|
|
|
mode: '0600'
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- host_config
|
2018-09-04 17:12:00 -04:00
|
|
|
check_mode: no
|
|
|
|
diff: no
|
|
|
|
|
|
|
|
- name: Diff puppet step_config manifest changes for check mode
|
|
|
|
command:
|
|
|
|
diff -uN /var/lib/tripleo-config/puppet_step_config.pp /var/lib/tripleo-config/check-mode/puppet_step_config.pp
|
|
|
|
register: diff_results
|
|
|
|
tags:
|
|
|
|
- host_config
|
|
|
|
check_mode: no
|
|
|
|
when:
|
|
|
|
- ansible_check_mode
|
|
|
|
- ansible_diff_mode
|
|
|
|
failed_when: false
|
|
|
|
changed_when: diff_results.rc == 1
|
|
|
|
|
|
|
|
- name: Diff puppet step_config manifest changes for check mode
|
|
|
|
debug:
|
|
|
|
var: diff_results.stdout_lines
|
|
|
|
changed_when: diff_results.rc == 1
|
|
|
|
when:
|
|
|
|
- ansible_check_mode
|
|
|
|
- ansible_diff_mode
|
|
|
|
tags:
|
|
|
|
- host_config
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2019-03-01 14:58:57 -05:00
|
|
|
# Config file for our container-puppet.py script, used to generate container configs
|
|
|
|
- name: Create /var/lib/container-puppet
|
2018-04-10 14:57:24 -04:00
|
|
|
file:
|
2019-03-01 14:58:57 -05:00
|
|
|
path: /var/lib/container-puppet
|
2018-04-10 14:57:24 -04:00
|
|
|
state: directory
|
|
|
|
setype: svirt_sandbox_file_t
|
|
|
|
selevel: s0
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_config
|
2018-09-06 21:05:13 -04:00
|
|
|
- container_config_tasks
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2019-03-01 14:58:57 -05:00
|
|
|
# For backward compatibility in Stein, so our operators have time
|
|
|
|
# to learn about the new directory.
|
|
|
|
- name: Create /var/lib/docker-puppet for backward compatibility
|
|
|
|
file:
|
|
|
|
path: /var/lib/docker-puppet
|
|
|
|
state: directory
|
|
|
|
tags:
|
|
|
|
- container_config
|
|
|
|
- container_config_tasks
|
|
|
|
|
|
|
|
- name: Deprecation file about /var/lib/docker-puppet
|
|
|
|
copy:
|
|
|
|
dest: /var/lib/docker-puppet/readme.txt
|
|
|
|
content: |
|
|
|
|
/var/lib/docker-puppet was moved under
|
|
|
|
/var/lib/container-puppet because we don't run Docker anymore.
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: Delete existing /var/lib/container-puppet/container-puppet.sh
|
2019-01-08 21:47:00 -05:00
|
|
|
file:
|
2019-03-01 14:58:57 -05:00
|
|
|
path: /var/lib/container-puppet/container-puppet.sh
|
2019-01-08 21:47:00 -05:00
|
|
|
state: absent
|
|
|
|
tags:
|
|
|
|
- container_config
|
|
|
|
ignore_errors: true
|
|
|
|
check_mode: no
|
|
|
|
|
2019-03-01 14:58:57 -05:00
|
|
|
- name: Delete existing /var/lib/container-puppet/check-mode for check mode
|
2018-09-06 14:37:14 -04:00
|
|
|
file:
|
2019-03-01 14:58:57 -05:00
|
|
|
path: /var/lib/container-puppet/check-mode
|
2018-09-06 14:37:14 -04:00
|
|
|
state: absent
|
|
|
|
tags:
|
|
|
|
- container_config
|
|
|
|
ignore_errors: true
|
|
|
|
check_mode: no
|
|
|
|
when:
|
|
|
|
- ansible_check_mode
|
|
|
|
|
2019-03-01 14:58:57 -05:00
|
|
|
- name: Create /var/lib/container-puppet/check-mode for check mode
|
2018-09-06 14:37:14 -04:00
|
|
|
file:
|
2019-03-01 14:58:57 -05:00
|
|
|
path: /var/lib/container-puppet/check-mode
|
2018-09-06 14:37:14 -04:00
|
|
|
state: directory
|
|
|
|
setype: svirt_sandbox_file_t
|
|
|
|
selevel: s0
|
|
|
|
tags:
|
|
|
|
- container_config
|
|
|
|
check_mode: no
|
|
|
|
when:
|
|
|
|
- ansible_check_mode
|
|
|
|
|
2019-03-01 14:58:57 -05:00
|
|
|
- name: Write container-puppet.json file
|
2018-04-10 14:57:24 -04:00
|
|
|
copy:
|
2018-09-06 14:37:14 -04:00
|
|
|
content: "{{ lookup('file', tripleo_role_name + '/puppet_config.yaml', errors='ignore') | default([], True) | from_yaml | to_nice_json }}"
|
2019-03-01 14:58:57 -05:00
|
|
|
dest: /var/lib/container-puppet/{{ ansible_check_mode | ternary('check-mode/', '') }}container-puppet.json
|
2018-04-10 14:57:24 -04:00
|
|
|
force: yes
|
|
|
|
mode: '0600'
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_config
|
2018-09-06 14:37:14 -04:00
|
|
|
check_mode: no
|
|
|
|
diff: no
|
|
|
|
|
2019-03-01 14:58:57 -05:00
|
|
|
- name: Diff container-puppet.json changes for check mode
|
2018-09-06 14:37:14 -04:00
|
|
|
command:
|
2019-03-01 14:58:57 -05:00
|
|
|
diff -uN /var/lib/container-puppet/container-puppet.json /var/lib/container-puppet/check-mode/container-puppet.json
|
2018-09-06 14:37:14 -04:00
|
|
|
register: diff_results
|
|
|
|
tags:
|
|
|
|
- container_config
|
|
|
|
check_mode: no
|
|
|
|
when:
|
|
|
|
- ansible_check_mode
|
|
|
|
- ansible_diff_mode
|
|
|
|
failed_when: false
|
|
|
|
changed_when: diff_results.rc == 1
|
|
|
|
|
2019-03-01 14:58:57 -05:00
|
|
|
- name: Diff container-puppet.json changes for check mode
|
2018-09-06 14:37:14 -04:00
|
|
|
debug:
|
|
|
|
var: diff_results.stdout_lines
|
|
|
|
changed_when: diff_results.rc == 1
|
|
|
|
when:
|
|
|
|
- ansible_check_mode
|
|
|
|
- ansible_diff_mode
|
|
|
|
tags:
|
|
|
|
- container_config
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2017-12-04 13:55:10 +00:00
|
|
|
- name: Create /var/lib/docker-config-scripts
|
2018-04-10 14:57:24 -04:00
|
|
|
file:
|
|
|
|
path: /var/lib/docker-config-scripts
|
|
|
|
state: directory
|
2018-09-05 13:59:21 +02:00
|
|
|
setype: svirt_sandbox_file_t
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_config_scripts
|
2018-04-10 14:57:24 -04:00
|
|
|
|
2017-12-04 13:55:10 +00:00
|
|
|
# The container config files
|
|
|
|
# /var/lib/docker-container-startup-configs.json is removed as we now write
|
|
|
|
# per-step files instead
|
|
|
|
- name: Clean old /var/lib/docker-container-startup-configs.json file
|
|
|
|
file:
|
|
|
|
path: /var/lib/docker-container-startup-configs.json
|
|
|
|
state: absent
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_startup_configs
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2017-12-04 13:55:10 +00:00
|
|
|
- name: Write docker config scripts
|
2018-04-10 14:57:24 -04:00
|
|
|
copy:
|
2018-09-17 17:26:47 -04:00
|
|
|
content: "{{ item[1].content }}"
|
|
|
|
dest: "/var/lib/docker-config-scripts/{{ item[0] }}"
|
2018-04-10 14:57:24 -04:00
|
|
|
force: yes
|
2018-09-17 17:26:47 -04:00
|
|
|
mode: "{{ item[1].mode | default('0600', true) }}"
|
2018-10-03 14:56:59 +02:00
|
|
|
setype: svirt_sandbox_file_t
|
2018-09-17 17:26:47 -04:00
|
|
|
loop: "{{ role_data_docker_config_scripts | dictsort }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item[0] }}"
|
2018-04-10 14:57:24 -04:00
|
|
|
vars:
|
|
|
|
role_data_docker_config_scripts: "{{ lookup('file', tripleo_role_name + '/docker_config_scripts.yaml', errors='ignore') | default({}, True) | from_yaml }}"
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_config_scripts
|
2018-04-10 14:57:24 -04:00
|
|
|
|
2017-12-04 13:55:10 +00:00
|
|
|
# Here we are dumping all the docker container startup configuration data
|
|
|
|
# so that we can have access to how they are started outside of heat
|
2018-04-10 14:57:24 -04:00
|
|
|
# and docker-cmd. This lets us create command line tools to test containers.
|
|
|
|
# FIXME We need to update the defaults, e.g in docker-tool, so we can remove the
|
2017-12-04 13:55:10 +00:00
|
|
|
# docker-container-startup-configs.json and use per-step configs instead
|
|
|
|
- name: Set docker_config_default fact
|
2018-04-03 17:43:57 -04:00
|
|
|
no_log: True
|
2017-12-04 13:55:10 +00:00
|
|
|
set_fact:
|
2018-04-10 14:57:24 -04:00
|
|
|
docker_config_default: "{{ docker_config_default | default({}) | combine( {'step_' + item: {}} ) }}"
|
|
|
|
with_sequence: count={{ deploy_steps_max }}
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_startup_configs
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2017-12-04 13:55:10 +00:00
|
|
|
- name: Set docker_startup_configs_with_default fact
|
2018-04-03 17:43:57 -04:00
|
|
|
no_log: True
|
2017-12-04 13:55:10 +00:00
|
|
|
set_fact:
|
2018-04-10 14:57:24 -04:00
|
|
|
docker_config_with_default: "{{ docker_config_default | combine(role_data_docker_config) }}"
|
|
|
|
vars:
|
|
|
|
role_data_docker_config: "{{ lookup('file', tripleo_role_name + '/docker_config.yaml', errors='ignore') | default({}, True) | from_yaml }}"
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_startup_configs
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2017-12-04 13:55:10 +00:00
|
|
|
- name: Write docker-container-startup-configs
|
2018-04-10 14:57:24 -04:00
|
|
|
copy:
|
2018-09-17 17:19:53 -04:00
|
|
|
content: "{{ docker_config_with_default | to_nice_json }}"
|
2018-04-10 14:57:24 -04:00
|
|
|
dest: /var/lib/docker-container-startup-configs.json
|
|
|
|
force: yes
|
|
|
|
mode: '0600'
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_startup_configs
|
2018-09-17 17:19:53 -04:00
|
|
|
diff: no
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2017-12-04 13:55:10 +00:00
|
|
|
- name: Write per-step docker-container-startup-configs
|
2018-04-10 14:57:24 -04:00
|
|
|
copy:
|
2018-09-17 17:19:53 -04:00
|
|
|
content: "{{ item[1] | to_nice_json }}"
|
|
|
|
dest: /var/lib/tripleo-config/docker-container-startup-config-{{ item[0] }}.json
|
2018-04-10 14:57:24 -04:00
|
|
|
force: yes
|
|
|
|
mode: '0600'
|
2018-09-17 17:26:47 -04:00
|
|
|
loop: "{{ docker_config_with_default | dictsort }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item[0] }}"
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_startup_configs
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2017-12-04 13:55:10 +00:00
|
|
|
- name: Create /var/lib/kolla/config_files directory
|
2018-04-10 14:57:24 -04:00
|
|
|
file:
|
|
|
|
path: /var/lib/kolla/config_files
|
|
|
|
state: directory
|
|
|
|
setype: svirt_sandbox_file_t
|
|
|
|
selevel: s0
|
|
|
|
recurse: true
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_startup_configs
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2018-09-05 13:59:21 +02:00
|
|
|
- name: Create /var/lib/config-data directory
|
|
|
|
file:
|
|
|
|
path: /var/lib/config-data
|
|
|
|
state: directory
|
|
|
|
setype: svirt_sandbox_file_t
|
|
|
|
selevel: s0
|
|
|
|
|
2017-12-04 13:55:10 +00:00
|
|
|
- name: Write kolla config json files
|
2018-04-10 14:57:24 -04:00
|
|
|
copy:
|
2018-09-17 17:19:53 -04:00
|
|
|
content: "{{ item[1] | to_nice_json }}"
|
2018-09-17 17:26:47 -04:00
|
|
|
dest: "{{ item[0] }}"
|
2018-04-10 14:57:24 -04:00
|
|
|
force: yes
|
|
|
|
mode: '0600'
|
2018-10-03 14:56:59 +02:00
|
|
|
setype: svirt_sandbox_file_t
|
2018-09-17 17:26:47 -04:00
|
|
|
loop: "{{ lookup('file', tripleo_role_name + '/kolla_config.yaml', errors='ignore') | default([], True) | from_yaml | dictsort }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item[0] }}"
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_startup_configs
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2017-05-03 17:12:55 +01:00
|
|
|
#####################################################
|
|
|
|
# Per step puppet configuration of the baremetal host
|
|
|
|
#####################################################
|
2018-01-30 19:41:35 -05:00
|
|
|
|
Fix ConfigDebug for puppet host runs
Before pike we used to be able to add -e environments/config-debug.yaml
and that would give us debug logs for puppet. With the move to ansible
running puppet we lost this feature.
Let's make sure that the old ConfigDebug variable still works with
the ansible playbook-based deploy steps. With this patch and ConfigDebug
set to true, we correctly get the puppet debug logs:
TASK [debug] *******************************************************************
ok: [localhost] => {
"(outputs.stderr|default('')).split('\n')|union(outputs.stdout_lines|default([]))": [
"Warning: Undefined variable 'deploy_config_name'; ",
" (file & line not available)",
"Warning: This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README. at [\"/etc/puppet/modules/ntp/manifests/init.pp\", 54]:[\"/etc/puppet/modules/tripleo/manifests/profile/base/time/ntp.pp\", 29]",
" (at /etc/puppet/modules/stdlib/lib/puppet/functions/deprecation.rb:25:in `deprecation')",
"Debug: Runtime environment: puppet_version=4.8.2, ruby_version=2.0.0, run_mode=user, default_encoding=UTF-8",
"Debug: Loading external facts from /etc/puppet/modules/openstacklib/facts.d",
"Debug: Loading external facts from /var/lib/puppet/facts.d",
....
Change-Id: Ia726fb8ca4a6f7bbbd7a1284d76ff42df6825d01
Closes-Bug: #1722752
2017-10-11 12:47:01 +02:00
|
|
|
- name: Set host puppet debugging fact string
|
|
|
|
set_fact:
|
|
|
|
host_puppet_config_debug: "--debug --verbose"
|
2018-03-06 13:43:07 -05:00
|
|
|
when:
|
2018-10-25 12:15:12 +02:00
|
|
|
- enable_puppet | bool
|
|
|
|
- enable_debug | bool
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- host_config
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2018-09-04 17:12:00 -04:00
|
|
|
- name: Check for /etc/puppet/check-mode directory for check mode
|
|
|
|
stat:
|
|
|
|
path: /etc/puppet/check-mode
|
|
|
|
register: check_mode_dir
|
|
|
|
when: ansible_check_mode
|
|
|
|
tags:
|
|
|
|
- host_config
|
2018-09-06 14:37:14 -04:00
|
|
|
- container_config
|
2018-09-04 17:12:00 -04:00
|
|
|
|
|
|
|
- name: Create /etc/puppet/check-mode/hieradata directory for check mode
|
|
|
|
file:
|
|
|
|
path: /etc/puppet/check-mode/hieradata
|
|
|
|
state: directory
|
|
|
|
setype: svirt_sandbox_file_t
|
|
|
|
selevel: s0
|
|
|
|
recurse: true
|
|
|
|
check_mode: no
|
|
|
|
when:
|
|
|
|
- ansible_check_mode
|
|
|
|
- not check_mode_dir.stat.exists
|
|
|
|
tags:
|
|
|
|
- host_config
|
2018-09-06 14:37:14 -04:00
|
|
|
- container_config
|
2018-09-04 17:12:00 -04:00
|
|
|
|
2017-05-03 17:12:55 +01:00
|
|
|
- name: Write the config_step hieradata
|
2018-04-10 14:57:24 -04:00
|
|
|
copy:
|
|
|
|
content: "{{ dict(step=step|int) | to_json }}"
|
2018-09-04 17:12:00 -04:00
|
|
|
dest: /etc/puppet/{{ ansible_check_mode | ternary('check-mode/', '') }}hieradata/config_step.json
|
2018-04-10 14:57:24 -04:00
|
|
|
force: true
|
|
|
|
mode: '0600'
|
2018-09-04 17:12:00 -04:00
|
|
|
check_mode: no
|
|
|
|
tags:
|
|
|
|
- host_config
|
|
|
|
|
|
|
|
- name: Create puppet check-mode files if they don't exist for check mode
|
|
|
|
shell: |
|
|
|
|
cp -a /etc/puppet/hiera.yaml /etc/puppet/check-mode/hiera.yaml
|
|
|
|
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
|
|
|
|
when:
|
|
|
|
- ansible_check_mode
|
|
|
|
- not check_mode_dir.stat.exists
|
|
|
|
check_mode: no
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- host_config
|
2018-09-06 14:37:14 -04:00
|
|
|
- container_config
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2018-04-10 14:57:24 -04:00
|
|
|
- name: Run puppet host configuration for step {{ step }}
|
2018-10-25 12:15:12 +02:00
|
|
|
when: enable_puppet|bool
|
2017-06-09 18:03:50 +02:00
|
|
|
command: >-
|
2018-04-10 14:57:24 -04:00
|
|
|
puppet apply {{ host_puppet_config_debug | default('') }}
|
2017-06-09 18:03:50 +02:00
|
|
|
--modulepath=/etc/puppet/modules:/opt/stack/puppet-modules:/usr/share/openstack-puppet/modules
|
2017-10-12 17:37:50 +02:00
|
|
|
--detailed-exitcodes
|
2018-01-03 12:55:55 -08:00
|
|
|
--summarize
|
2017-07-27 13:59:04 -04:00
|
|
|
--logdest syslog --logdest console --color=false
|
2018-09-04 17:12:00 -04:00
|
|
|
{{ ansible_check_mode | ternary('--noop', '') }}
|
|
|
|
{{ ansible_check_mode | ternary('--hiera_config /etc/puppet/check-mode/hiera.yaml', '') }}
|
|
|
|
/var/lib/tripleo-config/{{ ansible_check_mode | ternary('check-mode/', '') }}puppet_step_config.pp
|
2017-10-12 17:37:50 +02:00
|
|
|
changed_when: outputs.rc == 2
|
2017-06-09 18:03:50 +02:00
|
|
|
register: outputs
|
|
|
|
failed_when: false
|
|
|
|
no_log: true
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- host_config
|
2018-09-04 17:12:00 -04:00
|
|
|
check_mode: no
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2018-08-30 12:07:47 -04:00
|
|
|
- name: "Debug output for task: Run puppet host configuration for step {{ step }}"
|
2018-04-10 14:57:24 -04:00
|
|
|
debug:
|
|
|
|
var: outputs.stdout_lines | default([]) | union(outputs.stderr_lines | default([]))
|
2018-03-06 13:43:07 -05:00
|
|
|
when:
|
2018-10-25 12:15:12 +02:00
|
|
|
- enable_puppet | bool
|
2018-04-10 14:57:24 -04:00
|
|
|
- outputs.rc is defined
|
2017-10-12 17:37:50 +02:00
|
|
|
failed_when: outputs.rc not in [0, 2]
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- host_config
|
2018-09-21 14:58:47 -04:00
|
|
|
ignore_errors: "{{ ansible_check_mode }}"
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2017-05-03 17:12:55 +01:00
|
|
|
######################################
|
2019-03-01 14:58:57 -05:00
|
|
|
# Generate config via container-puppet.py
|
2017-05-03 17:12:55 +01:00
|
|
|
######################################
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2019-03-01 14:58:57 -05:00
|
|
|
- name: Run container-puppet tasks (generate config) during step {{ step }}
|
|
|
|
shell: "{{ python_cmd }} /var/lib/container-puppet/container-puppet.py"
|
2017-05-03 17:12:55 +01:00
|
|
|
environment:
|
|
|
|
NET_HOST: 'true'
|
2018-10-25 12:15:12 +02:00
|
|
|
DEBUG: '{{ docker_puppet_debug | bool }}'
|
|
|
|
PROCESS_COUNT: '{{ docker_puppet_process_count }}'
|
|
|
|
CONTAINER_CLI: "{{ container_cli }}"
|
2019-03-01 14:58:57 -05:00
|
|
|
CONFIG: '/var/lib/container-puppet/{{ ansible_check_mode | ternary("check-mode/", "") }}container-puppet.json'
|
2018-09-06 14:37:14 -04:00
|
|
|
CONFIG_VOLUME_PREFIX: '/var/lib/config-data{{ ansible_check_mode | ternary("/check-mode", "") }}'
|
|
|
|
CHECK_MODE: '{{ ansible_check_mode | ternary(1, 0) }}'
|
|
|
|
STARTUP_CONFIG_PATTERN: '/var/lib/tripleo-config/{{ ansible_check_mode | ternary("check-mode/", "") }}docker-container-startup-config-step_*.json'
|
2018-03-08 09:13:42 -05:00
|
|
|
MOUNT_HOST_PUPPET: '{{docker_puppet_mount_host_puppet | default(true)}}'
|
2019-02-08 09:55:07 +01:00
|
|
|
CONTAINER_LOG_STDOUT_PATH: "{{ container_log_stdout_path }}"
|
2017-05-03 17:12:55 +01:00
|
|
|
when: step == "1"
|
|
|
|
changed_when: false
|
|
|
|
check_mode: no
|
2017-06-09 18:03:50 +02:00
|
|
|
register: outputs
|
|
|
|
failed_when: false
|
|
|
|
no_log: true
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_config
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2019-03-01 14:58:57 -05:00
|
|
|
- name: "Debug output for task: Run container-puppet tasks (generate config) during step {{ step }}"
|
2018-04-10 14:57:24 -04:00
|
|
|
debug:
|
|
|
|
var: outputs.stdout_lines | default([]) | union(outputs.stderr_lines | default([]))
|
2017-11-20 20:48:50 +01:00
|
|
|
when: outputs.rc is defined
|
|
|
|
failed_when: outputs.rc != 0
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_config
|
2018-09-21 14:58:47 -04:00
|
|
|
ignore_errors: "{{ ansible_check_mode }}"
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2019-03-01 14:58:57 -05:00
|
|
|
- name: Diff container-puppet.py puppet-generated changes for check mode
|
2018-09-06 21:05:13 -04:00
|
|
|
shell: |
|
|
|
|
diff -ruN --no-dereference -q /var/lib/config-data/puppet-generated /var/lib/config-data/check-mode/puppet-generated
|
|
|
|
diff -ruN --no-dereference /var/lib/config-data/puppet-generated /var/lib/config-data/check-mode/puppet-generated
|
2018-09-06 14:37:14 -04:00
|
|
|
register: diff_results
|
|
|
|
tags:
|
|
|
|
- container_config
|
|
|
|
check_mode: no
|
|
|
|
when:
|
|
|
|
- step == "1"
|
|
|
|
- ansible_check_mode
|
|
|
|
- ansible_diff_mode
|
|
|
|
failed_when: false
|
|
|
|
changed_when: diff_results.rc == 1
|
|
|
|
|
2019-03-01 14:58:57 -05:00
|
|
|
- name: Diff container-puppet.py puppet-generated changes for check mode
|
2018-09-06 14:37:14 -04:00
|
|
|
debug:
|
|
|
|
var: diff_results.stdout_lines
|
|
|
|
changed_when: diff_results.rc == 1
|
|
|
|
when:
|
|
|
|
- step == "1"
|
|
|
|
- ansible_check_mode
|
|
|
|
- ansible_diff_mode
|
|
|
|
tags:
|
|
|
|
- container_config
|
|
|
|
|
2017-05-03 17:12:55 +01:00
|
|
|
##################################################
|
|
|
|
# Per step starting of the containers using paunch
|
|
|
|
##################################################
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2019-03-01 14:58:57 -05:00
|
|
|
# Note container-puppet.py generates the hashed-*.json file, which is a copy of
|
2017-05-19 16:38:56 +01:00
|
|
|
# the *step_n.json with a hash of the generated external config added
|
|
|
|
# This acts as a salt to enable restarting the container if config changes
|
2019-02-08 09:55:07 +01:00
|
|
|
# TODO(cjeanner): add --container-log-path {{ container_log_stdout_path }} once
|
|
|
|
# we have new paunch version related to
|
|
|
|
# https://review.openstack.org/#/c/635438/
|
2018-04-10 14:57:24 -04:00
|
|
|
- name: Start containers for step {{ step }}
|
2019-02-08 10:38:10 +01:00
|
|
|
environment:
|
|
|
|
TRIPLEO_MINOR_UPDATE: '{{ tripleo_minor_update | default(false) }}'
|
2017-06-09 18:03:50 +02:00
|
|
|
command: >-
|
2018-10-24 10:40:48 +02:00
|
|
|
paunch {% if enable_debug|bool %}--debug{% else %}-v{% endif %} apply
|
2018-10-25 12:15:12 +02:00
|
|
|
--default-runtime "{{ container_cli }}"
|
2018-04-10 14:57:24 -04:00
|
|
|
--file /var/lib/tripleo-config/hashed-docker-container-startup-config-step_{{ step }}.json
|
|
|
|
--config-id tripleo_step{{ step }} --managed-by tripleo-{{ tripleo_role_name }}
|
2017-05-03 17:12:55 +01:00
|
|
|
changed_when: false
|
2017-06-09 18:03:50 +02:00
|
|
|
register: outputs
|
|
|
|
failed_when: false
|
|
|
|
no_log: true
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_startup_configs
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2018-08-30 12:07:47 -04:00
|
|
|
- name: "Debug output for task: Start containers for step {{ step }}"
|
2018-04-10 14:57:24 -04:00
|
|
|
debug:
|
|
|
|
var: outputs.stdout_lines | default([]) | union(outputs.stderr_lines | default([]))
|
2017-11-20 20:48:50 +01:00
|
|
|
when: outputs.rc is defined
|
|
|
|
failed_when: outputs.rc != 0
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_startup_configs
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2017-05-03 17:12:55 +01:00
|
|
|
########################################################
|
2018-12-13 17:56:44 +00:00
|
|
|
# Bootstrap tasks - run any tasks that have been defined
|
2017-05-03 17:12:55 +01:00
|
|
|
########################################################
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2018-12-13 17:56:44 +00:00
|
|
|
- name: "Clean docker_puppet_tasks for {{ansible_hostname}} step {{step}}"
|
|
|
|
file:
|
2019-03-01 14:58:57 -05:00
|
|
|
path: /var/lib/container-puppet/container-puppet-tasks{{step}}.json
|
2018-12-13 17:56:44 +00:00
|
|
|
state: absent
|
|
|
|
tags:
|
|
|
|
- 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
|
|
|
|
|
2019-03-01 14:58:57 -05:00
|
|
|
- name: Write container-puppet-tasks json file for {{ansible_hostname}} step {{step}}
|
2018-12-13 17:56:44 +00:00
|
|
|
copy:
|
|
|
|
content: "{{host_docker_puppet_tasks|to_nice_json}}"
|
2019-03-01 14:58:57 -05:00
|
|
|
dest: "/var/lib/container-puppet/container-puppet-tasks{{step}}.json"
|
2018-12-13 17:56:44 +00:00
|
|
|
force: yes
|
|
|
|
mode: '0600'
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_config_tasks
|
2018-12-13 17:56:44 +00:00
|
|
|
when: host_docker_puppet_tasks is defined
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2019-03-01 14:58:57 -05:00
|
|
|
- name: Run container-puppet tasks (bootstrap tasks) for step {{ step }}
|
|
|
|
shell: "{{ python_cmd }} /var/lib/container-puppet/container-puppet.py"
|
2017-05-03 17:12:55 +01:00
|
|
|
environment:
|
2019-03-01 14:58:57 -05:00
|
|
|
CONFIG: /var/lib/container-puppet/{{ ansible_check_mode | ternary('check-mode/', '') }}container-puppet-tasks{{ step }}.json
|
2018-09-06 21:05:13 -04:00
|
|
|
CONFIG_VOLUME_PREFIX: '/var/lib/config-data{{ ansible_check_mode | ternary("/check-mode", "") }}'
|
2017-05-03 17:12:55 +01:00
|
|
|
NET_HOST: "true"
|
|
|
|
NO_ARCHIVE: "true"
|
2018-04-10 14:57:24 -04:00
|
|
|
STEP: "{{ step }}"
|
2018-10-25 12:15:12 +02:00
|
|
|
CONTAINER_CLI: "{{ container_cli }}"
|
|
|
|
DEBUG: "{{ docker_puppet_debug }}"
|
|
|
|
MOUNT_HOST_PUPPET: '{{docker_puppet_mount_host_puppet}}'
|
2018-12-13 17:56:44 +00:00
|
|
|
when: host_docker_puppet_tasks is defined
|
2017-05-03 17:12:55 +01:00
|
|
|
changed_when: false
|
2017-06-09 18:03:50 +02:00
|
|
|
register: outputs
|
|
|
|
failed_when: false
|
|
|
|
no_log: true
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_config_tasks
|
2018-01-30 19:41:35 -05:00
|
|
|
|
2019-03-01 14:58:57 -05:00
|
|
|
- name: "Debug output for task: Run container-puppet tasks (bootstrap tasks) for step {{ step }}"
|
2018-04-10 14:57:24 -04:00
|
|
|
debug:
|
|
|
|
var: outputs.stdout_lines | default([]) | union(outputs.stderr_lines | default([]))
|
2017-11-20 20:48:50 +01:00
|
|
|
when: outputs.rc is defined
|
|
|
|
failed_when: outputs.rc != 0
|
2018-09-06 08:53:28 -04:00
|
|
|
tags:
|
|
|
|
- container_config_tasks
|