Commit ded7057c by Jesse Zoldak

Pass the ANSIBLE_TIMER_LOG os envar value through to the playbook command

parent 37b25c1f
......@@ -20,7 +20,7 @@ Originally written by 'Jharrod LaFon'
"""
ANSIBLE_TIMER_LOG = os.environ.get('ANSIBLE_TIMER_LOG')
print("ANSIBLE_TIMER_LOG value: {}".format(ANSIBLE_TIMER_LOG))
class Timestamp(object):
"""
......@@ -155,9 +155,11 @@ class JsonTimingLogger(TimingLogger):
})
log_path = playbook_timestamp.start.strftime(ANSIBLE_TIMER_LOG)
print('ANSIBLE_TIMER_LOG full path to file: {}'.format(os.path.abspath(log_path)))
try:
if not exists(dirname(log_path)):
print('ANSIBLE_TIMER_LOG Creating directories in path {}'.format(dirname(log_path)))
os.makedirs(dirname(log_path))
with open(log_path, 'a') as outfile:
......@@ -172,6 +174,14 @@ class JsonTimingLogger(TimingLogger):
except Exception:
LOGGER.exception("Unable to write json timing log messages")
try:
print("ANSIBLE_TIMER_LOG contents of the file are: ")
with open(log_path, 'r') as log_file:
print log_file.read()
print("ANSIBLE_TIMER_LOG end contents of the file.")
except Exception:
LOGGER.exception("Unable to read the ANSIBLE_TIMER_LOG json timing log messages")
class LoggingTimingLogger(TimingLogger):
"""
......
......@@ -2,6 +2,7 @@
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"ansible_timer_log": "{{env `ANSIBLE_TIMER_LOG`}}",
"playbook_remote_dir": "/tmp/packer-edx-playbooks",
"ami": "{{env `JENKINS_WORKER_AMI`}}",
"test_platform_version": "{{env `TEST_PLATFORM_VERSION`}}",
......@@ -82,7 +83,7 @@
"type": "ansible-local",
"playbook_file": "../../playbooks/run_role.yml",
"playbook_dir": "../../playbooks",
"command": "source {{user `playbook_remote_dir`}}/packer-venv/bin/activate && ansible-playbook",
"command": "source {{user `playbook_remote_dir`}}/packer-venv/bin/activate && ANSIBLE_TIMER_LOG='{{user `ansible_timer_log`}}' ansible-playbook",
"inventory_groups": "jenkins_worker",
"extra_arguments": [
"-e \"role=test_build_server test_edx_platform_version={{user `test_platform_version`}}\"",
......
......@@ -2,6 +2,7 @@
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"ansible_timer_log": "{{env `ANSIBLE_TIMER_LOG`}}",
"playbook_remote_dir": "/tmp/packer-edx-playbooks",
"ami": "{{env `JENKINS_WORKER_AMI`}}",
"test_platform_version": "{{env `TEST_PLATFORM_VERSION`}}"
......@@ -61,7 +62,7 @@
"type": "ansible-local",
"playbook_file": "../../playbooks/edx-east/jenkins_worker.yml",
"playbook_dir": "../../playbooks",
"command": "source {{user `playbook_remote_dir`}}/packer-venv/bin/activate && ansible-playbook",
"command": "source {{user `playbook_remote_dir`}}/packer-venv/bin/activate && ANSIBLE_TIMER_LOG='{{user `ansible_timer_log`}}' ansible-playbook",
"inventory_groups": "jenkins_worker",
"extra_arguments": [
"-vvv"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment