Merge "check mode: docker_puppet"
This commit is contained in:
commit
c262998fcf
@ -27,8 +27,8 @@
|
|||||||
state: absent
|
state: absent
|
||||||
tags:
|
tags:
|
||||||
- host_config
|
- host_config
|
||||||
- container_puppet
|
- container_config
|
||||||
- container_puppet_tasks
|
- container_config_tasks
|
||||||
- container_config_scripts
|
- container_config_scripts
|
||||||
- container_startup_configs
|
- container_startup_configs
|
||||||
when:
|
when:
|
||||||
@ -45,8 +45,8 @@
|
|||||||
recurse: true
|
recurse: true
|
||||||
tags:
|
tags:
|
||||||
- host_config
|
- host_config
|
||||||
- container_puppet
|
- container_config
|
||||||
- container_puppet_tasks
|
- container_config_tasks
|
||||||
- container_config_scripts
|
- container_config_scripts
|
||||||
- container_startup_configs
|
- container_startup_configs
|
||||||
when:
|
when:
|
||||||
@ -98,14 +98,62 @@
|
|||||||
tags:
|
tags:
|
||||||
- container_config
|
- container_config
|
||||||
|
|
||||||
|
- name: Delete existing /var/lib/docker-puppet/check-mode for check mode
|
||||||
|
file:
|
||||||
|
path: /var/lib/docker-puppet/check-mode
|
||||||
|
state: absent
|
||||||
|
tags:
|
||||||
|
- container_config
|
||||||
|
ignore_errors: true
|
||||||
|
check_mode: no
|
||||||
|
when:
|
||||||
|
- ansible_check_mode
|
||||||
|
|
||||||
|
- name: Create /var/lib/docker-puppet/check-mode for check mode
|
||||||
|
file:
|
||||||
|
path: /var/lib/docker-puppet/check-mode
|
||||||
|
state: directory
|
||||||
|
setype: svirt_sandbox_file_t
|
||||||
|
selevel: s0
|
||||||
|
tags:
|
||||||
|
- container_config
|
||||||
|
check_mode: no
|
||||||
|
when:
|
||||||
|
- ansible_check_mode
|
||||||
|
|
||||||
- name: Write docker-puppet.json file
|
- name: Write docker-puppet.json file
|
||||||
copy:
|
copy:
|
||||||
content: "{{ lookup('file', tripleo_role_name + '/puppet_config.yaml', errors='ignore') | default([], True) | from_yaml | to_json }}"
|
content: "{{ lookup('file', tripleo_role_name + '/puppet_config.yaml', errors='ignore') | default([], True) | from_yaml | to_nice_json }}"
|
||||||
dest: /var/lib/docker-puppet/docker-puppet.json
|
dest: /var/lib/docker-puppet/{{ ansible_check_mode | ternary('check-mode/', '') }}docker-puppet.json
|
||||||
force: yes
|
force: yes
|
||||||
mode: '0600'
|
mode: '0600'
|
||||||
tags:
|
tags:
|
||||||
- container_config
|
- container_config
|
||||||
|
check_mode: no
|
||||||
|
diff: no
|
||||||
|
|
||||||
|
- name: Diff docker-puppet.json changes for check mode
|
||||||
|
command:
|
||||||
|
diff -uN /var/lib/docker-puppet/docker-puppet.json /var/lib/docker-puppet/check-mode/docker-puppet.json
|
||||||
|
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
|
||||||
|
|
||||||
|
- name: Diff docker-puppet.json changes for check mode
|
||||||
|
debug:
|
||||||
|
var: diff_results.stdout_lines
|
||||||
|
changed_when: diff_results.rc == 1
|
||||||
|
when:
|
||||||
|
- ansible_check_mode
|
||||||
|
- ansible_diff_mode
|
||||||
|
tags:
|
||||||
|
- container_config
|
||||||
|
|
||||||
- name: Create /var/lib/docker-config-scripts
|
- name: Create /var/lib/docker-config-scripts
|
||||||
file:
|
file:
|
||||||
@ -115,7 +163,6 @@
|
|||||||
tags:
|
tags:
|
||||||
- container_config_scripts
|
- container_config_scripts
|
||||||
|
|
||||||
|
|
||||||
# The container config files
|
# The container config files
|
||||||
# /var/lib/docker-container-startup-configs.json is removed as we now write
|
# /var/lib/docker-container-startup-configs.json is removed as we now write
|
||||||
# per-step files instead
|
# per-step files instead
|
||||||
@ -141,7 +188,6 @@
|
|||||||
tags:
|
tags:
|
||||||
- container_config_scripts
|
- container_config_scripts
|
||||||
|
|
||||||
|
|
||||||
# Here we are dumping all the docker container startup configuration data
|
# 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
|
# so that we can have access to how they are started outside of heat
|
||||||
# and docker-cmd. This lets us create command line tools to test containers.
|
# and docker-cmd. This lets us create command line tools to test containers.
|
||||||
@ -262,6 +308,7 @@
|
|||||||
when: ansible_check_mode
|
when: ansible_check_mode
|
||||||
tags:
|
tags:
|
||||||
- host_config
|
- host_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:
|
||||||
@ -276,6 +323,7 @@
|
|||||||
- not check_mode_dir.stat.exists
|
- not check_mode_dir.stat.exists
|
||||||
tags:
|
tags:
|
||||||
- host_config
|
- host_config
|
||||||
|
- container_config
|
||||||
|
|
||||||
- name: Write the config_step hieradata
|
- name: Write the config_step hieradata
|
||||||
copy:
|
copy:
|
||||||
@ -298,6 +346,7 @@
|
|||||||
check_mode: no
|
check_mode: no
|
||||||
tags:
|
tags:
|
||||||
- host_config
|
- host_config
|
||||||
|
- container_config
|
||||||
|
|
||||||
- name: Run puppet host configuration for step {{ step }}
|
- name: Run puppet host configuration for step {{ step }}
|
||||||
when: enable_puppet|default(true)|bool
|
when: enable_puppet|default(true)|bool
|
||||||
@ -339,6 +388,10 @@
|
|||||||
DEBUG: '{{ docker_puppet_debug | default(false) }}'
|
DEBUG: '{{ docker_puppet_debug | default(false) }}'
|
||||||
PROCESS_COUNT: '{{ docker_puppet_process_count | default(3) }}'
|
PROCESS_COUNT: '{{ docker_puppet_process_count | default(3) }}'
|
||||||
CONTAINER_CLI: "{{ container_cli | default('docker') }}"
|
CONTAINER_CLI: "{{ container_cli | default('docker') }}"
|
||||||
|
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) }}'
|
||||||
|
STARTUP_CONFIG_PATTERN: '/var/lib/tripleo-config/{{ ansible_check_mode | ternary("check-mode/", "") }}docker-container-startup-config-step_*.json'
|
||||||
when: step == "1"
|
when: step == "1"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
check_mode: no
|
check_mode: no
|
||||||
@ -356,6 +409,31 @@
|
|||||||
tags:
|
tags:
|
||||||
- container_config
|
- container_config
|
||||||
|
|
||||||
|
- name: Diff docker-puppet.py puppet-generated changes for check mode
|
||||||
|
command:
|
||||||
|
diff -ruN /var/lib/config-data/puppet-generated /var/lib/config-data/check-mode/puppet-generated
|
||||||
|
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
|
||||||
|
|
||||||
|
- name: Diff docker-puppet.py puppet-generated changes for check mode
|
||||||
|
debug:
|
||||||
|
var: diff_results.stdout_lines
|
||||||
|
changed_when: diff_results.rc == 1
|
||||||
|
when:
|
||||||
|
- step == "1"
|
||||||
|
- ansible_check_mode
|
||||||
|
- ansible_diff_mode
|
||||||
|
tags:
|
||||||
|
- container_config
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
# Per step starting of the containers using paunch
|
# Per step starting of the containers using paunch
|
||||||
##################################################
|
##################################################
|
||||||
|
@ -255,6 +255,13 @@ with open(sh_script, 'w') as script_file:
|
|||||||
TAGS="--tags \"$PUPPET_TAGS\""
|
TAGS="--tags \"$PUPPET_TAGS\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
CHECK_MODE=""
|
||||||
|
if [ -d "/tmp/puppet-check-mode" ]; then
|
||||||
|
mkdir -p /etc/puppet/check-mode
|
||||||
|
cp -a /tmp/puppet-check-mode/* /etc/puppet/check-mode
|
||||||
|
CHECK_MODE="--hiera_config /etc/puppet/check-mode/hiera.yaml"
|
||||||
|
fi
|
||||||
|
|
||||||
# Create a reference timestamp to easily find all files touched by
|
# Create a reference timestamp to easily find all files touched by
|
||||||
# puppet. The sync ensures we get all the files we want due to
|
# puppet. The sync ensures we get all the files we want due to
|
||||||
# different timestamp.
|
# different timestamp.
|
||||||
@ -276,6 +283,7 @@ with open(sh_script, 'w') as script_file:
|
|||||||
--logdest console \
|
--logdest console \
|
||||||
--modulepath=/etc/puppet/modules:/usr/share/openstack-puppet/modules \
|
--modulepath=/etc/puppet/modules:/usr/share/openstack-puppet/modules \
|
||||||
$TAGS \
|
$TAGS \
|
||||||
|
$CHECK_MODE \
|
||||||
/etc/config.pp
|
/etc/config.pp
|
||||||
rc=$?
|
rc=$?
|
||||||
set -e
|
set -e
|
||||||
@ -322,7 +330,7 @@ with open(sh_script, 'w') as script_file:
|
|||||||
|
|
||||||
|
|
||||||
def mp_puppet_config(*args):
|
def mp_puppet_config(*args):
|
||||||
(config_volume,puppet_tags,manifest,config_image,volumes,privileged) = args[0]
|
(config_volume,puppet_tags,manifest,config_image,volumes,privileged,check_mode) = args[0]
|
||||||
log = get_logger()
|
log = get_logger()
|
||||||
log.info('Starting configuration of %s using image %s' % (config_volume,
|
log.info('Starting configuration of %s using image %s' % (config_volume,
|
||||||
config_image))
|
config_image))
|
||||||
@ -332,6 +340,8 @@ def mp_puppet_config(*args):
|
|||||||
log.debug('config_image %s' % config_image)
|
log.debug('config_image %s' % config_image)
|
||||||
log.debug('volumes %s' % volumes)
|
log.debug('volumes %s' % volumes)
|
||||||
log.debug('privileged %s' % privileged)
|
log.debug('privileged %s' % privileged)
|
||||||
|
log.debug('check_mode %s' % check_mode)
|
||||||
|
|
||||||
with tempfile.NamedTemporaryFile() as tmp_man:
|
with tempfile.NamedTemporaryFile() as tmp_man:
|
||||||
with open(tmp_man.name, 'w') as man_file:
|
with open(tmp_man.name, 'w') as man_file:
|
||||||
man_file.write('include ::tripleo::packages\n')
|
man_file.write('include ::tripleo::packages\n')
|
||||||
@ -368,6 +378,11 @@ def mp_puppet_config(*args):
|
|||||||
|
|
||||||
dcmd = common_dcmd + cli_dcmd
|
dcmd = common_dcmd + cli_dcmd
|
||||||
|
|
||||||
|
if check_mode:
|
||||||
|
dcmd.extend([
|
||||||
|
'--volume',
|
||||||
|
'/etc/puppet/check-mode:/tmp/puppet-check-mode:ro'])
|
||||||
|
|
||||||
for volume in volumes:
|
for volume in volumes:
|
||||||
if volume:
|
if volume:
|
||||||
dcmd.extend(['--volume', volume])
|
dcmd.extend(['--volume', volume])
|
||||||
@ -415,6 +430,9 @@ def mp_puppet_config(*args):
|
|||||||
# to consume.
|
# to consume.
|
||||||
process_map = []
|
process_map = []
|
||||||
|
|
||||||
|
check_mode = int(os.environ.get('CHECK_MODE', 0))
|
||||||
|
log.debug('CHECK_MODE: %s' % check_mode)
|
||||||
|
|
||||||
for config_volume in configs:
|
for config_volume in configs:
|
||||||
|
|
||||||
service = configs[config_volume]
|
service = configs[config_volume]
|
||||||
@ -429,7 +447,8 @@ for config_volume in configs:
|
|||||||
else:
|
else:
|
||||||
puppet_tags = "file,file_line,concat,augeas,cron"
|
puppet_tags = "file,file_line,concat,augeas,cron"
|
||||||
|
|
||||||
process_map.append([config_volume, puppet_tags, manifest, config_image, volumes, privileged])
|
process_map.append([config_volume, puppet_tags, manifest, config_image,
|
||||||
|
volumes, privileged, check_mode])
|
||||||
|
|
||||||
for p in process_map:
|
for p in process_map:
|
||||||
log.debug('- %s' % p)
|
log.debug('- %s' % p)
|
||||||
@ -451,7 +470,7 @@ for returncode, config_volume in zip(returncodes, config_volumes):
|
|||||||
# Update the startup configs with the config hash we generated above
|
# Update the startup configs with the config hash we generated above
|
||||||
startup_configs = os.environ.get('STARTUP_CONFIG_PATTERN', '/var/lib/tripleo-config/docker-container-startup-config-step_*.json')
|
startup_configs = os.environ.get('STARTUP_CONFIG_PATTERN', '/var/lib/tripleo-config/docker-container-startup-config-step_*.json')
|
||||||
log.debug('STARTUP_CONFIG_PATTERN: %s' % startup_configs)
|
log.debug('STARTUP_CONFIG_PATTERN: %s' % startup_configs)
|
||||||
infiles = glob.glob('/var/lib/tripleo-config/docker-container-startup-config-step_*.json')
|
infiles = glob.glob(startup_configs)
|
||||||
for infile in infiles:
|
for infile in infiles:
|
||||||
with open(infile) as f:
|
with open(infile) as f:
|
||||||
infile_data = json.load(f)
|
infile_data = json.load(f)
|
||||||
|
Loading…
Reference in New Issue
Block a user