Use deepcopy when copying ansible logging config

When using shallow copies of these data structures there is a race
between writing out the config to disk and some other Job or Server
coming along and updating handler filenames for that job/server before
the previous config is fully written to disk.

We can illustrate this in a simple example case:

  >>> d = {'foo': { 'bar': 1 } }
  >>> d1 = d.copy()
  >>> d2 = d.copy()
  >>> d1
  {'foo': {'bar': 1}}
  >>> d2
  {'foo': {'bar': 1}}
  >>> d1['foo']['bar'] = 2
  >>> d1
  {'foo': {'bar': 2}}
  >>> d2
  {'foo': {'bar': 2}}
  >>>

Notice that the inner dict is updated in both d1 and d2 because the foo
key points at a reference to that inner dict and not a copy.

We can avoid this problem entirely using deepcopies.

Change-Id: I8c1ac002af76c516621396b13375913d5d60f092
1 file changed