Hello folks,

I'm new to Python/Ansible and I'm running into a problem that's stumped me 
for 2 days. I'm trying to modify the DEFAULT_LOG_PATH variable in Python 
(the log file name will be date based). The setup below works on my local 
machine i.e it writes logs to the location set in my Python code. However, 
it fails on a the actual deployment machine. It seems like my 
DEFAULT_LOG_PATH doesn't get set because Ansible still writes the logs to 
the default DEFAULT_LOG_PATH i.e /var/log/ansible.log 

I suspect that the differing Python versions are the culprit. Upgrading the 
deployment machine to 2.7.10 might be a solution but we don't want to do 
that if we don't know for sure if that will fix the problem.

Local machine: Python v2.7.10, Ansible v1.9.4
Deployment machine: Python v2.6.6 and Ansible 1.9.4

All my import declarations:

import argparse
import getpass
import sys
import datetime
import os

import ansible.runner
import ansible.playbook
import ansible.inventory
from ansible import errors
from ansible import callbacks
from ansible.callbacks import display
from ansible import utils
from ansible.color import ANSIBLE_COLOR, stringc
from ansible import constants as ANSIBLE_CONSTANTS


The log_path modifier excerpt (for brevity):

logFile = "ansible_" + environment + "_" + 
datetime.date.today().strftime('%Y%m%d') +".log" #e.g 
ansible_prod_20160408.log
if environment != 'dev' and os.path.isdir("/usr/local/releases/logs") and 
 os.access("/usr/local/releases/logs", os.W_OK ):
    ANSIBLE_CONSTANTS.DEFAULT_LOG_PATH = "/usr/local/releases/logs/" + 
logFile
  else:
    ANSIBLE_CONSTANTS.DEFAULT_LOG_PATH = logFile
 reload(callbacks) 

Note: "reload(callbacks)" is outside the else block.

Any ideas as to what I may be missing? 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/265378fb-4bbc-45d7-92fa-ff5082486c6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to