Skip to content

Commit 03c76fa

Browse files
committed
Improve idempotency for rpm package install/removal.
1 parent bda04fb commit 03c76fa

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pyinfra/operations/util/packaging.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ def ensure_rpm(state, host, files, source, present, package_manager_command):
186186
# If we had info, always install
187187
if info:
188188
yield 'rpm -i {0}'.format(source)
189+
host.create_fact(RpmPackage, kwargs={'name': info['name']}, data=info)
189190

190191
# This happens if we download the package mid-deploy, so we have no info
191192
# but also don't know if it's installed. So check at runtime, otherwise
@@ -196,6 +197,7 @@ def ensure_rpm(state, host, files, source, present, package_manager_command):
196197
# Package exists but we don't want?
197198
elif exists and not present:
198199
yield '{0} remove -y {1}'.format(package_manager_command, info['name'])
200+
host.delete_fact(RpmPackage, kwargs={'name': info['name']})
199201

200202
else:
201203
host.noop('rpm {0} is {1}'.format(

0 commit comments

Comments
 (0)