upgrade should obey check mode
This commit is contained in:
parent
75a9687a2a
commit
3eb859a01c
1 changed files with 6 additions and 2 deletions
8
apt
8
apt
|
@ -187,16 +187,20 @@ def remove(m, pkgspec, cache, purge=False):
|
||||||
m.exit_json(changed=True)
|
m.exit_json(changed=True)
|
||||||
|
|
||||||
def upgrade(m, mode="yes"):
|
def upgrade(m, mode="yes"):
|
||||||
|
if m.check_mode:
|
||||||
|
check_arg = '--simulate'
|
||||||
|
else:
|
||||||
|
check_arg = ''
|
||||||
upgrade_command = 'upgrade'
|
upgrade_command = 'upgrade'
|
||||||
if mode == "dist":
|
if mode == "dist":
|
||||||
cmd = '%s -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" dist-upgrade' % APT
|
cmd = '%s %s -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" dist-upgrade' % (APT, check_arg)
|
||||||
rc, out, err = m.run_command(cmd)
|
rc, out, err = m.run_command(cmd)
|
||||||
if rc:
|
if rc:
|
||||||
m.fail_json(msg="'apt-get %s' failed: %s" % (upgrade_command, err))
|
m.fail_json(msg="'apt-get %s' failed: %s" % (upgrade_command, err))
|
||||||
if "0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." in out :
|
if "0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." in out :
|
||||||
m.exit_json(changed=False)
|
m.exit_json(changed=False)
|
||||||
else:
|
else:
|
||||||
cmd = "/usr/bin/aptitude safe-upgrade -y"
|
cmd = "/usr/bin/aptitude safe-upgrade %s -y" % check_arg
|
||||||
rc, out, err = m.run_command(cmd)
|
rc, out, err = m.run_command(cmd)
|
||||||
if rc:
|
if rc:
|
||||||
m.fail_json(msg="'aptitude safe-upgrade' failed: %s" % err)
|
m.fail_json(msg="'aptitude safe-upgrade' failed: %s" % err)
|
||||||
|
|
Loading…
Reference in a new issue