2
2
3
3
import re
4
4
import os
5
+ import pathlib
6
+ import subprocess
5
7
from ansible .module_utils .basic import AnsibleModule
6
8
from ansible .module_utils .common .text .converters import to_text
7
9
@@ -24,7 +26,8 @@ def same_list_file(list1, filepath):
24
26
return same
25
27
26
28
def write_list_to_file (list1 , filepath ):
27
- os .makedirs (filepath .split ('/' )[:- 1 ], mode = 0o755 , exist_ok = True )
29
+ path = pathlib .Path (filepath )
30
+ os .makedirs (path .parent , mode = 0o755 , exist_ok = True )
28
31
f = open (filepath , "w" )
29
32
for it in list1 :
30
33
f .write (it + "\n " )
@@ -103,6 +106,7 @@ def generate_netdev(self):
103
106
else :
104
107
netdev .append ("Mode=802.3ad" )
105
108
109
+ return netdev
106
110
107
111
def main ():
108
112
# Parsing argument file
@@ -176,9 +180,10 @@ def main():
176
180
write_list_to_file (netdev , netdev_file )
177
181
178
182
# Post actions
179
- if changed == 1 :
180
- stdout , stderr = os .subprocess .Popen ("networkctl reload" , stdout = os .subprocess .PIPE , stderr = subprocess .STDOUT , shell = True ).communicate ()
181
- stdout , stderr = os .subprocess .Popen ("networkctl reconfigure " + networkd .conn_name , stdout = subprocess .PIPE , stderr = subprocess .STDOUT , shell = True ).communicate ()
183
+ #if changed == 1:
184
+ #stdout, stderr = subprocess.Popen("networkctl reload", stdout=os.subprocess.PIPE, stderr=subprocess.STDOUT, shell=True).communicate()
185
+ #stdout, stderr = subprocess.Popen("networkctl reconfigure " + networkd.conn_name, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True).communicate()
186
+
182
187
183
188
except NetworkdModuleError as e :
184
189
module .fail_json (name = networkd .conn_name , msg = str (e ))
0 commit comments