Create individual logs for each ansible run for better debugging
Currently, ansible.log file bloats with multiple run's in case of redeployment, with which analysing logs is bit difficult. Rotate the logs files before starting the deployment so that history is kept and it allows for better debugging. Change-Id: I0741956a44d35f61391e4cba94aa27974c6d5b95
This commit is contained in:
parent
3f5b75bd47
commit
2e39c89192
@ -12,6 +12,7 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from datetime import datetime
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
@ -47,8 +48,14 @@ def write_default_ansible_cfg(work_dir,
|
||||
config.read(ansible_config_path)
|
||||
|
||||
config.set('defaults', 'retry_files_enabled', 'False')
|
||||
config.set('defaults', 'log_path',
|
||||
os.path.join(work_dir, 'ansible.log'))
|
||||
|
||||
log_path = os.path.join(work_dir, 'ansible.log')
|
||||
config.set('defaults', 'log_path', log_path)
|
||||
if os.path.exists(log_path):
|
||||
new_path = (log_path + '-' +
|
||||
datetime.now().strftime("%Y-%m-%dT%H:%M:%S"))
|
||||
os.rename(log_path, new_path)
|
||||
|
||||
config.set('defaults', 'forks', '25')
|
||||
config.set('defaults', 'timeout', '30')
|
||||
config.set('defaults', 'gather_timeout', '30')
|
||||
|
Loading…
x
Reference in New Issue
Block a user