summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/modules/postmulti4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/modules/postmulti b/lib/modules/postmulti
index 3c0a522..e6f58e3 100644
--- a/lib/modules/postmulti
+++ b/lib/modules/postmulti
@@ -13,66 +13,66 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Look up postfix configuration variable
def postconf(k, instance=None):
if instance:
cmd = [ os.path.join(os.sep, 'usr', 'sbin', 'postmulti')
, '-x'
, '-i', instance
, '--'
]
else:
cmd = []
cmd.extend([ os.path.join(os.sep, 'usr', 'sbin', 'postconf')
, '-h', k ])
- return subprocess.check_output(cmd, stderr=subprocess.STDOUT).rstrip()
+ return subprocess.check_output(cmd, stderr=subprocess.STDOUT).rstrip().decode("utf-8")
# To destroy an existing instance:
# postmulti -e disable -i mx
# postmulti -e destroy -i mx
def main():
module = AnsibleModule(
argument_spec = dict(
instance = dict( required=True ),
group = dict( required=False )
),
supports_check_mode=True
)
params = module.params
instance = params['instance']
group = params['group']
changed=False
try:
enable = postconf('multi_instance_enable')
wrapper = postconf('multi_instance_wrapper')
- if enable != "yes" or not wrapper:
+ if enable != "yes" or wrapper == "":
# Initiate postmulti
changed = True
if module.check_mode:
module.exit_json(changed=changed, msg="init postmulti")
cmd = [ os.path.join(os.sep, 'usr', 'sbin', 'postmulti') ]
cmd.extend([ '-e', 'init' ])
subprocess.check_output(cmd, stderr=subprocess.STDOUT).rstrip()
instances = postconf('multi_instance_directories').split()
if os.path.join(os.sep, 'etc', 'postfix-%s' % instance) not in instances:
changed = True
# Create the instance
if module.check_mode:
module.exit_json(changed=changed, msg="create postmulti")
cmd = [ os.path.join(os.sep, 'usr', 'sbin', 'postmulti') ]
cmd.extend([ '-e', 'create' ])
if group:
cmd.extend([ '-G', group ])
cmd.extend([ '-I', 'postfix-%s' % instance ])