diff --git a/pyinfra/operations/apk.py b/pyinfra/operations/apk.py index 6e330c1d6..33a2673cb 100644 --- a/pyinfra/operations/apk.py +++ b/pyinfra/operations/apk.py @@ -9,12 +9,17 @@ @operation -def upgrade(state=None, host=None): +def upgrade(available=False, state=None, host=None): ''' Upgrades all apk packages. + + + available: force all packages to be upgraded (recommended on whole Alpine version upgrades) ''' - yield 'apk upgrade' + if available: + yield 'apk upgrade --available' + else: + yield 'apk upgrade' _upgrade = upgrade # noqa: E305 diff --git a/tests/operations/apk.upgrade/upgrade_available.json b/tests/operations/apk.upgrade/upgrade_available.json new file mode 100644 index 000000000..4ed1c58ae --- /dev/null +++ b/tests/operations/apk.upgrade/upgrade_available.json @@ -0,0 +1,11 @@ +{ + "args": [], + "kwargs": { + "available": true + }, + "commands": [ + "apk upgrade --available" + ], + "idempotent": false, + "disable_itempotent_warning_reason": "package upgrades are always executed" +}