Merge "Create individual logs for each ansible run for better debugging"

This commit is contained in:
Zuul 2019-03-25 21:01:25 +00:00 committed by Gerrit Code Review
commit 6e165a6775

View File

@ -12,6 +12,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from datetime import datetime
import json import json
import logging import logging
import os import os
@ -47,8 +48,14 @@ def write_default_ansible_cfg(work_dir,
config.read(ansible_config_path) config.read(ansible_config_path)
config.set('defaults', 'retry_files_enabled', 'False') 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', 'forks', '25')
config.set('defaults', 'timeout', '30') config.set('defaults', 'timeout', '30')
config.set('defaults', 'gather_timeout', '30') config.set('defaults', 'gather_timeout', '30')